/**
 * Cuento digital · "La armadura y la mariposa"
 * assets/css/cuento.css — solo para /cuentos/.
 *
 * Reglas de la casa: se animan transform, opacity y clip-path. Entradas con
 * cubic-bezier(.16,1,.3,1). Con movimiento reducido el libro cambia de página
 * sin girar y se apaga lo autónomo (polvo, aleteo, mariposas que vuelan).
 */

:root {
  --noche: 10 31 56;
  --hondo: 5 16 31;
  --crema: 247 243 234;
  --papel: #fefcf5;            /* el mismo fondo de las ilustraciones */
  --tinta: #23293a;
  --tinta-suave: #5b6070;
  --oro: #c8a25a;
  --oro-claro: #ecd49a;
  --oro-hondo: #8a6630;
  --oro-metal: linear-gradient(135deg, #f8e7b8 0%, #d6ad5c 35%, #a8792c 62%, #f2d58a 85%, #c99838 100%);
  --e-salida: cubic-bezier(.16, 1, .3, 1);
  --e-pagina: cubic-bezier(.645, .045, .355, 1);
  --t-voltear: 1100ms;
  --pw: 420px;                 /* ancho de una página (lo fija el JS) */
  --ph: 580px;                 /* alto de una página */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.cuento {
  background: rgb(var(--hondo)); color: rgb(var(--crema));
  font-family: Lato, system-ui, sans-serif; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--oro-claro); outline-offset: 3px; border-radius: 8px; }

.saltar { position: fixed; left: 1rem; top: -4rem; z-index: 200; padding: .6rem 1rem; border-radius: 999px; background: var(--oro); color: rgb(var(--noche)); font-weight: 700; }
.saltar:focus { top: 1rem; }

/* ---------- La escena: mesa azul noche ---------- */
.escena {
  /* clip y no solo hidden: con hidden el navegador sí la desplaza al enfocar un botón
     de la portada (medido: 110 px en una pantalla de 682 px de alto) y el libro salía cortado */
  position: fixed; inset: 0; overflow: hidden; overflow: clip;
  background:
    radial-gradient(60% 55% at 50% 48%, rgb(28 58 98 / .85) 0%, rgb(28 58 98 / 0) 70%),
    radial-gradient(120% 90% at 50% 120%, rgb(var(--hondo)) 0%, rgb(var(--noche)) 70%);
}
.escena::after {   /* grano */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
  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='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
.polvo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.aura {   /* luz cálida que sigue al mouse */
  position: absolute; left: 0; top: 0; width: 900px; height: 900px; margin: -450px 0 0 -450px; pointer-events: none;
  background: radial-gradient(circle, rgb(236 196 110 / .13) 0%, rgb(236 196 110 / 0) 60%);
  transform: translate3d(50vw, 50vh, 0); transition: transform 1.4s var(--e-salida);
}

/* ---------- Barra superior ---------- */
.barra {
  position: absolute; z-index: 30; left: 0; right: 0; top: 0; height: 68px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(14px, 3vw, 32px);
}
.barra__marca { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.barra__marca img { width: 34px; height: auto; }
.barra__marca span { font-family: Marcellus, Georgia, serif; letter-spacing: .22em; text-transform: uppercase; font-size: .8rem; color: rgb(var(--crema)); }
.barra__titulo { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: 1.15rem; color: var(--oro-claro); opacity: 0; transition: opacity .6s; }
.abierto .barra__titulo { opacity: 1; }
.barra__acciones { display: flex; gap: .4rem; }
.boton-redondo {
  width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center;
  background: rgb(255 255 255 / .06); border: 1px solid rgb(255 255 255 / .12); color: var(--oro-claro);
  transition: background-color .25s, transform .25s var(--e-salida);
}
.boton-redondo:hover { background: rgb(255 255 255 / .12); transform: translateY(-1px); }
.boton-redondo svg { width: 19px; height: 19px; }
@media (max-width: 640px) { .barra__titulo { display: none; } .barra__marca span { display: none; } }

/* ---------- Portal (la entrada) ---------- */
.portal {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; text-align: center; padding: 90px 20px 40px;
  overflow-y: auto; scrollbar-width: none;   /* si aun así no cabe, se desplaza la portada, no la escena */
  transition: opacity 1s var(--e-salida), transform 1.2s var(--e-salida);
}
/* Pantallas bajitas (portátiles): todo se encoge con el alto para que quepa sin desplazarse */
@media (max-height: 820px) {
  .portal { padding: 70px 20px 12px; }
  .portal__titulo { font-size: clamp(2.6rem, min(2rem + 6vw, 12.5vh), 7.2rem); }
  .portal__ante { margin-bottom: 2vh; }
  .portal__mariposa { margin: 2vh auto .2rem; }
  .portal__acciones { margin-top: 2vh; }
  .portal__ayuda { margin-top: 1.6vh; }
}
.abierto .portal { opacity: 0; transform: scale(1.06); pointer-events: none; }
.portal__ante { font-family: Marcellus, Georgia, serif; text-transform: uppercase; letter-spacing: .4em; font-size: .78rem; color: var(--oro-claro); margin: 0 0 1.4rem; }
.portal__titulo { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; line-height: .95; font-size: clamp(3rem, 2rem + 6vw, 7.2rem); color: rgb(var(--crema)); }
.portal__titulo span { display: block; }
.portal__titulo .y { font-style: italic; font-weight: 500; font-size: .42em; margin: .25em 0; color: var(--oro-claro); }
.portal__titulo .oro {
  background: var(--oro-metal); -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* Entrada del título: cada línea se descubre de abajo hacia arriba */
.js .portal__titulo span, .js .portal__ante, .js .portal__acciones, .js .portal__ayuda, .js .portal__mariposa {
  clip-path: inset(0 0 100% 0); transform: translateY(18px);
  transition: clip-path 1.3s var(--e-salida), transform 1.3s var(--e-salida);
}
.listo .portal__titulo span, .listo .portal__ante, .listo .portal__acciones, .listo .portal__ayuda, .listo .portal__mariposa { clip-path: inset(0 0 -20% 0); transform: none; }
.listo .portal__titulo span:nth-child(2) { transition-delay: .18s; }
.listo .portal__titulo span:nth-child(3) { transition-delay: .32s; }
.listo .portal__mariposa { transition-delay: .5s; }
.listo .portal__acciones { transition-delay: .7s; }
.listo .portal__ayuda { transition-delay: .85s; }
.portal__mariposa { display: block; margin: 1.6rem auto .4rem; width: max-content; }
.portal__acciones { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: 1.4rem; }
.btn {
  display: inline-flex; align-items: center; gap: .8rem; border-radius: 999px; padding: .55rem .55rem .55rem 1.5rem;
  min-height: 54px; font-weight: 700; font-size: 1rem; letter-spacing: .01em; text-decoration: none;
  transition: transform .25s var(--e-salida), box-shadow .25s;
}
.btn:active { transform: scale(.97); }
.btn__icono { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; transition: transform .3s var(--e-salida); }
.btn:hover .btn__icono { transform: translateX(3px); }
.btn__icono svg { width: 19px; height: 19px; }
.btn-oro { background: var(--oro-metal); color: rgb(var(--noche)); box-shadow: 0 14px 34px -14px rgb(214 168 80 / .8); }
.btn-oro .btn__icono { background: rgb(var(--noche)); color: var(--oro-claro); }
.btn-linea { color: rgb(var(--crema)); border: 1px solid rgb(255 255 255 / .22); }
.btn-linea .btn__icono { background: rgb(255 255 255 / .08); color: var(--oro-claro); }
.portal__ayuda { margin: 1.4rem 0 0; font-size: .85rem; color: rgb(var(--crema) / .55); }

/* ---------- La mesa y el libro ---------- */
.mesa {
  position: absolute; inset: 68px 0 86px; display: grid; place-items: center; perspective: 2600px;
  opacity: 0; transform: translateY(40px) scale(.94); transition: opacity 1s var(--e-salida) .25s, transform 1.4s var(--e-salida) .2s;
}
.abierto .mesa { opacity: 1; transform: none; }
.libro {
  position: relative; width: calc(var(--pw) * 2); height: var(--ph);
  transition: transform 1.1s var(--e-pagina);
  user-select: none; -webkit-user-select: none;
}
.libro[data-modo="simple"] { width: var(--pw); }
/* Cerrado, el libro muestra una sola tapa: se corre media página para quedar centrado */
.libro[data-lado="tapa"] { transform: translateX(calc(var(--pw) * -.5)); }
.libro[data-lado="contra"] { transform: translateX(calc(var(--pw) * .5)); }
.libro[data-modo="simple"][data-lado] { transform: none; }
/* Sombra del libro sobre la mesa */
.libro::before {
  content: ''; position: absolute; left: 4%; right: 4%; bottom: -26px; height: 40px; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / .55), transparent); filter: blur(6px);
}
.libro__bloque { width: 100%; height: 100%; }

/* Hojas: el doblez, el reverso que se asoma y sus sombras los dibuja StPageFlip
   (assets/js/vendor/page-flip-2.0.7.js). Aquí solo el papel y el lomo. */
.hoja-pf { background: var(--papel); overflow: hidden; cursor: pointer; }
.hoja-pf.--hard { background: #0a1f38; }
.hoja-pf::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hoja-pf.--right:not(.--hard)::after { background: linear-gradient(90deg, rgb(60 44 20 / .17) 0%, rgb(60 44 20 / .05) 3.5%, transparent 9%, transparent 97%, rgb(60 44 20 / .06) 100%); }
.hoja-pf.--left:not(.--hard)::after { background: linear-gradient(270deg, rgb(60 44 20 / .17) 0%, rgb(60 44 20 / .05) 3.5%, transparent 9%, transparent 97%, rgb(60 44 20 / .06) 100%); }
/* Lo que se toca dentro de una página es el botón o el enlace, no su icono:
   así la librería deja pasar el clic en vez de tomarlo como un giro */
.hoja-pf a *, .hoja-pf button * { pointer-events: none; }

/* ---------- Páginas ---------- */
.pagina { position: absolute; inset: 0; display: flex; flex-direction: column; color: var(--tinta); }
.pagina--texto { padding: calc(var(--pw) * .1) calc(var(--pw) * .1) calc(var(--pw) * .075); }
.pagina__cabeza, .pagina__pie {
  flex: none; display: flex; justify-content: space-between; align-items: center;
  font-family: Marcellus, Georgia, serif; text-transform: uppercase; letter-spacing: .22em;
  font-size: calc(var(--pw) * .02 + 3px); color: var(--oro-hondo);
}
.pagina__pie { justify-content: center; gap: .6em; margin-top: auto; padding-top: .6em; color: var(--tinta-suave); }
.pagina__pie i { font-style: normal; color: var(--oro); }
.pagina__cuerpo {
  flex: 1; overflow: hidden; margin-top: calc(var(--pw) * .045);
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500;
  font-size: var(--letra, 19px); line-height: 1.52; color: var(--tinta); hyphens: auto; -webkit-hyphens: auto;
}
.pagina__cuerpo p { margin: 0 0 .55em; text-align: justify; text-indent: 1.3em; }
.pagina__cuerpo p.primero, .pagina__cuerpo p.continua { text-indent: 0; }
.pagina__cuerpo p.primero::first-letter {
  float: left; font-size: 3.6em; line-height: .82; padding: .06em .1em 0 0; font-weight: 600;
  color: var(--oro-hondo);
}
.capitulo-cabeza { text-align: center; margin-bottom: 1.1em; }
.capitulo-cabeza__num { display: block; font-family: Marcellus, Georgia, serif; letter-spacing: .4em; font-size: .62em; color: var(--oro-hondo); }
.capitulo-cabeza__titulo { display: block; font-size: 1.62em; font-weight: 600; line-height: 1.1; margin: .25em 0 .3em; color: rgb(var(--noche)); }
.capitulo-cabeza__orn { display: block; color: var(--oro); letter-spacing: .5em; font-size: .7em; }

/* Ilustración: se descubre como si se dibujara, y la recorre un brillo de oro */
.pagina--ilus { padding: calc(var(--pw) * .07); justify-content: center; align-items: center; }
.ilus { position: relative; width: 100%; flex: 1; display: grid; place-items: center; overflow: hidden; }
.ilus img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  mix-blend-mode: multiply;   /* el fondo crema de la imagen desaparece en el papel: solo queda el trazo */
  -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 62%, transparent 100%);
  mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 62%, transparent 100%);
}
.js .ilus img { clip-path: inset(0 100% 0 0); opacity: .35; transform: scale(1.03);
  transition: clip-path 2.4s var(--e-salida), opacity 1.6s ease, transform 3s var(--e-salida); }
