/* ==========================================================================
   Luis Varillas — biblioteca
   1. Base y tokens
   2. Hero (tipografía editorial, grano, glow, estantería, cursor)
   3. Visor flipbook (chrome oscuro sobre las páginas del PDF)
   4. Storyboard (filmstrip)
   5. Responsive y movimiento reducido
   ========================================================================== */

/* ── 1. Base y tokens ─────────────────────────────────────────────────── */
:root {
  --ink: #08080a;
  --ink-2: #0d0d10;
  --ink-3: #141418;
  --paper: #f4f0e8;
  --paper-2: #cfc8ba;
  --dim: rgba(244, 240, 232, 0.56);
  --dim-2: rgba(244, 240, 232, 0.34);
  --line: rgba(244, 240, 232, 0.14);
  --line-strong: rgba(244, 240, 232, 0.26);
  --gold: #c8a96a;
  --gold-soft: rgba(200, 169, 106, 0.16);
  --shadow-lg: 0 40px 80px -30px rgba(0, 0, 0, 0.85);
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --shelf-h: clamp(158px, 27vh, 290px);
  /* Todas las tarjetas miden lo mismo: MISMAs proporción (2:3) y altura. */
  --card-w: calc(var(--shelf-h) * 2 / 3);
  --gutter: clamp(16px, 3.2vw, 52px);
  --px: 0;
  --py: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: rgba(244, 240, 232, 0.2) transparent;
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.storyboard-open,
body.reader-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 999;
  transform: translate(-50%, -120%);
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 0 0 10px 10px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.25s var(--ease);
}

.skip-link:focus-visible {
  transform: translate(-50%, 0);
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ── 2. HERO ──────────────────────────────────────────────────────────── */
.hero {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 2.4vh, 30px);
  padding: clamp(16px, 2.6vh, 30px) 0 clamp(10px, 1.8vh, 20px);
  overflow: hidden;
  transition: opacity 0.55s var(--ease), transform 0.75s var(--ease), filter 0.55s var(--ease);
}

.hero.is-behind {
  opacity: 0;
  transform: scale(0.985);
  filter: blur(6px);
  pointer-events: none;
}

.hero__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% -10%, #17171c 0%, #0b0b0e 45%, #060608 100%);
}

.hero__glow {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(38% 46% at 62% 18%, rgba(200, 169, 106, 0.16), transparent 70%),
    radial-gradient(45% 55% at 18% 72%, rgba(70, 96, 140, 0.2), transparent 72%);
  transform: translate3d(calc(var(--px) * -18px), calc(var(--py) * -14px), 0);
  transition: transform 0.9s var(--ease);
  will-change: transform;
}

.hero__grain {
  position: absolute;
  inset: 0;
  opacity: 0.085;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.hero__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 70% at 50% 42%, transparent 40%, rgba(3, 3, 4, 0.72) 100%),
    linear-gradient(to bottom, rgba(4, 4, 5, 0.55), transparent 22%, transparent 72%, rgba(4, 4, 5, 0.85));
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding-inline: var(--gutter);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.8s var(--ease) 0.1s, transform 0.8s var(--ease) 0.1s;
}

.hero.is-ready .topbar {
  opacity: 1;
  transform: none;
}

.topbar__mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.topbar__monogram {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--paper);
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease);
}

.topbar__mark:hover .topbar__monogram {
  border-color: var(--gold);
  color: var(--gold);
}

.topbar__label {
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--dim);
}

/* nombre completo + grado y perfil, bajo el título del hero */
.hero__fullname {
  margin-top: clamp(8px, 1.2vh, 14px);
  padding-top: clamp(8px, 1.1vh, 12px);
  border-top: 1px solid var(--line);
  max-width: 32ch;
  font-family: var(--serif);
  font-size: clamp(0.9rem, 1.35vw, 1.2rem);
  font-style: italic;
  line-height: 1.25;
  color: var(--paper-2);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s var(--ease) 0.34s, transform 0.9s var(--ease) 0.34s;
}

.hero.is-ready .hero__fullname {
  opacity: 1;
  transform: none;
}

