/* Libro de historia de la pertulma ultramarina. Ver DECISIONES.md §5 y DESIGN.md. */
:root {
  --papel: #f4f4f1;          /* papel de libro, gris cálido muy claro (no crema) */
  --papel-hondo: #ebebe6;
  --tinta: #1b1d24;
  --tenue: #62666f;
  --oro: #a8873f;            /* filetes y ornamentos */
  --azul: #1d36a8;           /* enlaces y acentos */
  --linea: #d9d8d2;
  --ancho: 68ch;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papel: #10131f;
    --papel-hondo: #161a2a;
    --tinta: #ece8de;
    --tenue: #a9adba;
    --oro: #c9a96a;
    --azul: #a9b8ff;
    --linea: #2a3047;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 20px/1.75 "EB Garamond", Garamond, "Times New Roman", serif;
  font-variant-numeric: oldstyle-nums proportional-nums;
}
a { color: var(--azul); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--oro); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--oro); outline-offset: 3px; border-radius: 2px; }

/* ---------- Guardas marmoladas y lomo dorado ---------- */
.guarda {
  height: 112px;
  background: #0b1a6e url(/img/guarda.svg) center / cover no-repeat;
  border-bottom: 5px solid transparent;
  border-image: linear-gradient(90deg, #8a6c2c, #e2c98a 45%, #a8873f 70%, #8a6c2c) 1;
  view-transition-name: guarda;
}

/* ---------- Portadilla: nombre del libro y salas ---------- */
.portadilla { text-align: center; padding: 18px 16px 0; border-bottom: 1px solid var(--linea); view-transition-name: portadilla; }
.marca {
  font-family: "Cormorant Garamond", "EB Garamond", serif; font-style: italic; font-weight: 500;
  font-size: 1.35rem; color: var(--tinta); text-decoration: none;
}
.salas {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 26px;
  padding: 8px 0 12px; font-variant: small-caps; letter-spacing: .06em; font-size: 1.02rem;
}
.salas a { color: var(--tenue); text-decoration: none; padding: 4px 0; border-bottom: 1px solid transparent; }
.salas a:hover { color: var(--tinta); }
.salas a[aria-current="page"] { color: var(--tinta); border-bottom-color: var(--oro); }

/* ---------- La página ---------- */
.pagina { max-width: calc(var(--ancho) + 32px); margin: 0 auto; padding: 64px 16px 40px; }
.sala {
  margin: 0; text-align: center; font-variant: small-caps; letter-spacing: .16em;
  color: var(--oro); font-size: 1rem;
}
h1, h2, h3 { font-family: "Cormorant Garamond", "EB Garamond", serif; font-weight: 600; line-height: 1.1; }
h1 {
  text-align: center; font-weight: 500; font-size: clamp(2.6rem, 6vw, 4.6rem); letter-spacing: -.005em;
  margin: .15em 0 0; view-transition-name: titulo;
}
h1 i { display: block; font-weight: 500; font-size: .62em; color: var(--azul); }
/* Orla bajo el título */
h1::after {
  content: "❦"; display: flex; align-items: center; justify-content: center; width: 190px; margin: 22px auto 36px;
  font-family: "EB Garamond", serif; font-size: 1.1rem; font-style: normal; color: var(--oro); letter-spacing: 0;
  background: linear-gradient(var(--oro), var(--oro)) left center / 70px 1px no-repeat,
              linear-gradient(var(--oro), var(--oro)) right center / 70px 1px no-repeat;
}
h2 { font-size: 2rem; margin: 2.1em 0 .45em; }
h2::before { content: "§ "; color: var(--oro); font-weight: 500; }
h3 { font-size: 1.4rem; font-style: italic; font-weight: 500; margin: 1.6em 0 .3em; }
p { margin: 0 0 1.05em; }

/* Respuesta en una frase, con capitular en azul pertulma */
.lead { font-size: 1.2rem; margin-bottom: 1.4em; }
.lead strong { font-weight: 500; }
.lead::first-letter {
  float: left; font-family: "Cormorant Garamond", serif; font-weight: 600;
  font-size: 4.4em; line-height: .78; margin: .06em .1em 0 0; padding-right: .02em;
  color: #1532b4;
  background: radial-gradient(140% 125% at 28% -12%, #5a78ff 0%, #2747e0 22%, #1532b4 45%, #0b1a6e 72%, #040a2b 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ---------- Tablas como tablas de un libro ---------- */
table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: .8em 0 1.4em; border-top: 1px solid var(--oro); font-variant-numeric: lining-nums tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: top; }
thead th { font-weight: 500; font-variant: small-caps; letter-spacing: .06em; color: var(--tenue); border-bottom: 1px solid var(--oro); }
.ficha th { width: 34%; font-weight: 400; font-style: italic; color: var(--tenue); }
.importe { text-align: right; white-space: nowrap; color: var(--tenue); }
.libro td:first-child { width: 4.5em; font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 1.2rem; color: var(--azul); }

/* ---------- Citas y listas ---------- */
.asiento { margin: 2.2em 0; padding: 0 1.5em; text-align: center; font-style: italic; font-size: 1.3rem; font-family: "Cormorant Garamond", serif; }
.asiento p { margin: 0 0 .35em; }
.asiento::before { content: "❧"; display: block; font-style: normal; color: var(--oro); font-size: 1.1rem; margin-bottom: .3em; }
.asiento cite { display: block; font-family: "EB Garamond", serif; font-style: normal; font-size: .9rem; color: var(--tenue); }
ul, ol { padding-left: 1.3em; }
li { margin: .35em 0; }
.indice { list-style: none; padding: 0; border-top: 1px solid var(--linea); }
.indice li { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--linea); }
.pasos, .capas { list-style: none; padding: 0; }
.pasos { counter-reset: paso; } .capas { counter-reset: capa; }
.pasos li, .capas li { position: relative; padding-left: 2.6em; margin: .8em 0; }
.pasos li { counter-increment: paso; } .capas li { counter-increment: capa; }
.pasos li::before, .capas li::before {
  position: absolute; left: 0; top: -.05em; width: 2.2em;
  font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 1.15rem; color: var(--oro);
}
.pasos li::before { content: counter(paso, upper-roman) "."; }
.capas li::before { content: counter(capa, upper-roman) "."; }
.meta { margin-top: 3em; text-align: center; color: var(--tenue); font-size: .9rem; font-style: italic; }

/* ---------- Pintura de carro: color, tono perlado y laca ---------- */
:root {
  --laca-fondo: radial-gradient(140% 125% at 28% -12%, #5a78ff 0%, #2747e0 20%, #1532b4 42%, #0b1a6e 68%, #040a2b 100%);
  --laca-tono: linear-gradient(var(--angulo, 115deg), rgba(64,210,255,.28) 0%, rgba(64,210,255,0) 32%, rgba(0,0,0,0) 62%, rgba(120,40,220,.38) 100%);
}
.laca { position: relative; overflow: hidden; isolation: isolate; background: var(--laca-tono), var(--laca-fondo); }
.laca::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at var(--luz-x, 30%) var(--luz-y, -10%), rgba(255,255,255,.42) 0, rgba(190,210,255,.14) 18%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, rgba(255,255,255,.38) 0%, rgba(255,255,255,.08) 16%, rgba(255,255,255,0) 34%),
    linear-gradient(176deg, rgba(255,255,255,0) 52%, rgba(255,255,255,.28) 53.2%, rgba(255,255,255,.06) 56%, rgba(255,255,255,0) 62%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), inset 0 -22px 34px -22px rgba(0,0,0,.6);
}

