/* Facsímil del libro: cada página reproduce la caja, la tipografía y las
   ilustraciones del dossier original, escaladas con unidades de contenedor. */
@font-face {
  font-family: "Goudy Bookletter 1911";
  src: url("/assets/fonts/goudy-bookletter-1911.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.book {
  --page-ratio: 0.6719;
  --gap: clamp(10px, 1.4vw, 22px);
  margin-top: 34px;
}

.book-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  font: 700 11px/1 Arial, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-jump {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.book-jump select {
  max-width: min(58vw, 360px);
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 700 11px/1 Arial, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-modes {
  display: flex;
  border: 1px solid var(--line);
}

.book-modes button {
  padding: 10px 16px;
  border: 0;
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.book-modes button + button {
  border-left: 1px solid var(--line);
}

.book-modes button[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
}

.book-stage {
  display: flex;
  gap: var(--gap);
  align-items: center;
  justify-content: center;
}

.book-arrow {
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--blue);
  font: 400 21px/1 Georgia, "Times New Roman", serif;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.book-arrow:hover:not(:disabled) {
  background: var(--blue);
  color: #fff;
}

.book-arrow:disabled {
  color: var(--line);
  cursor: default;
}

.book-view {
  display: flex;
  justify-content: center;
  width: min(100%, 1560px, calc((100svh - 140px) * var(--page-ratio) * 2));
  filter: drop-shadow(0 14px 36px rgba(31, 77, 88, 0.14));
}

.book-view.is-single {
  width: min(100%, 780px, calc((100svh - 140px) * var(--page-ratio)));
}

.book-status {
  margin: 20px 0 0;
  color: var(--muted);
  font: 700 11px/1 Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

/* ---- página ---- */
.pg {
  container-type: inline-size;
  position: relative;
  flex: 1 1 0;
  aspect-ratio: var(--page-ratio);
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: "Goudy Bookletter 1911", Georgia, "Times New Roman", serif;
  hyphens: auto;
}

.pg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pg.is-left::after {
  background: linear-gradient(270deg, rgba(31, 77, 88, 0.09), transparent 5%);
}

.pg.is-right::after {
  background: linear-gradient(90deg, rgba(31, 77, 88, 0.09), transparent 5%);
}

.pg .pink {
  color: var(--pink);
}

.pg > * {
  position: absolute;
  margin: 0;
  top: calc(var(--t) * 1%);
  left: calc(var(--l) * 1%);
  font-size: calc(var(--fs) * 1cqw);
  line-height: var(--lh, 1.22);
}

/* La columna de texto fluye: el navegador rompe las líneas a su manera y los
   párrafos nunca se pisan, aunque la partición no coincida con la del PDF. */
.pg .col {
  width: calc(var(--w) * 1%);
  transform: translateY(calc((1 - var(--lh, 1.22)) * 0.5em));
}

.pg .col > * {
  margin: calc(var(--mt, 0) * 1em) 0 0;
  text-align: justify;
}

.pg .col > .free {
  text-align: left;
}

.pg .col > .mid {
  text-align: center;
  /* Los versos y las líneas centradas conservan el corte del original: si el
     navegador compone un pelo más ancho, sobresalen a partes iguales. */
  white-space: nowrap;
}

.pg .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.pg .head {
  transform: translate(-50%, calc((1 - var(--lh, 1.22)) * 0.5em));
  white-space: nowrap;
  text-align: center;
}

.pg .big {
  color: var(--pink);
  line-height: 1;
  white-space: nowrap;
  transform: translate(-50%, -0.06em);
}

.pg .big.ink {
  color: var(--ink);
}

.pg .folio {
  color: var(--pink);
  line-height: 1;
  transform: translateX(-50%);
}

.pg .art {
  display: block;
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
}

.pg .art img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.pg .mark {
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  overflow: visible;
  fill: none;
  stroke: var(--pink);
  stroke-width: 2.2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* ---- modo lectura: el mismo contenido reflujado ---- */
.book.is-flow .book-view,
.book.is-flow .book-view.is-single {
  display: block;
  width: min(100%, 720px);
  filter: none;
}

/* En páginas largas las flechas acompañan la lectura en vez de quedarse
   ancladas a la mitad de una columna muy alta. */
.book.is-flow .book-stage {
  align-items: flex-start;
}

.book.is-flow .book-arrow {
  position: sticky;
  top: 45vh;
}

.book.is-flow .pg {
  container-type: normal;
  aspect-ratio: auto;
  padding: clamp(28px, 5vw, 54px) clamp(20px, 5vw, 46px) clamp(36px, 6vw, 62px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: clamp(17px, 1.15vw + 13px, 21px);
  line-height: 1.5;
}

.book.is-flow .pg::after {
  display: none;
}

.book.is-flow .pg > * {
  position: static;
  width: auto;
  max-width: none;
  margin: 0 0 0.85em;
  font-size: inherit;
  line-height: inherit;
  transform: none;
  white-space: normal;
}

.book.is-flow .pg .col > * {
  margin: 0 0 0.85em;
  text-align: left;
}

.book.is-flow .pg .col > .mid,
.book.is-flow .pg .head {
  text-align: center;
}

.book.is-flow .pg .big {
  display: block;
  margin-bottom: 0.2em;
  font-size: clamp(38px, 11vw, 96px);
  line-height: 1;
  text-align: center;
}

.book.is-flow .pg .art {
  width: 100%;
  height: auto;
  margin: 0 0 1.1em;
}

.book.is-flow .pg .art img {
  height: auto;
  object-fit: contain;
}

.book.is-flow .pg .mark {
  display: none;
}

.book.is-flow .pg .folio {
  display: block;
  margin: 0;
  font-size: 15px;
  text-align: center;
}

/* En pantallas estrechas se lee una página por pantalla, a sangre completa, y
   las flechas pasan debajo: así la caja del original conserva toda su medida. */
@media (max-width: 880px) {
  .book-stage {
    flex-wrap: wrap;
    gap: 16px;
    margin-inline: calc(-1 * var(--pad, 20px));
  }

  .book-view,
  .book-view.is-single {
    flex: 1 0 100%;
    order: 1;
    width: 100%;
  }

  .book.is-flow .book-view,
  .book.is-flow .book-view.is-single {
    width: 100%;
    padding-inline: var(--pad, 20px);
  }

  .book-arrow {
    order: 2;
    width: 44px;
    height: 44px;
  }

  .book.is-flow .book-arrow {
    position: static;
  }
}

@media (max-width: 560px) {
  .book-bar {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .book-view {
    transition: opacity 0.22s ease;
  }

  .book-view.is-turning {
    opacity: 0;
  }
}