.hero__profile {
  margin-top: 8px;
  max-width: 60ch;
  font-size: clamp(0.52rem, 0.72vw, 0.64rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.55;
  color: var(--gold);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.9s var(--ease) 0.42s, transform 0.9s var(--ease) 0.42s;
}

.hero.is-ready .hero__profile {
  opacity: 1;
  transform: none;
}

/* contenido editorial: lead (izquierda) + semblanza (derecha) */
.hero__content {
  min-width: 0;
  min-height: 0;
  align-self: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.86fr);
  column-gap: clamp(28px, 5.2vw, 108px);
  align-items: start;
  overflow: hidden;
  padding-inline: var(--gutter);
  max-width: min(100%, 1320px);
  width: 100%;
}

.hero__lead {
  min-width: 0;
}

.hero__kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(10px, 1.8vh, 20px);
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s var(--ease) 0.18s, transform 0.9s var(--ease) 0.18s;
}

.hero__rule {
  display: inline-block;
  width: clamp(28px, 6vw, 72px);
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold));
}

.hero.is-ready .hero__kicker {
  opacity: 1;
  transform: none;
}

.hero__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.4rem, min(8.6vw, 13vh), 7.6rem);
  line-height: 0.845;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 1;
}

.hero__line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.03em;
}

.hero__line > span {
  display: block;
  transform: translateY(112%) rotate(2deg);
  transition: transform 1.15s var(--ease);
  will-change: transform;
}

.hero.is-ready .hero__line:nth-child(1) > span {
  transform: none;
  transition-delay: 0.14s;
}

.hero.is-ready .hero__line:nth-child(2) > span {
  transform: none;
  transition-delay: 0.26s;
}

.hero__tagline {
  margin-top: clamp(10px, 1.6vh, 18px);
  max-width: 30ch;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 1.3vw, 1.15rem);
  line-height: 1.35;
  color: var(--paper-2);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1s var(--ease) 0.4s, transform 1s var(--ease) 0.4s;
}

.hero.is-ready .hero__tagline {
  opacity: 1;
  transform: none;
}

.hero.is-ready .hero__bio {
  opacity: 1;
  transform: none;
}

/* semblanza: columna editorial en la mitad derecha del hero */
.hero__bio-block {
  min-width: 0;
  max-width: 54ch;
  justify-self: start;
  padding-left: clamp(0px, 2.4vw, 30px);
  border-left: 1px solid var(--line);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1s var(--ease) 0.5s, transform 1s var(--ease) 0.5s;
}

.hero.is-ready .hero__bio-block {
  opacity: 1;
  transform: none;
}

.hero__bio-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(10px, 1.5vh, 16px);
  font-size: 0.58rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero__bio-label .hero__rule {
  width: clamp(18px, 2.6vw, 40px);
}

.hero__bio-p {
  font-size: clamp(0.8rem, 0.94vw, 0.9rem);
  line-height: 1.72;
  color: var(--dim);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.85s var(--ease) calc(0.52s + var(--p, 0) * 0.11s),
    transform 0.85s var(--ease) calc(0.52s + var(--p, 0) * 0.11s);
}

.hero.is-ready .hero__bio-p {
  opacity: 1;
  transform: none;
}

.hero__bio-p + .hero__bio-p {
  margin-top: 0.9em;
}

/* capitular dorada en el primer párrafo */
.hero__bio-p:first-child::first-letter {
  float: left;
  margin: 0.06em 0.14em 0 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 3.1em;
  line-height: 0.78;
  color: var(--paper);
}

.hero__bio-p:first-child {
  padding-top: 2px;
}

/* estantería */
.shelf {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 14px);
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1s var(--ease) 0.62s, transform 1s var(--ease) 0.62s;
}

.hero.is-ready .shelf {
  opacity: 1;
  transform: none;
}

.shelf__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding-inline: var(--gutter);
}

.shelf__label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.64rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}