/* ---------- Láminas y piezas ---------- */
.panel-laca, .foto { margin: 2.2em 0; }
.panel-laca { padding: 14px; border: 1px solid var(--oro); background: var(--papel-hondo); }
.muestra-grande { height: 280px; }
figcaption { margin-top: .8em; font-size: .92rem; line-height: 1.5; color: var(--tenue); font-style: italic; }
figcaption[data-pieza]::before { content: attr(data-pieza); display: block; font-style: normal; font-variant: small-caps; letter-spacing: .08em; color: var(--oro); }
.foto img { display: block; width: 100%; height: auto; background: var(--linea); outline: 1px solid var(--linea); outline-offset: 6px; }
.foto-chica img { max-width: 450px; }
.foto-retrato img { max-width: 26rem; }
.foto-retrato, .foto-chica { display: flex; flex-direction: column; align-items: center; }
.foto-retrato figcaption, .foto-chica figcaption { max-width: 34rem; text-align: center; }
.credito { display: block; font-style: normal; font-size: .82rem; margin-top: .2em; }
.ampliable { cursor: zoom-in; }

/* Galería de piezas */
.galeria { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; align-items: start; margin: 1.6em 0 2.2em; }
.galeria .foto { margin: 0; }
.galeria figcaption { font-size: .82rem; }

/* Recorrido de salas en la portada */
.recorrido { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border-top: 1px solid var(--oro); margin: .6em 0 1.4em; }
.recorrido a {
  display: block; padding: 18px 20px 20px; text-decoration: none; color: var(--tinta);
  border-bottom: 1px solid var(--linea); transition: background-color .25s;
}
.recorrido a:nth-child(odd) { border-right: 1px solid var(--linea); }
.recorrido small { display: block; font-variant: small-caps; letter-spacing: .14em; color: var(--oro); font-size: .85rem; }
.recorrido b { display: block; font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 1.45rem; line-height: 1.15; margin: .15em 0 .25em; }
.recorrido span { display: block; color: var(--tenue); font-size: .92rem; line-height: 1.45; }
.recorrido a:hover { background: var(--papel-hondo); }
.recorrido a:hover b { color: var(--azul); }