.viva .ilus img { clip-path: inset(0 0 0 0); opacity: 1; transform: none; }
.ilus::after {
  content: ''; position: absolute; top: -20%; bottom: -20%; left: 0; width: 35%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgb(255 230 160 / .55), transparent); mix-blend-mode: soft-light;
  transform: translateX(-120%) skewX(-12deg); opacity: 0;
}
.viva .ilus::after { animation: brillo-oro 2.6s ease-in-out 1.3s; }
@keyframes brillo-oro { 0% { transform: translateX(-120%) skewX(-12deg); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateX(380%) skewX(-12deg); opacity: 0; } }
.ilus__pie { flex: none; text-align: center; margin-top: calc(var(--pw) * .025); font-family: 'Cormorant Garamond', Georgia, serif; color: var(--tinta-suave); }
.ilus__pie b { display: block; font-family: Marcellus, Georgia, serif; font-weight: 400; letter-spacing: .38em; font-size: calc(var(--pw) * .018 + 3px); color: var(--oro-hondo); text-transform: uppercase; }
.ilus__pie em { font-size: calc(var(--pw) * .036 + 4px); }

/* Tapa dura */
.pagina--tapa, .pagina--contra {
  color: rgb(var(--crema)); justify-content: center; align-items: center; text-align: center;
  background:
    radial-gradient(90% 70% at 30% 20%, rgb(40 76 124 / .9), transparent 70%),
    linear-gradient(160deg, #13325a, #0a1f38 55%, #06152a);
}
.pagina--tapa::before, .pagina--contra::before {   /* marco de oro estampado */
  content: ''; position: absolute; inset: calc(var(--pw) * .05); border: 1.5px solid rgb(216 180 106 / .75); border-radius: 4px;
  box-shadow: inset 0 0 0 5px rgb(10 31 56), inset 0 0 0 6px rgb(216 180 106 / .45);
}
.pagina--tapa::after {   /* lomo */
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 7%;
  background: linear-gradient(90deg, rgb(0 0 0 / .45), rgb(255 255 255 / .06) 60%, transparent);
}
.tapa__ante { font-family: Marcellus, Georgia, serif; letter-spacing: .38em; font-size: calc(var(--pw) * .022 + 3px); color: var(--oro-claro); text-transform: uppercase; }
.tapa__titulo {
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; line-height: .98; margin: .5em 0 .2em;
  font-size: calc(var(--pw) * .1 + 6px);
  background: var(--oro-metal); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tapa__titulo i { display: block; font-size: .45em; font-weight: 500; margin: .2em 0; }
.tapa__brillo { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.tapa__brillo::after {
  content: ''; position: absolute; top: -30%; bottom: -30%; left: 0; width: 30%;
  background: linear-gradient(100deg, transparent, rgb(255 236 180 / .22), transparent);
  transform: translateX(-150%) skewX(-14deg); animation: brillo-tapa 5.5s ease-in-out 1.5s infinite;
}
@keyframes brillo-tapa { 0%, 55% { transform: translateX(-150%) skewX(-14deg); } 100% { transform: translateX(420%) skewX(-14deg); } }

/* Guardas: papel azul con maripositas doradas */
.pagina--guarda {
  background-color: #0c2442;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70' viewBox='0 0 70 70'%3E%3Cg fill='none' stroke='%23d8b46a' stroke-opacity='.35' stroke-width='.8'%3E%3Cpath d='M35 33c-3-7-9-11-13-9-3 2 1 7 13 10M35 33c3-7 9-11 13-9 3 2-1 7-13 10M35 35c-6 0-9 5-7 7s6-2 7-6M35 35c6 0 9 5 7 7s-6-2-7-6'/%3E%3C/g%3E%3C/svg%3E");
}
.pagina--titulo, .pagina--orn, .pagina--fin { justify-content: center; align-items: center; text-align: center; padding: 12%; }
.titulo-libro { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; color: rgb(var(--noche)); font-size: calc(var(--pw) * .085 + 4px); line-height: 1; margin: .4em 0 .3em; }
.titulo-libro i { display: block; font-size: .42em; color: var(--oro-hondo); font-weight: 500; margin: .3em 0; }
.subtitulo-libro { font-family: Marcellus, Georgia, serif; letter-spacing: .35em; text-transform: uppercase; font-size: calc(var(--pw) * .02 + 3px); color: var(--tinta-suave); }
.ornamento { color: var(--oro); letter-spacing: .5em; margin-top: 1.2em; }
.fin__palabra { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: calc(var(--pw) * .13 + 6px); color: var(--oro-hondo); line-height: 1; }
.fin__texto { font-family: 'Cormorant Garamond', Georgia, serif; font-size: calc(var(--pw) * .036 + 6px); line-height: 1.35; color: var(--tinta); margin: 1em 0 1.4em; }
.pagina--contra { padding: 0 16%; }
.fin__texto { text-wrap: balance; }   /* el texto queda dentro del marco de oro */
.pagina--contra .fin__texto { color: rgb(var(--crema)); }
.cita__texto { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: calc(var(--pw) * .045 + 5px); line-height: 1.35; color: rgb(var(--noche)); margin: 1em 0 .9em; text-wrap: balance; }
.cita__firma { font-family: Marcellus, Georgia, serif; letter-spacing: .32em; text-transform: uppercase; font-size: calc(var(--pw) * .018 + 3px); color: var(--oro-hondo); }
.pagina--contra .btn { position: relative; z-index: 2; }
.contra__marca { margin-top: 1.4em; font-family: Marcellus, Georgia, serif; letter-spacing: .3em; text-transform: uppercase; font-size: calc(var(--pw) * .018 + 3px); color: var(--oro-claro); position: relative; z-index: 2; }
.contra__marca img { display: block; width: calc(var(--pw) * .16); height: auto; margin: 0 auto .8em; }
.contra__volver { display: inline-block; margin-top: 1em; font-size: .85rem; color: rgb(var(--crema) / .7); position: relative; z-index: 2; }

/* ---------- Controles ---------- */
.controles {
  position: absolute; z-index: 30; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: .9rem; padding: .45rem .55rem; border-radius: 999px;
  background: rgb(6 18 34 / .6); border: 1px solid rgb(255 255 255 / .1);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .6s .6s;
}
.abierto .controles { opacity: 1; pointer-events: auto; }
.controles__progreso { width: clamp(90px, 22vw, 240px); height: 3px; border-radius: 3px; background: rgb(255 255 255 / .12); overflow: hidden; }
.controles__barra { display: block; height: 100%; background: var(--oro-metal); transform-origin: left; transform: scaleX(0); transition: transform .8s var(--e-salida); }
.controles__texto { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; color: var(--oro-claro); min-width: 9.5em; text-align: center; font-size: 1rem; white-space: nowrap; }
@media (max-width: 520px) {
  .controles { gap: .5rem; max-width: calc(100vw - 24px); }
  .controles__progreso { width: 56px; flex: none; }
  /* el nombre del capítulo puede ser largo: se corta con "…" en vez de sacar las flechas de la pantalla */
  .controles__texto { min-width: 0; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Índice ---------- */
.indice {
  position: absolute; z-index: 40; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgb(5 16 31 / .72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity .35s;
}
.indice[data-abierto="true"] { opacity: 1; pointer-events: auto; }
.indice__panel { width: min(460px, 100%); max-height: 85vh; overflow: auto; padding: 2rem 1.6rem; border-radius: 24px;
  background: linear-gradient(160deg, rgb(255 255 255 / .09), rgb(255 255 255 / .03)); border: 1px solid rgb(255 255 255 / .12); }
.indice__titulo { margin: 0 0 1.2rem; text-align: center; font-family: Marcellus, Georgia, serif; letter-spacing: .35em; text-transform: uppercase; font-size: .8rem; color: var(--oro-claro); }
.indice ol { list-style: none; margin: 0; padding: 0; }
.indice button { width: 100%; display: flex; gap: 1rem; align-items: baseline; padding: .7rem .8rem; border-radius: 12px; text-align: left; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.25rem; transition: background-color .2s; }
.indice button:hover, .indice button[aria-current="true"] { background: rgb(255 255 255 / .07); }
.indice button b { font-family: Marcellus, Georgia, serif; font-weight: 400; color: var(--oro); font-size: .8rem; letter-spacing: .2em; min-width: 2.6em; }

/* ---------- Mariposas (la misma figura del sitio) ---------- */
.mp {
  position: relative; display: inline-block; flex: none;
  width: var(--t, 28px); height: var(--t, 28px); perspective: calc(var(--t, 28px) * 3.2);
  --mp-ala: url(#mp-oro); --mp-filo: url(#mp-filo); --mp-vena: url(#mp-filo);
  --mp-banda: rgb(232 186 92 / .38); --mp-escarcha: url(#mp-escarcha);
  --mp-chispa: #fff1c0; --mp-cuerpo: url(#mp-filo);
  --mp-celda: rgb(246 214 140 / .07); --mp-mancha: #ffe9b0;
  filter: drop-shadow(0 0 calc(var(--t, 28px) * .016) rgb(242 194 96 / .55));
}
.mp svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mp__ala { position: absolute; top: 0; width: 50%; height: 100%; }
.mp__ala--i { left: 0; transform-origin: 100% 50%; animation: mp-i var(--vel, 340ms) ease-in-out infinite alternate; }
.mp__ala--d { right: 0; transform-origin: 0 50%; animation: mp-d var(--vel, 340ms) ease-in-out infinite alternate; }
.mp__cuerpo { position: absolute; inset: 0; }
@keyframes mp-i { from { transform: rotateY(4deg); } to { transform: rotateY(64deg); } }
@keyframes mp-d { from { transform: rotateY(-4deg); } to { transform: rotateY(-64deg); } }
.mp-vuela { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; will-change: transform; }
.chispa {
  position: fixed; left: 0; top: 0; z-index: 49; width: var(--c, 4px); height: var(--c, 4px); pointer-events: none;
  background: radial-gradient(circle, #fff7dc 0%, #f1cf7f 45%, rgb(241 207 127 / 0) 72%);
  animation: chispa var(--d, 900ms) cubic-bezier(.16, 1, .3, 1) forwards;
}
.chispa--estrella { --c: 9px; background: #f8e2a6; clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); }
@keyframes chispa {
  from { opacity: 1; transform: translate3d(var(--x), var(--y), 0) scale(1); }
  to   { opacity: 0; transform: translate3d(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy)), 0) scale(.2) rotate(90deg); }
}

/* ---------- El texto original (para buscadores, lectores de pantalla y sin JS) ---------- */
.js .texto-fuente { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.texto-fuente { position: relative; max-width: 680px; margin: 0 auto; padding: 100px 22px 80px; color: rgb(var(--crema)); font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.25rem; line-height: 1.6; }
html:not(.js) body.cuento { overflow: auto; }
html:not(.js) .escena { display: none; }
.texto-fuente h1, .texto-fuente h2 { color: var(--oro-claro); }
.texto-fuente img { width: 100%; height: auto; border-radius: 12px; }

/* El medidor de páginas (invisible) */
.medidor { position: absolute; left: -9999px; top: 0; visibility: hidden; width: var(--pw); height: var(--ph); }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .mp__ala { animation: none !important; }
  /* Reducir no es eliminar: los fundidos se mantienen */
  .js .ilus img { clip-path: none !important; transform: none !important; transition: opacity .8s ease !important; }
  .aura { display: none; }
}

/* Detalles del paginado */
.pagina__cuerpo p.partido { text-align-last: justify; }   /* la frase sigue en la página siguiente */
.ilus__mariposa { display: grid; place-items: center; width: 100%; height: 100%; }
.libro.salto { animation: salto .45s ease; }

/* Entrada con el libro cerrado: la tapa ilustrada a un lado, el título al otro */
.portal--con-libro { grid-template-columns: auto minmax(0, 560px); justify-content: center; align-content: center; column-gap: clamp(2rem, 6vw, 6rem); }
.portal--con-libro .portal__texto { text-align: left; }
.portal--con-libro .portal__acciones { justify-content: flex-start; }
.portal--con-libro .portal__titulo { font-size: clamp(2.8rem, min(1.6rem + 4.6vw, 11vh), 6.4rem); }
.portal__libro {
  --pw: min(46vh, 340px); --ph: calc(var(--pw) * 1.38);
  position: relative; width: var(--pw); height: var(--ph); padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 3px 8px 8px 3px; overflow: hidden;
  box-shadow: 0 40px 70px -30px rgb(0 0 0 / .85), 0 0 0 1px rgb(216 180 106 / .25), 18px 0 0 -8px #e9e1cd;   /* el canto de las hojas */
  transform: perspective(1400px) rotateY(16deg) rotateX(3deg);
  transition: transform .9s var(--e-salida), opacity 1.2s ease;
}
.portal__libro:hover, .portal__libro:focus-visible { transform: perspective(1400px) rotateY(4deg) translateY(-6px); }
.js .portal__libro { opacity: 0; transform: perspective(1400px) rotateY(34deg) translateX(-30px); }
.listo .portal__libro { opacity: 1; transform: perspective(1400px) rotateY(16deg) rotateX(3deg); }
.listo .portal__libro:hover, .listo .portal__libro:focus-visible { transform: perspective(1400px) rotateY(4deg) translateY(-6px); }
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .portal--con-libro { grid-template-columns: 1fr; row-gap: 1.1rem; }
  .portal--con-libro .portal__texto { text-align: center; }
  .portal--con-libro .portal__acciones { justify-content: center; }
  .portal__libro { --pw: min(24vh, 190px); justify-self: center; }
}

/* Ilustración embebida: arriba de la primera página del capítulo, con el texto debajo */
.ilus--cabecera { flex: none; height: calc(var(--ph) * .3); margin: 0 0 .4em; }
.ilus--cabecera img {
  /* más suave que la de página completa: en una franja baja, la otra se comía el dibujo */
  -webkit-mask-image: radial-gradient(ellipse 90% 88% at 50% 50%, #000 72%, transparent 100%);
  mask-image: radial-gradient(ellipse 90% 88% at 50% 50%, #000 72%, transparent 100%);
}
.ilus--cabecera + .capitulo-cabeza { margin-bottom: .8em; }

/* Viñeta de cierre: ocupa el aire que deja el final de un capítulo */
.vineta { margin: 0; display: grid; place-items: center; }
.vineta img {
  max-width: 82%; max-height: 100%; width: auto; height: 100%; object-fit: contain; display: block; mix-blend-mode: multiply;
  -webkit-mask-image: radial-gradient(ellipse 68% 68% at 50% 50%, #000 58%, transparent 100%);
  mask-image: radial-gradient(ellipse 68% 68% at 50% 50%, #000 58%, transparent 100%);
}
.js .vineta img, .js .vineta .mp { opacity: 0; transform: translateY(12px); transition: opacity 1.4s ease .5s, transform 1.8s var(--e-salida) .5s; }
.viva .vineta img, .viva .vineta .mp { opacity: 1; transform: none; }

/* Tapa ilustrada: el dibujo en oro sobre azul, y el título encima, en el aire que deja arriba */
.pagina--tapa.con-arte { justify-content: flex-start; padding-top: calc(var(--ph) * .085); }
.tapa__arte { position: absolute; inset: 0; }
.tapa__arte img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pagina--tapa.con-arte > :not(.tapa__arte):not(.tapa__brillo) { position: relative; z-index: 2; }
.pagina--tapa.con-arte .tapa__titulo { filter: drop-shadow(0 2px 10px rgb(6 18 34 / .7)); }
@keyframes salto { 0% { opacity: .2; } 100% { opacity: 1; } }

/* Red de seguridad global de movimiento reducido (como en el sitio): todo
   llega a su estado final al instante. Las excepciones de arriba (fundidos de
   las ilustraciones) llevan !important y mayor especificidad. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.pagina__cuerpo p.fin-capitulo { text-align: center; text-indent: 0; color: var(--oro); letter-spacing: .5em; margin-top: 1.4em; font-size: .8em; }