.shelf__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.shelf__viewport {
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  padding-block: 6px 2px;
  touch-action: pan-x pan-y;
  mask-image: linear-gradient(to right, transparent 0, #000 3.5%, #000 96.5%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 3.5%, #000 96.5%, transparent 100%);
}

.shelf__viewport::-webkit-scrollbar {
  display: none;
}

.shelf__viewport.is-dragging {
  cursor: grabbing;
}

.shelf__rail {
  display: flex;
  align-items: flex-start;
  gap: clamp(12px, 1.5vw, 26px);
  width: max-content;
  padding-inline: var(--gutter);
  padding-bottom: 6px;
  list-style: none;
}

.shelf__item {
  position: relative;
  flex: 0 0 auto;
  /* Todas las tarjetas (portadas y storyboard) ocupan exactamente lo mismo. */
  width: var(--card-w);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--i) * 65ms + 0.72s);
}

.hero.is-ready .shelf__item {
  opacity: 1;
  transform: none;
}

.shelf__item.is-hidden {
  opacity: 0 !important;
  pointer-events: none;
}

.cover {
  position: relative;
  display: block;
  width: 100%;
  height: var(--shelf-h);
  aspect-ratio: 2 / 3;
  padding: 0;
  border-radius: 3px;
  transform-style: preserve-3d;
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0)
    scale(1);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
  box-shadow: 0 18px 34px -18px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.5);
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.cover__frame {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  overflow: hidden;
  background: #101014;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  pointer-events: none;
  user-select: none;
  transform: scale(1.001);
}

/* Tarjeta del storyboard: mismo tamaño, se distingue por el marco dorado. */
.shelf__item--storyboard .cover {
  box-shadow: 0 18px 34px -18px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(200, 169, 106, 0.35);
}

.cover__sheen {
  position: absolute;
  inset: -30%;
  pointer-events: none;
  background: radial-gradient(
    40% 40% at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.34),
    rgba(255, 255, 255, 0) 70%
  );
  opacity: 0;
  transition: opacity 0.45s var(--ease);
  mix-blend-mode: soft-light;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(244, 240, 232, 0.09);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .cover:hover {
    transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(24px)
      scale(1.035);
    box-shadow: 0 40px 70px -28px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(200, 169, 106, 0.25),
      0 0 60px -12px rgba(200, 169, 106, 0.28);
    z-index: 3;
  }

  .cover:hover .cover__sheen {
    opacity: 1;
  }

  .shelf__viewport:has(.cover:hover) .cover:not(:hover) {
    opacity: 0.62;
  }

  .shelf__viewport {
    cursor: none;
  }
}

.cover:focus-visible {
  transform: perspective(1000px) translateZ(18px) scale(1.02);
  box-shadow: 0 0 0 2px var(--gold), 0 30px 50px -26px rgba(0, 0, 0, 0.9);
}

.cover:active {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(0.995);
}

.shelf__item.is-soon .cover {
  cursor: not-allowed;
}

.shelf__item.is-soon .cover img {
  filter: saturate(0.55) brightness(0.72);
  transition: filter 0.5s var(--ease);
}

.shelf__item.is-soon .cover:hover img {
  filter: saturate(0.75) brightness(0.85);
}

.badge-soon {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  padding: 5px 10px;
  border: 1px solid rgba(200, 169, 106, 0.55);
  border-radius: 999px;
  background: rgba(8, 8, 10, 0.78);
  color: var(--gold);
  font-size: 0.56rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.shelf__caption {
  margin-top: 10px;
  width: 100%;
  /* Pie de dos líneas exactas: todas las tarjetas alinean igual. */
  height: calc(2 * 1.45em + 2px);
  font-size: 0.6rem;
  line-height: 1.45;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: normal;
}

.shelf__item.is-soon .shelf__caption {
  color: var(--gold);
  opacity: 0.8;
}

.shelf__hint {
  padding-inline: var(--gutter);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim-2);
}

/* cursor propio */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  border: 1px solid rgba(200, 169, 106, 0.6);
  background: rgba(200, 169, 106, 0.12);
  backdrop-filter: blur(3px);
  color: var(--paper);
  font-size: 0.55rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  /* Solo funde: sin escala ni reanimación al cambiar de tarjeta. */
  transition: opacity 0.16s linear, background 0.2s linear;
  will-change: transform;
}

.cursor.is-visible {
  opacity: 1;
}