/* Visor de láminas */
.visor { padding: 0; border: 0; max-width: min(92vw, 1100px); max-height: 94vh; background: transparent; color: #ece8de; overflow: visible; }
.visor::backdrop { background: rgba(8, 10, 20, .96); }
.visor img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; }
.visor p { text-align: center; font-style: italic; font-size: .95rem; margin: .8em auto 0; max-width: 60ch; }
.visor button {
  position: fixed; top: 16px; right: 20px; font: inherit; font-size: 1rem; color: #ece8de;
  background: transparent; border: 1px solid rgba(236,232,222,.4); padding: 4px 14px; cursor: pointer;
}

/* ---------- Cronología interactiva (movimiento.js la arma sobre la tabla .libro) ---------- */
.cronologia { margin: 1.4em 0 .6em; }
.cronologia-pista { position: relative; height: 58px; margin: 0 12px; }
.cronologia-pista::before { content: ""; position: absolute; left: 0; right: 0; top: 24px; height: 1px; background: var(--oro); }
.cronologia-pista button {
  position: absolute; top: 15px; width: 18px; height: 18px; margin-left: -9px; padding: 0; border-radius: 50%;
  border: 1px solid var(--oro); background: var(--papel); cursor: pointer; transition: transform .2s, background-color .2s;
}
.cronologia-pista button[aria-pressed="true"], .cronologia-pista button:hover { background: #1532b4; border-color: #1532b4; transform: scale(1.3); }
.cronologia-pista span { position: absolute; top: 40px; transform: translateX(-50%); font-size: .78rem; color: var(--tenue); font-variant-numeric: lining-nums; white-space: nowrap; }
.cronologia-ficha { min-height: 7em; padding: 16px 20px; border: 1px solid var(--linea); background: var(--papel-hondo); }
.cronologia-ficha b { display: block; font-family: "Cormorant Garamond", serif; font-size: 1.7rem; line-height: 1.1; color: var(--azul); }
.cronologia-ficha p { margin: .3em 0 0; }
.libro tr.activo td { background: var(--papel-hondo); }

/* ---------- Cómo citar: ficha bibliográfica ---------- */
.cita { margin: 3.2em 0 0; padding: 16px 20px; border: 1px solid var(--linea); border-top: 2px solid var(--oro); background: var(--papel-hondo); font-size: .92rem; line-height: 1.55; }
.cita p { margin: 0; }
.cita-titulo { font-variant: small-caps; letter-spacing: .12em; color: var(--oro); margin-bottom: .3em !important; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cita-texto { overflow-wrap: anywhere; }
.cita button { font: inherit; font-variant: small-caps; letter-spacing: .06em; font-size: .85rem; color: var(--azul); background: none; border: 1px solid var(--linea); padding: 1px 10px; cursor: pointer; }
.cita button:hover { border-color: var(--oro); }

/* ---------- Colofón ---------- */
.colofon { max-width: 580px; margin: 0 auto; padding: 24px 16px 72px; text-align: center; color: var(--tenue); font-size: .95rem; }
.colofon::before { content: "❧"; display: block; color: var(--oro); font-size: 1.5rem; margin-bottom: .4em; }
.colofon .titulo-colofon { font-variant: small-caps; letter-spacing: .2em; color: var(--tinta); font-size: 1.05rem; margin-bottom: .8em; }
.colofon p { margin: 0 0 .8em; }
.colofon .vinculos { font-variant: small-caps; letter-spacing: .06em; }
.colofon .insignia img { max-width: 220px; height: auto; margin-top: .6em; }

/* ---------- Movimiento ---------- */
@view-transition { navigation: auto; }
@keyframes entrar { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes entintar { from { opacity: .25; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes salir-hoja { to { opacity: 0; transform: translateX(-28px); } }
@keyframes entrar-hoja { from { opacity: 0; transform: translateX(28px); } }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: 300ms ease both salir-hoja; }
  ::view-transition-new(root) { animation: 420ms ease both entrar-hoja; }
  .sala, .pagina > h1 { animation: entrar .7s ease-out both; }
  .lead { animation: entrar .7s ease-out .15s both; }
  .panel-laca { animation: entrar .8s ease-out .3s both; }
  @supports (animation-timeline: view()) {
    .pagina > :is(h2, p:not(.lead), ul, ol, blockquote, figure:not(.panel-laca), table) {
      animation: entintar linear both; animation-timeline: view(); animation-range: entry 0% entry 60%;
    }
  }
  .foto img { transition: transform .5s cubic-bezier(.2,.7,.2,1); }
  .foto:hover img { transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* ---------- Pantallas angostas ---------- */
@media (max-width: 700px) {
  body { font-size: 18px; }
  .guarda { height: 72px; }
  .salas { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding: 8px 16px 12px 4px; }
  .salas a { white-space: nowrap; }
  .pagina { padding-top: 40px; }
  h2 { font-size: 1.7rem; }
  .muestra-grande { height: 190px; }
  .ficha th { width: 40%; }
  .cronologia-pista span { font-size: .68rem; }
  .galeria { grid-template-columns: 1fr 1fr; }
  .recorrido { grid-template-columns: 1fr; }
  .recorrido a:nth-child(odd) { border-right: 0; }
}