.cursor.is-soon {
  border-color: rgba(244, 240, 232, 0.28);
  background: rgba(244, 240, 232, 0.06);
  color: var(--dim);
}

/* vuelo de portada */
.flight-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  perspective: 1400px;
}

.flight-layer.is-active {
  pointer-events: none;
}

.flight-cover {
  position: fixed;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 50px 90px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(200, 169, 106, 0.2);
  will-change: transform, filter;
  transform-origin: center center;
}

.boot-error {
  position: fixed;
  inset: auto 0 0;
  z-index: 200;
  padding: 18px;
  text-align: center;
  background: #1a1013;
  color: var(--paper);
  border-top: 1px solid var(--line-strong);
}

.boot-error__hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--dim);
}

.boot-error code {
  font-size: 0.8rem;
  color: var(--gold);
}

/* ── 3. VISOR FLIPBOOK ────────────────────────────────────────────────── */
.reader-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(120% 90% at 50% -10%, #141419 0%, #0a0a0d 50%, #050507 100%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.reader-root[hidden] {
  display: none;
}

.reader-root.is-open {
  opacity: 1;
}

.reader-shell {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.reader-top {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  padding: clamp(10px, 1.6vh, 18px) clamp(12px, 2vw, 26px) clamp(6px, 1vh, 12px);
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-2);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease),
    transform 0.3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.reader-back:hover {
  border-color: var(--gold);
  color: var(--paper);
  background: var(--gold-soft);
  transform: translateX(-2px);
}

.reader-back-arrow {
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.3s var(--ease);
}

.reader-back:hover .reader-back-arrow {
  transform: translateX(-3px);
}

.reader-heading {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.4vw, 18px);
  min-width: 0;
  flex: 1;
}

.reader-heading__text {
  min-width: 0;
}

.reader-title {
  font-family: var(--serif);
  font-size: clamp(0.85rem, 1.35vw, 1.15rem);
  letter-spacing: 0.01em;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-subtitle {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: default;
  touch-action: none;
}

.reader-viewport.is-scroll-page {
  align-items: flex-start;
  justify-content: safe center;
  overflow: auto;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  padding: 6px 0 16px;
  -webkit-overflow-scrolling: touch;
}

.reader-viewport.is-dragging {
  cursor: grabbing;
}

.zoom-layer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  will-change: transform;
}

.zoom-layer.no-transition {
  transition: none;
}

.book-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, 0.62));
  opacity: 0;
  transition: opacity 0.55s var(--ease);
}

.reader-root.is-ready .book-shell {
  opacity: 1;
}

.book {
  transition: transform 0.45s var(--ease);
}

.book.no-transition {
  transition: none !important;
}

.book,
.book.stf__parent {
  margin: 0 auto !important;
}

.page {
  background: #fff;
  overflow: hidden;
}

.page img,
.page canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  pointer-events: none;
  user-select: none;
}

.page-loading {
  background: #ecebe7;
}

.page-placeholder {
  width: 100%;
  height: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.side-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: rgba(244, 240, 232, 0.36);
  border-radius: 50%;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.side-nav:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-50%) scale(1.08);
}

.side-nav--prev {
  left: 4px;
}

.side-nav--next {
  right: 4px;
}

.float-panel {
  position: absolute;
  top: clamp(10px, 1.6vh, 18px);
  right: clamp(10px, 2vw, 26px);
  z-index: 30;
  display: flex;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(14, 14, 18, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.9);
}

.float-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: rgba(244, 240, 232, 0.7);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.float-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
}

.float-btn.is-active {
  background: var(--gold-soft);
  color: var(--gold);
}

.float-btn.is-saved {
  color: var(--gold);
}

.page-badge {
  position: absolute;
  left: clamp(10px, 2vw, 26px);
  bottom: clamp(18px, 2.4vh, 28px);
  z-index: 30;
  min-width: 118px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 14, 18, 0.72);
  backdrop-filter: blur(14px);
  text-align: left;
  line-height: 1.35;
  font-size: 0.76rem;
  color: var(--paper-2);
  box-shadow: 0 16px 40px -22px rgba(0, 0, 0, 0.9);
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.page-badge:hover {
  border-color: var(--gold);
}

.page-badge strong {
  display: block;
  font-weight: 600;
  color: var(--paper);
}

.page-badge span {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--dim);
}

.reader-progress {
  position: absolute;
  inset: auto 0 0;
  z-index: 25;
  height: 3px;
  background: rgba(244, 240, 232, 0.08);
}

.page-track {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.page-track-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, rgba(200, 169, 106, 0.55), var(--gold));
  transition: width 0.35s var(--ease);
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(90vw, 380px);
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(18, 18, 22, 0.94);
  backdrop-filter: blur(10px);
  color: var(--paper);
  font-size: 0.78rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

/* modales */
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.reader-modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 6, 0.66);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(100%, 360px);
  padding: 22px 20px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, #15151a, #0d0d11);
  box-shadow: var(--shadow-lg);
}

.modal-card h2 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--paper);
}

.modal-hint {
  margin: 6px 0 16px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--dim);
}

.modal-hint strong {
  color: var(--gold);
}

.modal-card input {
  width: 100%;
  margin-bottom: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
  font: inherit;
  font-size: 1.05rem;
}

.modal-card input:focus {
  border-color: var(--gold);
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.modal-btn.ghost {
  border: 1px solid var(--line);
  color: var(--dim);
}

.modal-btn.ghost:hover {
  color: var(--paper);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.modal-btn.primary {
  background: var(--gold);
  color: #16120a;
  font-weight: 600;
}

.modal-btn.primary:hover {
  background: #d8bc80;
}

/* loader del visor */
.reader-loader {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 20%, #121217, #060608 75%);
  transition: opacity 0.5s var(--ease);
}

.reader-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.reader-loader.hidden {
  display: none;
}

.loader-box {
  width: min(280px, 84vw);
  text-align: center;
}

.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border: 2px solid rgba(244, 240, 232, 0.14);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.reader-loader p {
  margin-bottom: 12px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.progress-bar {
  height: 2px;
  border-radius: 2px;
  background: rgba(244, 240, 232, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.3s var(--ease);
}

/* ── 4. STORYBOARD ────────────────────────────────────────────────────── */
.sb {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 18px);
  padding: clamp(12px, 2vh, 22px) clamp(12px, 2.4vw, 32px) clamp(14px, 2.4vh, 26px);
  background: radial-gradient(120% 80% at 50% 0%, #101014 0%, #07070a 60%, #040405 100%);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
}

.sb[hidden] {
  display: none;
}

.sb.is-open {
  opacity: 1;
}

.sb__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.sb__bar {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sb__title {
  font-family: var(--serif);
  font-size: clamp(0.95rem, 1.6vw, 1.3rem);
  color: var(--paper);
}

.sb__counter {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.sb__close {
  margin-left: auto;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.sb__close:hover {
  color: var(--paper);
  border-color: var(--gold);
  background: var(--gold-soft);
}

.sb__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.4vw, 20px);
  touch-action: pan-y;
}

.sb__nav {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.05rem;
  color: var(--dim);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.sb__nav:hover:not(:disabled) {
  color: var(--paper);
  border-color: var(--gold);
  background: var(--gold-soft);
}

.sb__nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.sb__film {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 1.6vh, 18px) clamp(8px, 1.4vw, 16px);
  border-radius: 8px;
  background: linear-gradient(180deg, #15151a, #0b0b0e);
  box-shadow: inset 0 0 0 1px rgba(244, 240, 232, 0.08), 0 40px 80px -40px rgba(0, 0, 0, 0.95);
}

.sb__sprocket {
  flex: 0 0 12px;
  border-radius: 2px;
  background-image: linear-gradient(90deg, rgba(244, 240, 232, 0.16) 50%, transparent 50%);
  background-size: 26px 100%;
  opacity: 0.55;
}

.sb__frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
}

.sb__frame img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  transition: opacity 0.22s var(--ease), transform 0.5s var(--ease);
}

.sb__frame img.is-swapping {
  opacity: 0.25;
  transform: scale(0.996);
}

.sb__caption {
  position: absolute;
  left: 14px;
  bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(4, 4, 6, 0.7);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.sb__thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
}

.sb__thumbs::-webkit-scrollbar {
  display: none;
}

.sb__thumb {
  position: relative;
  flex: 0 0 auto;
  width: clamp(64px, 7vw, 104px);
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  opacity: 0.42;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.sb__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sb__thumb-num {
  position: absolute;
  left: 5px;
  bottom: 4px;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: rgba(244, 240, 232, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.sb__thumb:hover {
  opacity: 0.8;
}

.sb__thumb.is-active {
  opacity: 1;
  box-shadow: 0 0 0 1.5px var(--gold), 0 10px 22px -12px rgba(0, 0, 0, 0.9);
  transform: translateY(-2px);
}

/* ── 4b. SINOPSIS ─────────────────────────────────────────────────────── */
.reader-synopsis {
  flex: 0 0 auto;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-2);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.reader-synopsis:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}

.synopsis {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 40px);
  opacity: 0;
  transition: opacity 0.26s var(--ease);
}

.synopsis.is-open {
  opacity: 1;
}

.synopsis__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 6, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.synopsis__card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(120px, 190px) minmax(0, 1fr);
  gap: clamp(16px, 2.6vw, 34px);
  align-items: start;
  width: min(100%, 760px);
  max-height: min(88vh, 640px);
  overflow: auto;
  padding: clamp(18px, 2.6vw, 32px);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #15151a, #0b0b0e);
  box-shadow: 0 50px 90px -40px rgba(0, 0, 0, 0.95);
  transform: translateY(12px) scale(0.99);
  transition: transform 0.32s var(--ease);
}

.synopsis.is-open .synopsis__card {
  transform: none;
}

.synopsis__cover {
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 22px 40px -22px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(200, 169, 106, 0.18);
}

.synopsis__body {
  min-width: 0;
}

.synopsis__meta {
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.synopsis__title {
  margin-top: 8px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--paper);
}

.synopsis__credits {
  margin-top: 8px;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim-2);
}

.synopsis__text {
  margin-top: clamp(12px, 1.8vh, 18px);
  font-size: clamp(0.86rem, 1vw, 0.95rem);
  line-height: 1.72;
  color: var(--paper-2);
}

.synopsis__soon {
  display: inline-block;
  margin-top: 16px;
  padding: 5px 12px;
  border: 1px solid rgba(200, 169, 106, 0.55);
  border-radius: 999px;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.synopsis__card.is-soon .synopsis__cover {
  filter: saturate(0.7) brightness(0.85);
}

.synopsis__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--dim);
  background: rgba(10, 10, 12, 0.7);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.synopsis__close:hover {
  color: var(--paper);
  border-color: var(--gold);
}

/* ── 5. RESPONSIVE ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --shelf-h: clamp(168px, 42vw, 240px);
  }

  .hero {
    /* Flujo natural (flex) para que el contenido no se comprima: si no entra,
       el hero scrollea en vez de superponerse a la estantería. */
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.7vh, 18px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .hero__content {
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    row-gap: clamp(12px, 2vh, 18px);
  }

  .shelf {
    flex: 0 0 auto;
  }

  .hero__bio-block {
    max-width: 62ch;
    padding-left: 0;
    border-left: none;
  }

  .hero__title {
    font-size: clamp(2.6rem, 15vw, 5.4rem);
    line-height: 0.88;
  }

  .hero__bio-p {
    font-size: 0.8rem;
    line-height: 1.65;
  }

  .topbar__label,
  .shelf__hint {
    display: none;
  }

  .shelf__viewport {
    mask-image: none;
    -webkit-mask-image: none;
    scroll-snap-type: x proximity;
  }

  .shelf__rail {
    gap: 14px;
  }

  .shelf__item {
    scroll-snap-align: center;
  }

  .cover:hover {
    transform: none;
  }
}

@media (max-width: 560px) {
  .hero__kicker {
    font-size: 0.58rem;
    letter-spacing: 0.24em;
  }

  /* En teléfono el hero prioriza nombre + perfil + semblanza + estantería:
     la tagline decorativa se retira para que la estantería entre en pantalla. */
  .hero__tagline {
    display: none;
  }

  .hero__bio-p {
    font-size: 0.72rem;
    line-height: 1.52;
  }

  .hero__bio-p {
    font-size: 0.74rem;
    line-height: 1.55;
  }

  .hero__bio-label {
    font-size: 0.54rem;
    margin-bottom: 10px;
  }

  .hero__fullname {
    font-size: 0.92rem;
    max-width: 24ch;
  }

  .hero__profile {
    font-size: 0.52rem;
    letter-spacing: 0.12em;
    line-height: 1.6;
    max-width: 40ch;
  }

  .reader-synopsis {
    padding: 6px 11px;
    font-size: 0.56rem;
  }

  .synopsis__card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px;
    max-height: 88vh;
  }

  .synopsis__cover {
    width: 104px;
    justify-self: start;
  }

  .synopsis__title {
    font-size: 1.15rem;
    padding-right: 24px;
  }

  .synopsis__text {
    font-size: 0.84rem;
    line-height: 1.68;
  }

  .shelf__caption {
    font-size: 0.54rem;
    letter-spacing: 0.12em;
  }

  .reader-top {
    flex-wrap: wrap;
    gap: 8px;
  }

  .reader-title {
    font-size: 0.82rem;
  }

  .reader-back {
    padding: 7px 12px;
    font-size: 0.6rem;
  }

  .float-panel {
    top: auto;
    bottom: calc(clamp(10px, 2vw, 20px) + env(safe-area-inset-bottom, 0px));
    right: 50%;
    transform: translateX(50%);
    gap: 0;
  }

  .float-btn {
    width: 40px;
    height: 40px;
  }

  .page-badge {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    min-width: 96px;
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .page-badge span {
    display: none;
  }

  .sb__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(8, 8, 10, 0.62);
    backdrop-filter: blur(6px);
  }

  .sb__nav--prev {
    left: 2px;
  }

  .sb__nav--next {
    right: 2px;
  }

  .sb__stage {
    gap: 0;
  }

  /* En vertical la cinta se ajusta a la imagen: menos negro, plano más grande. */
  .sb__film {
    height: auto;
    max-height: 100%;
  }

  .sb__frame {
    flex: 0 0 auto;
  }

  .sb__frame img {
    max-height: 58vh;
  }

  .sb__sprocket {
    flex-basis: 10px;
    background-size: 20px 100%;
  }

  .sb__thumbs {
    gap: 6px;
  }
}

@media (max-height: 950px) and (min-width: 901px) {
  .hero__title {
    font-size: clamp(2.2rem, min(8.6vw, 12vh), 7rem);
  }

  .hero__bio-p {
    font-size: 0.8rem;
    line-height: 1.62;
  }
}

@media (max-height: 820px) and (min-width: 901px) {
  .hero__title {
    font-size: clamp(2rem, min(8.4vw, 10.4vh), 6rem);
  }

  .hero__tagline {
    margin-top: 10px;
    font-size: 1rem;
  }
}

@media (max-height: 780px) {
  :root {
    --shelf-h: clamp(150px, 25vh, 230px);
  }

  .hero__bio-p {
    font-size: 0.76rem;
    line-height: 1.55;
  }
}

@media (max-height: 620px) and (min-width: 901px) {
  :root {
    --shelf-h: clamp(140px, 30vh, 200px);
  }

  .hero__bio-block {
    display: none;
  }
}

@media (max-height: 560px) {
  .hero__bio-block {
    display: none;
  }

  .hero__tagline {
    display: none;
  }
}

/* movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .hero__line > span {
    transform: none !important;
  }

  .cover {
    transform: none !important;
  }

  /* El cursor propio se mantiene (si no, con `cursor: none` en la estantería el
     puntero desaparecería): solo deja de interpolar, se pega al puntero. */
  .cursor {
    transition: none !important;
  }

  .hero__glow {
    transform: none !important;
  }
}

/* cursor táctil: nunca mostrar el cursor propio */
@media (pointer: coarse) {
  .cursor {
    display: none;
  }
}

/* El contenedor del visor recibe foco programático sin anillo visible. */
.reader-root:focus,
.reader-root:focus-visible {
  outline: none;
}
