/* ════════════════════════════════════════════════════
   BOOK – solo invitacion-libro.html
   ──────────────────────────────────────────────────
   La invitación como libro de cuentos: tapa, hojas que
   se voltean en 3D, canto de páginas, marcapáginas y
   contratapa. Reutiliza la paleta y tipografía de
   index.html (redefinidas aquí, no en variables.css).
════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────────
   1. VARIABLES
───────────────────────────────────────────────────── */
:root {
	--color-paper:       #F8F1EA;
	--color-paper-dark:  #EFE4D8;
	--color-ink:         #0F1C2E;
	--color-ink-soft:    #26374d;
	--color-rose:        #d16d7a;
	--color-rose-light:  #e3a9bd;
	--color-rose-pale:   #EBC5CD;
	--color-gold:        #C8A86A;
	--color-gold-light:  #ddc496;
	--color-gold-deep:   #9c7c42;
	--color-blue-deep:   #0F1C2E;
	--color-night:       #000A19;
	--font-display:      'Playfair Display', Georgia, serif;
	--font-body:         'Lato', Arial, sans-serif;
	--font-accent:       'Playfair Display', Georgia, serif;
	--font-script:       'Great Vibes', cursive;

	/* Tamaño de una página: lo calcula js/book.js en píxeles enteros */
	--page-w: 360px;
	--page-h: 640px;
	--page-radius: 12px;

	/* Paso de página: ni muy rápido ni muy lento, como un cuento.
	   Debe coincidir con TURN_MS en js/book.js */
	--turn-time: 1.4s;
	--turn-ease: cubic-bezier(.45, .05, .25, 1);

	--paper-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}


/* ─────────────────────────────────────────────────────
   2. ESCENARIO (cielo nocturno con estrellas)
───────────────────────────────────────────────────── */
html, body {
	height: 100%;
	overflow: hidden;
	scroll-snap-type: none;
	background: var(--color-night);
}

body::before { display: none; }

.book-stage {
	position: fixed;
	inset: 0;
	overflow: hidden;
	background: radial-gradient(ellipse at 50% 40%, #0c1a38 0%, var(--color-night) 70%);
}

.sky,
.sky::before,
.sky::after {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.sky {
	background-image:
		radial-gradient(1.5px 1.5px at 12% 18%, #fff8, transparent),
		radial-gradient(1px 1px at 28% 72%, #fff7, transparent),
		radial-gradient(1.5px 1.5px at 44% 8%, #ffe9b8aa, transparent),
		radial-gradient(1px 1px at 63% 88%, #fff6, transparent),
		radial-gradient(2px 2px at 82% 26%, #ffe9b8aa, transparent),
		radial-gradient(1px 1px at 92% 64%, #fff7, transparent),
		radial-gradient(1px 1px at 6% 52%, #fff6, transparent);
	animation: twinkle 4s ease-in-out infinite alternate;
}

.sky::before {
	content: '';
	background-image:
		radial-gradient(1px 1px at 20% 40%, #fff8, transparent),
		radial-gradient(1.5px 1.5px at 36% 92%, #ffe9b8aa, transparent),
		radial-gradient(1px 1px at 54% 30%, #fff6, transparent),
		radial-gradient(1.5px 1.5px at 74% 50%, #fff8, transparent),
		radial-gradient(1px 1px at 88% 8%, #fff7, transparent);
	animation: twinkle 3s ease-in-out 1.5s infinite alternate;
}

@keyframes twinkle {
	from { opacity: .35; }
	to   { opacity: 1; }
}


/* ─────────────────────────────────────────────────────
   3. LIBRO (doble página), CÁMARA, CANTOS Y CONTRATAPA
   ──────────────────────────────────────────────────
   .book mide dos páginas de ancho con el lomo al centro.
   js/book.js fija en píxeles enteros su tamaño y posición
   (--page-w, --page-h, left/top) y la "cámara" (--cam-x):
   en móvil se ve una página y la cámara se corre a la
   izquierda o a la derecha; en escritorio se ve la doble
   página completa.
───────────────────────────────────────────────────── */
.book {
	--s: 1;          /* fracción de hojas por leer  (js/book.js) */
	--r: 0;          /* fracción de hojas ya leídas (js/book.js) */
	--cam-x: 0px;
	--cam-time: 1s;
	position: absolute;
	width: calc(var(--page-w) * 2);
	height: var(--page-h);
	perspective: 3600px;
	touch-action: pan-y;
	transform: translate3d(var(--cam-x), 0, 0);
	transition: transform var(--cam-time) var(--turn-ease);
	will-change: transform;
}

/* Vistazo: en una página izquierda la cámara se asoma un poco a la derecha */
.book.cam-peek { animation: cam-peek 1.6s ease-in-out; }

@keyframes cam-peek {
	0%, 100% { transform: translate3d(var(--cam-x), 0, 0); }
	45%      { transform: translate3d(calc(var(--cam-x) - 16px), 0, 0); }
}

/* Mitad derecha: todas las hojas, la contratapa y el canto por leer */
.book-block,
.back-cover,
.leaf {
	position: absolute;
	top: 0;
	left: 50%;
	width: 50%;
	height: 100%;
}

.book-block {
	border-radius: 2px var(--page-radius) var(--page-radius) 2px;
	background: var(--color-paper-dark);
	box-shadow:
		calc(var(--s) * 2px) 1px 0 #efe5d7,
		calc(var(--s) * 3px) 2px 0 #d9cbb6,
		calc(var(--s) * 5px) 3px 0 #ede2d3,
		calc(var(--s) * 6px) 4px 0 #cfbfa7,
		calc(var(--s) * 8px) 5px 0 #e8dccb,
		calc(var(--s) * 9px) 6px 0 #c4b397,
		0 24px 60px rgba(0, 0, 0, .6);
	transition: box-shadow var(--turn-time) var(--turn-ease);
}

/* Mitad izquierda: canto de las hojas ya leídas (solo con el libro abierto) */
.book-block-left {
	position: absolute;
	top: 0;
	left: 0;
	width: 50%;
	height: 100%;
	border-radius: var(--page-radius) 2px 2px var(--page-radius);
	background: var(--color-paper-dark);
	box-shadow:
		calc(var(--r) * -2px) 1px 0 #efe5d7,
		calc(var(--r) * -3px) 2px 0 #d9cbb6,
		calc(var(--r) * -5px) 3px 0 #ede2d3,
		calc(var(--r) * -6px) 4px 0 #cfbfa7,
		calc(var(--r) * -8px) 5px 0 #e8dccb,
		calc(var(--r) * -9px) 6px 0 #c4b397,
		0 24px 60px rgba(0, 0, 0, .6);
	opacity: 0;
	transition: opacity .4s ease var(--turn-time), box-shadow var(--turn-time) var(--turn-ease);
}

.book-stage:not(.is-cover) .book-block-left { opacity: 1; transition-delay: 0s; }

/* Contratapa (p9): queda debajo de todas las hojas */
.back-cover {
	z-index: 1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	overflow: hidden;
	border-radius: 2px var(--page-radius) var(--page-radius) 2px;
	background:
		linear-gradient(to right, rgba(60, 40, 20, .2), transparent 5%),
		var(--paper-texture),
		linear-gradient(to bottom, var(--color-paper), var(--color-paper-dark));
	text-align: center;
}

.back-cover-inner {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .6rem;
	padding: 1.5rem 1.5rem 0;
}

.back-heart { color: var(--color-rose); font-size: 1.6rem; }

.back-restart {
	padding: .45rem 1.1rem;
	border: 1px solid var(--color-gold);
	border-radius: 20px;
	background: transparent;
	font-family: var(--font-body);
	font-size: .66rem;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--color-gold-deep);
	cursor: pointer;
	transition: background .3s, color .3s;
}

.back-restart:hover { background: var(--color-gold); color: #fff; }

/* Cierre: nombres grandes y la bugambilia al pie, sobre el humo del footer */
.back-names {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0 1rem;
	font-family: var(--font-script);
	font-size: clamp(2.2rem, 11.5vw, 2.9rem);
	line-height: 1.15;
	color: var(--color-ink);
}

.back-footer {
	position: relative;
	background: url('../assets/footer.png') bottom center / 100% auto no-repeat;
}

.back-tree {
	display: block;
	width: 50%;
	margin: .2rem auto -.7rem;
}

/* p8: "…y vivieron felices para siempre" / Fin */
.fin-page {
	min-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .3rem;
	padding: 2rem 1.5rem;
	text-align: center;
}

.fin-happy {
	font-family: var(--font-script);
	max-width: 6.5em;
	font-size: clamp(2.4rem, 11vw, 3rem);
	line-height: 1.15;
	text-wrap: balance;
	color: var(--color-rose);
}

.fin-end {
	font-family: var(--font-display);
	font-style: italic;
	font-size: clamp(2.6rem, 11vw, 3.6rem);
	letter-spacing: .08em;
	color: var(--color-ink);
}

.fin-epilogue {
	font-family: var(--font-accent);
	font-style: italic;
	font-size: .8rem;
	color: var(--color-ink-soft);
}

.fin-heart { margin-top: .6rem; color: var(--color-rose); font-size: 2.8rem; line-height: 1; }


/* ─────────────────────────────────────────────────────
   4. HOJAS (giran sobre el lomo hacia la izquierda)
───────────────────────────────────────────────────── */
.leaf {
	transform-origin: left center;
	transition:
		transform var(--turn-time) var(--turn-ease),
		visibility 0s linear 0s;
}

/* Hoja ya leída: queda en la mitad izquierda; las de debajo se ocultan al terminar el giro */
.leaf.turned {
	transform: rotateY(-180deg);
	visibility: hidden;
	transition:
		transform var(--turn-time) var(--turn-ease),
		visibility 0s linear var(--turn-time);
}

/* La última hoja leída es la página izquierda visible */
.leaf.turned.on-left { visibility: visible; }

.leaf-front,
.leaf-back {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

/* Nitidez:
   - En reposo la página que se lee es plana (sin 3D), así se pinta a
     resolución nativa.
   - .prep activa el 3D y el reverso ANTES de que empiece el giro
     (js/book.js lo pone al tocar y espera un par de cuadros), para que
     el navegador ya tenga la hoja rasterizada cuando arranca a moverse
     y no se vea pixelada en el primer instante. */
.leaf.prep,
.leaf.turning,
.leaf.turned,
.leaf.peek {
	transform-style: preserve-3d;
	will-change: transform;
}

.leaf.prep .leaf-front,
.leaf.prep .leaf-back,
.leaf.turning .leaf-front,
.leaf.turning .leaf-back,
.leaf.turned .leaf-front,
.leaf.turned .leaf-back,
.leaf.peek .leaf-front,
.leaf.peek .leaf-back {
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

/* En reposo solo se pinta la cara que mira al lector. En móviles
   backface-visibility no oculta las capas internas (scroll, imágenes,
   animaciones) y se transparentaba la otra cara de la hoja. */
.leaf:not(.turning):not(.turned) .leaf-back,
.leaf.turned:not(.turning) .leaf-front { visibility: hidden; }

/* Frente = página derecha (lomo a la izquierda) */
.leaf-front {
	border-radius: 2px var(--page-radius) var(--page-radius) 2px;
	background:
		linear-gradient(to right, rgba(60, 40, 20, .22), rgba(60, 40, 20, 0) 5%, rgba(60, 40, 20, 0) 96%, rgba(60, 40, 20, .06)),
		var(--paper-texture),
		var(--color-paper);
	box-shadow: 1px 0 3px rgba(0, 0, 0, .12);
}

/* Reverso = página izquierda (lomo a la derecha) */
.leaf-back {
	transform: rotateY(180deg);
	border-radius: var(--page-radius) 2px 2px var(--page-radius);
	background:
		linear-gradient(to left, rgba(60, 40, 20, .24), rgba(60, 40, 20, 0) 5%, rgba(60, 40, 20, 0) 96%, rgba(60, 40, 20, .06)),
		var(--paper-texture),
		linear-gradient(to bottom, var(--color-paper), var(--color-paper-dark));
}

/* Esquineros dorados en L (frente y reverso) */
.leaf-front::before,
.leaf-back::before {
	content: '';
	position: absolute;
	inset: 10px;
	z-index: 20;
	pointer-events: none;
	--c: rgba(200, 168, 106, .75);
	background:
		linear-gradient(var(--c), var(--c)) top left     / 24px 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) top left     / 1.5px 24px no-repeat,
		linear-gradient(var(--c), var(--c)) top right    / 24px 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) top right    / 1.5px 24px no-repeat,
		linear-gradient(var(--c), var(--c)) bottom left  / 24px 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) bottom left  / 1.5px 24px no-repeat,
		linear-gradient(var(--c), var(--c)) bottom right / 24px 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) bottom right / 1.5px 24px no-repeat;
}

/* Sombra que recorre la hoja mientras gira */
.leaf-front::after,
.leaf-back::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 30;
	pointer-events: none;
	opacity: 0;
	background: linear-gradient(to left, rgba(15, 28, 46, .4), rgba(15, 28, 46, .05) 60%, transparent);
}

.leaf.turning .leaf-front::after,
.leaf.turning .leaf-back::after {
	animation: turn-shade var(--turn-time) var(--turn-ease);
}

@keyframes turn-shade {
	0%   { opacity: 0; }
	50%  { opacity: 1; }
	100% { opacity: 0; }
}

/* Guarda (reverso de la tapa) */
.leaf-back-ornament {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-display);
	font-size: 1.1rem;
	letter-spacing: .4em;
	color: rgba(200, 168, 106, .6);
}

/* "Asomarse": la página derecha se levanta un poco cuando nadie la toca */
.leaf.peek { animation: leaf-peek 1.9s ease-in-out; }

@keyframes leaf-peek {
	0%, 100% { transform: rotateY(0); }
	45%      { transform: rotateY(-10deg); }
	60%      { transform: rotateY(-7deg); }
}

/* Oreja: esquina inferior derecha doblada de la página derecha enfocada */
.dog-ear {
	position: absolute;
	right: 0;
	bottom: 0;
	z-index: 25;
	width: 24px;
	height: 24px;
	border-radius: 0 0 var(--page-radius) 0;
	background:
		linear-gradient(315deg, #d9cbb6 0%, #e9dccb 42%, transparent 44%),
		linear-gradient(135deg, transparent 50%, #f3e9dc 50%, #fbf6ef 62%, #e2d4bf 100%);
	box-shadow: -2px -2px 5px rgba(15, 28, 46, .15);
	clip-path: polygon(100% 0, 100% 100%, 0 100%);
	opacity: 0;
	cursor: pointer;
	transition: opacity .6s ease;
	animation: dog-ear 2.8s ease-in-out infinite;
}

.leaf-front.focused .dog-ear { opacity: 1; }

@keyframes dog-ear {
	0%, 100% { width: 24px; height: 24px; }
	50%      { width: 32px; height: 32px; }
}


/* ─────────────────────────────────────────────────────
   HUD: pistas, número de página y marcapáginas.
   No se mueve con la cámara; js/book.js lo ubica sobre
   la parte visible del libro (una página en móvil, la
   doble página en escritorio).
───────────────────────────────────────────────────── */
.book-hud {
	position: absolute;
	z-index: 100;
	pointer-events: none;
}

.book-hud > * { pointer-events: auto; }
.book-hud > .edge-arrows,
.book-hud > .page-num,
.book-hud > .swipe-hint { pointer-events: none; }


/* ─────────────────────────────────────────────────────
   5. TAPA
───────────────────────────────────────────────────── */
.leaf-cover .cover-front {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 3px var(--page-radius) var(--page-radius) 3px;
	background:
		linear-gradient(to right, rgba(0, 0, 0, .4), rgba(255, 255, 255, .05) 1.5%, rgba(0, 0, 0, 0) 3%),
		var(--paper-texture),
		radial-gradient(ellipse at 30% 20%, #1d3160 0%, #0c1733 55%, #050c1e 100%);
	box-shadow: inset 0 0 40px rgba(0, 0, 0, .55);
	color: var(--color-paper);
}

.leaf-cover .cover-front::before { --c: var(--color-gold); inset: 18px 18px 18px 14px; }

/* Marco dorado doble con un brillo que lo recorre */
.cover-frame {
	position: absolute;
	inset: 12px 12px 12px 8px;
	border: 1.5px solid var(--color-gold);
	border-radius: 4px 8px 8px 4px;
	outline: 1px solid rgba(200, 168, 106, .45);
	outline-offset: -8px;
	pointer-events: none;
	overflow: hidden;
}

.cover-frame::after {
	content: '';
	position: absolute;
	top: -50%;
	left: -60%;
	width: 40%;
	height: 200%;
	transform: rotate(20deg);
	background: linear-gradient(to right, transparent, rgba(255, 233, 184, .18), transparent);
	animation: shimmer 5s ease-in-out infinite;
}

@keyframes shimmer {
	0%, 30% { left: -60%; }
	70%     { left: 130%; }
	100%    { left: 130%; }
}

.cover-inner {
	position: relative;
	z-index: 2;
	text-align: center;
	padding: 2rem 1.6rem;
}

.cover-monogram {
	width: clamp(90px, 26vw, 120px);
	height: clamp(90px, 26vw, 120px);
	margin: 0 auto 1.4rem;
	border-radius: 50%;
	border: 1.5px solid var(--color-gold);
	outline: 1.5px solid var(--color-gold);
	outline-offset: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .3em;
	font-family: var(--font-display);
	font-weight: 600;
	font-size: clamp(1.4rem, 5vw, 1.9rem);
	animation: halo 3.2s ease-in-out infinite;
}

@keyframes halo {
	0%, 100% { box-shadow: 0 0 0 rgba(221, 196, 150, 0); }
	50%      { box-shadow: 0 0 26px rgba(221, 196, 150, .35); }
}

.cover-monogram .heart { color: var(--color-rose); font-size: .7em; }

.cover-names {
	font-family: var(--font-script);
	font-size: clamp(2rem, 8vw, 2.7rem);
	line-height: 1.1;
}

.cover-divider {
	margin: .7rem auto .6rem;
	color: var(--color-gold);
	font-size: .8rem;
	letter-spacing: .6em;
}

.cover-for {
	font-family: var(--font-accent);
	font-style: italic;
	font-size: clamp(.85rem, 3.2vw, 1rem);
	color: rgba(248, 241, 234, .8);
}

.cover-guest {
	min-height: 1.2em;
	margin-top: .2rem;
	font-family: var(--font-script);
	font-size: clamp(1.9rem, 8vw, 2.5rem);
	line-height: 1.1;
	color: var(--color-gold-light);
	text-shadow: 0 0 14px rgba(221, 196, 150, .35);
}

.cover-tap {
	margin-top: 1.8rem;
	font-family: var(--font-body);
	font-size: .66rem;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--color-gold-light);
	animation: cover-pulse 1.6s ease-in-out infinite;
}

@keyframes cover-pulse {
	0%, 100% { opacity: .55; }
	50%      { opacity: 1; }
}

/* Luciérnagas sobre la tapa */
.fireflies i {
	position: absolute;
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: #ffe9b8;
	box-shadow: 0 0 8px 2px rgba(255, 233, 184, .6);
	opacity: 0;
	animation: firefly 7s ease-in-out infinite;
}

.fireflies i:nth-child(1) { left: 18%; top: 22%; animation-delay: 0s;   }
.fireflies i:nth-child(2) { left: 78%; top: 16%; animation-delay: 1.2s; animation-duration: 8s; }
.fireflies i:nth-child(3) { left: 30%; top: 70%; animation-delay: 2.4s; }
.fireflies i:nth-child(4) { left: 70%; top: 78%; animation-delay: .6s;  animation-duration: 9s; }
.fireflies i:nth-child(5) { left: 86%; top: 48%; animation-delay: 3.1s; }
.fireflies i:nth-child(6) { left: 12%; top: 50%; animation-delay: 4s;   animation-duration: 6s; }
.fireflies i:nth-child(7) { left: 50%; top: 10%; animation-delay: 5s;   }
.fireflies i:nth-child(8) { left: 56%; top: 88%; animation-delay: 1.8s; animation-duration: 8.5s; }

@keyframes firefly {
	0%   { opacity: 0; transform: translate(0, 0); }
	25%  { opacity: 1; }
	50%  { opacity: .4; transform: translate(14px, -22px); }
	75%  { opacity: 1; }
	100% { opacity: 0; transform: translate(-10px, -40px); }
}

/* Reverso de la tapa: guarda con papel marmoleado */
.leaf-cover .leaf-back::before { display: none; }

.leaf-cover .leaf-back {
	background:
		radial-gradient(circle at 20% 30%, rgba(209, 109, 122, .18), transparent 40%),
		radial-gradient(circle at 70% 70%, rgba(200, 168, 106, .2), transparent 45%),
		var(--paper-texture),
		#1a2747;
}


/* ─────────────────────────────────────────────────────
   6. CONTENIDO DE CADA PÁGINA (compacto para que quepa)
───────────────────────────────────────────────────── */
.page-scroll {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	overflow-x: hidden;
	scrollbar-width: none;
	overscroll-behavior: contain;
}

.page-scroll::-webkit-scrollbar { display: none; }

.leaf .section {
	height: auto;
	min-height: 100%;
	padding: 0;
	overflow: visible;
	background: transparent !important;
	animation: none !important;
	scroll-snap-align: none;
}

.leaf .section-inner {
	max-width: none;
	min-height: 100%;
	padding: 2.2rem 1.4rem 3rem;
	justify-content: center;
	background: transparent !important;
	backdrop-filter: none;
	box-shadow: none;
	border-radius: 0;
}

.leaf .section-inner::before { display: none; }

.leaf .section-inner .corner-img { width: clamp(70px, 20vw, 110px); }

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Tipografía común de las páginas */
.leaf .section-label  { font-size: .62rem; letter-spacing: .2em; margin-bottom: .2rem; }

.leaf .section-title {
	font-family: var(--font-display);
	font-style: normal;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	font-size: clamp(1.35rem, 6vw, 1.9rem);
	color: var(--color-ink);
	margin-bottom: .1rem;
}

.leaf .section-divider { margin: .25rem auto .35rem; }
.leaf .section-body    { font-size: .86rem; line-height: 1.55; }
.leaf .section-note    { margin-top: .6rem; font-size: .72rem; opacity: .75; }

.leaf .section-img-wrap {
	margin: .3rem auto .5rem;
	border-radius: 8px;
	box-shadow: 0 6px 16px rgba(15, 28, 46, .15);
}

.leaf .section-img-wrap:not(.section-img-circle):not(.section-img-medallion):not(.section-img-banner):not(.section-img-hero) {
	aspect-ratio: 16 / 9;
	max-height: 20svh;
}

.leaf .section-img-circle { max-width: min(150px, 20svh); border-radius: 50%; }

.leaf .event-card    { margin-top: .3rem; padding: .7rem .9rem; border-radius: 8px; }
.leaf .event-detail  { margin: .3rem 0; }
.leaf .event-detail .text { font-size: .8rem; line-height: 1.4; }

.leaf .btn {
	align-self: center;
	margin-top: .8rem;
	padding: .5rem 1.2rem;
	font-size: .68rem;
	border-radius: 20px;
}

.btn-glow { animation: btn-glow 2.4s ease-in-out infinite; }

@keyframes btn-glow {
	0%, 100% { box-shadow: 0 0 0 rgba(209, 109, 122, 0); }
	50%      { box-shadow: 0 0 18px rgba(209, 109, 122, .45); }
}

/* Recomendaciones */
.leaf .rec-list  { margin-top: .4rem; }
.leaf .rec-item  { padding: .45rem 0; gap: .6rem; }
.leaf .rec-num   { font-size: 1.15rem; }
.leaf .rec-text  { font-size: .8rem; line-height: 1.5; }

/* Dress code en 2 columnas */
.leaf .dress-grid { grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.leaf .dress-item { padding: .6rem .45rem; gap: .25rem; border-radius: 8px; }
.leaf .dress-item .dress-icon  { font-size: 1.4rem; }
.leaf .dress-item .dress-title { font-size: .9rem; }
.leaf .dress-item .dress-desc  { font-size: .7rem; line-height: 1.4; }
.leaf .color-palette { gap: .3rem; margin-top: .3rem; }
.leaf .color-swatch  { width: 16px; height: 16px; }

/* Recuerdos en 3 mini tarjetas */
.leaf .qr-grid { grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .6rem; }
.leaf .qr-card { padding: .6rem .3rem; gap: .35rem; border-radius: 8px; }
.leaf .qr-placeholder { width: 46px; height: 46px; font-size: 1.3rem; border-radius: 50%; }
.leaf .qr-title { font-size: .74rem; }
.leaf .qr-desc  { font-size: .62rem; line-height: 1.35; }

/* Cabecera de capítulo: número, título, filigrana, nota (epígrafe) y frase del narrador */
.chapter-num {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .6rem;
	font-family: var(--font-display);
	font-variant: small-caps;
	font-size: .72rem;
	letter-spacing: .28em;
	color: var(--color-gold-deep);
}

.chapter-num::before,
.chapter-num::after {
	content: '';
	width: 28px;
	height: 1px;
	background: linear-gradient(to right, transparent, var(--color-gold));
}

.chapter-num::after { background: linear-gradient(to left, transparent, var(--color-gold)); }

.chapter-title {
	margin-top: .15rem;
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 500;
	font-size: clamp(1.7rem, 7.5vw, 2.2rem);
	line-height: 1.1;
	color: var(--color-ink);
}

.chapter-flourish {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .45rem;
	margin: .1rem auto .15rem;
	font-size: .8rem;
	line-height: 1;
	color: var(--color-rose);
}

.chapter-flourish::before,
.chapter-flourish::after {
	content: '✦';
	font-size: .55rem;
	color: var(--color-gold);
}

.chapter-note {
	max-width: 30ch;
	margin: 0 auto;
	font-family: var(--font-accent);
	font-style: italic;
	font-size: .76rem;
	line-height: 1.4;
	color: var(--color-ink-soft);
	opacity: .85;
}

.chapter-note::before { content: '— '; }
.chapter-note::after  { content: ' —'; }

.chapter-lead {
	margin: .4rem 0 .45rem;
	font-family: var(--font-display);
	font-style: italic;
	font-size: .88rem;
	line-height: 1.4;
	color: var(--color-ink);
}

/* Letra capital, como en los libros de cuentos */
.chapter-lead::first-letter {
	font-family: var(--font-script);
	font-style: normal;
	font-size: 1.9em;
	line-height: .8;
	color: var(--color-rose);
}

/* Aparición escalonada de los elementos al llegar a la página */
.leaf .fade-in { transition-duration: .8s; }
.leaf .fade-in:nth-child(6)  { transition-delay: .5s; }
.leaf .fade-in:nth-child(7)  { transition-delay: .6s; }
.leaf .fade-in:nth-child(8)  { transition-delay: .7s; }
.leaf .fade-in:nth-child(9)  { transition-delay: .8s; }
.leaf .fade-in:nth-child(10) { transition-delay: .9s; }
.leaf .fade-in:nth-child(n+11) { transition-delay: 1s; }


/* ─────────────────────────────────────────────────────
   7. PÁGINA 1 – GUARDA LA FECHA
───────────────────────────────────────────────────── */
#save-the-date .section-inner { justify-content: flex-start; padding-top: 0; }

.ts-hero-wrap { position: relative; }

.leaf .section-img-hero {
	width: calc(100% + 2.8rem);
	margin: 0 -1.4rem .2rem;
	max-height: 21svh;
	aspect-ratio: 14 / 9;
	border-radius: 0;
	box-shadow: none;
	background: transparent;
}

/* La foto se desvanece con una máscara (no con un degradado de color),
   así se funde con el papel sin dejar una franja de otro tono */
.ts-hero-fade { display: none; }

.leaf .section-img-hero .section-img {
	-webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
	mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}

.ts-monogram {
	position: absolute;
	left: 50%;
	bottom: 6px;
	transform: translate(-50%, 50%);
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: 1.5px solid var(--color-gold);
	outline: 1.5px solid var(--color-gold);
	outline-offset: 3px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .25em;
	font-family: var(--font-display);
	font-weight: 600;
	font-size: 1.05rem;
	color: var(--color-ink);
	background: var(--color-paper);
	z-index: 5;
	animation: halo 3.2s ease-in-out infinite;
}

.ts-monogram .heart { color: var(--color-rose); font-size: .7em; }

/* Prólogo */
.prologue-num { margin-top: 2.1rem; }

.once-upon {
	margin: 0 0 .1rem;
	font-family: var(--font-script);
	font-weight: 400;
	font-size: 1.9rem;
	line-height: 1.1;
	color: var(--color-rose);
}

.once-upon::first-letter { font-size: 1.35em; }

.story-text {
	margin: .15rem 0;
	font-family: var(--font-display);
	font-size: .8rem;
	line-height: 1.42;
	color: var(--color-ink);
}

.story-guest strong {
	font-family: var(--font-script);
	font-weight: 400;
	font-size: 1.55em;
	color: var(--color-rose);
	white-space: nowrap;
}

.story-lead {
	margin-top: .2rem;
	font-family: var(--font-accent);
	font-style: italic;
	font-size: .76rem;
	color: var(--color-ink-soft);
}

/* Separador entre la historia y la fecha: filetes dorados con un corazón */
.story-lead-date {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	margin-top: .45rem;
}

.story-lead-date::before,
.story-lead-date::after {
	content: '';
	width: 34px;
	height: 1px;
	background: linear-gradient(to right, transparent, var(--color-gold));
}

.story-lead-date::after { background: linear-gradient(to left, transparent, var(--color-gold)); }

/* Prólogo compacto para que quepa en una pantalla de móvil */
#save-the-date .section-img-hero { max-height: 21svh; }
#save-the-date .ts-date-wrap     { margin-top: 0; }
#save-the-date .ts-daynum        { font-size: 2.3rem; }
#save-the-date .ts-month         { font-size: .92rem; }
#save-the-date .ts-year          { font-size: .78rem; }
#save-the-date .ts-location      { margin-top: .15rem; }
#save-the-date .countdown        { margin-top: .2rem; }
#save-the-date .couple-names     { font-size: clamp(1.8rem, 8vw, 2.3rem); padding-top: 0; }

/* Separadores del Prólogo y Asistencia: crecen con el alto libre de la
   página para repartir el contenido, sin bajar del espaciado normal */
.page-gap {
	flex: 1 1 0;
	min-height: .3rem;
	max-height: 3rem;
}

#asistencia .section-img-circle { max-width: min(190px, 25svh); }

#guest-greeting {
	min-height: 1.2em;
	font-family: var(--font-accent);
	font-style: italic;
	font-size: .95rem;
	color: var(--color-rose);
	margin: .2rem auto 0;
}

.guest-name {
	font-family: var(--font-script);
	font-style: normal;
	font-size: 1.7em;
	color: var(--color-rose);
}

.ts-script {
	font-family: var(--font-script);
	font-size: 2rem;
	color: var(--color-rose);
	line-height: 1;
	margin-top: .1rem;
}

.ts-title {
	font-family: var(--font-display);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .06em;
	font-size: clamp(1.6rem, 7vw, 2.2rem);
	color: var(--color-ink);
	line-height: 1.1;
}

.ts-divider-line {
	display: flex;
	align-items: center;
	width: 150px;
	margin: .4rem auto;
	color: var(--color-gold);
}

.ts-divider-line .line {
	flex: 1;
	height: 1.5px;
	margin-right: 8px;
	background: linear-gradient(to right, transparent, var(--color-gold));
}

.ts-divider-line .line:last-child {
	margin: 0 0 0 8px;
	background: linear-gradient(to left, transparent, var(--color-gold));
}

.ts-intro {
	font-family: var(--font-body);
	font-style: italic;
	font-size: .9rem;
	line-height: 1.45;
	color: var(--color-ink);
}

.leaf .couple-names {
	flex-direction: row;
	gap: .4rem;
	padding-top: .2rem;
	font-size: clamp(1.9rem, 9vw, 2.6rem);
}

.leaf .couple-names .heart { font-size: .5em; }

.ts-date-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .8rem;
	margin: .3rem auto 0;
}

.ts-date-flower { width: 38px; opacity: .9; animation: float 4s ease-in-out infinite; }
.ts-date-flower + .ts-date + .ts-date-flower,
.ts-date ~ .ts-date-flower { animation-delay: 2s; }

@keyframes float {
	0%, 100% { transform: translateY(0) rotate(0); }
	50%      { transform: translateY(-5px) rotate(4deg); }
}

.ts-daynum {
	font-family: var(--font-display);
	font-weight: 400;
	font-size: 2.9rem;
	color: var(--color-rose);
	line-height: .9;
}

.ts-month {
	font-family: var(--font-display);
	text-transform: uppercase;
	letter-spacing: .16em;
	font-size: 1.05rem;
	color: var(--color-rose);
}

.ts-year {
	font-family: var(--font-display);
	letter-spacing: .16em;
	font-size: .9rem;
	color: var(--color-rose);
}

.ts-location {
	font-family: var(--font-body);
	text-transform: uppercase;
	letter-spacing: .12em;
	font-size: .7rem;
	color: var(--color-ink-soft);
	margin-top: .3rem;
}

.leaf .countdown       { margin: .5rem 0 0; gap: .5rem; }
.leaf .countdown-num   { font-size: 1.3rem; }
.leaf .countdown-label { font-size: .52rem; }
.leaf .countdown-sep   { font-size: 1.1rem; }

/* Corazones latiendo */
.ts-heart {
	display: inline-block;
	animation: ts-pulse 1.4s ease-in-out infinite;
}

@keyframes ts-pulse {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.28); }
}

.ts-heartbeat { font-size: 1.3rem; color: var(--color-rose); }


/* ─────────────────────────────────────────────────────
   8. PISTAS PARA PASAR / VOLVER LA PÁGINA
───────────────────────────────────────────────────── */
.turn-hint,
.page-num,
.swipe-hint,
.edge-arrow {
	position: absolute;
	z-index: 60;
	transition: opacity .5s ease;
}

.turn-hint {
	bottom: 12px;
	display: inline-flex;
	align-items: center;
	gap: .3rem;
	padding: .3rem .2rem;
	border: none;
	background: none;
	font-family: var(--font-body);
	font-size: .6rem;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--color-gold-deep);
	cursor: pointer;
}

.turn-prev { left: 16px; }

/* "Pasa la página": botón dorado más grande, con brillo que late y un destello
   que lo recorre, para que se note que hay más contenido */
.turn-next {
	right: 18px;
	bottom: 10px;
	gap: .4rem;
	padding: .45rem .8rem .45rem .95rem;
	overflow: hidden;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold) 55%, var(--color-gold-deep));
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .1em;
	color: #fff;
	text-shadow: 0 1px 2px rgba(15, 28, 46, .25);
	box-shadow: 0 2px 8px rgba(15, 28, 46, .18);
	animation: next-glow 2.4s ease-in-out infinite;
}

.turn-next .turn-arrow { font-size: 1.25rem; }

.turn-next::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: -60%;
	width: 40%;
	background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
	transform: skewX(-20deg);
	animation: next-shine 3.2s ease-in-out infinite;
	pointer-events: none;
}

.turn-next:hover { filter: brightness(1.06); }

/* Barrita que se llena mientras corre el pase automático (js/book.js) */
.turn-next::before {
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	height: 2px;
	width: 100%;
	background: rgba(255, 255, 255, .75);
	transform: scaleX(0);
	transform-origin: left center;
	pointer-events: none;
}

.turn-next.auto-run::before { animation: auto-fill var(--auto-ms, 15s) linear forwards; }

@keyframes auto-fill {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

@keyframes next-glow {
	0%, 100% { box-shadow: 0 2px 8px rgba(15, 28, 46, .18), 0 0 0 0 rgba(200, 168, 106, .55); }
	50%      { box-shadow: 0 2px 10px rgba(15, 28, 46, .22), 0 0 0 7px rgba(200, 168, 106, 0); }
}

@keyframes next-shine {
	0%, 55% { left: -60%; }
	100%    { left: 130%; }
}

.turn-arrow {
	display: inline-block;
	font-size: 1.05rem;
	line-height: 1;
	animation: fly-right 1.6s ease-in-out infinite;
}

.turn-prev .turn-arrow { animation-name: fly-left; }

@keyframes fly-right {
	0%, 100% { transform: translateX(0);   opacity: .5; }
	50%      { transform: translateX(5px); opacity: 1; }
}

@keyframes fly-left {
	0%, 100% { transform: translateX(0);    opacity: .5; }
	50%      { transform: translateX(-5px); opacity: 1; }
}

/* Centrados con márgenes automáticos (no translateX(-50%), que puede dejar el texto
   en medio píxel y verse borroso en pantallas móviles) */
.page-num {
	bottom: 16px;
	left: 0;
	right: 0;
	width: max-content;
	margin: 0 auto;
	font-family: var(--font-display);
	font-style: italic;
	font-size: .7rem;
	color: rgba(156, 124, 66, .8);
	pointer-events: none;
}

/* Flechitas que vuelan a media altura en los bordes */
.edge-arrow {
	top: 50%;
	font-family: var(--font-display);
	font-size: 1.7rem;
	line-height: 1;
	color: var(--color-gold);
	pointer-events: none;
	text-shadow: 0 1px 4px rgba(15, 28, 46, .2);
}

.edge-next { right: 4px;  animation: edge-fly-right 2.2s ease-in-out infinite; }
.edge-prev { left: 6px;   animation: edge-fly-left 2.2s ease-in-out infinite; }

@keyframes edge-fly-right {
	0%   { transform: translate(-10px, -50%); opacity: 0; }
	40%  { opacity: .85; }
	100% { transform: translate(4px, -50%);   opacity: 0; }
}

@keyframes edge-fly-left {
	0%   { transform: translate(10px, -50%); opacity: 0; }
	40%  { opacity: .6; }
	100% { transform: translate(-4px, -50%); opacity: 0; }
}

.swipe-hint {
	bottom: 34px;
	left: 0;
	right: 0;
	width: max-content;
	margin: 0 auto;
	padding: .15rem .6rem;
	border-radius: 10px;
	background: rgba(248, 241, 234, .9);
	font-family: var(--font-body);
	font-size: .58rem;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--color-gold-deep);
	pointer-events: none;
	opacity: 0;
	animation: bob 1.6s ease-in-out infinite;
}

.swipe-hint.show { opacity: 1; }

@keyframes bob {
	0%, 100% { margin-bottom: 0; }
	50%      { margin-bottom: -4px; }
}

/* Qué se ve según dónde vamos */
.book-stage.is-cover .turn-hint,
.book-stage.is-cover .page-num,
.book-stage.is-cover .edge-arrow,
.book-stage.is-cover .bookmark,
.book-stage.is-cover .swipe-hint,
.book-stage.is-first .turn-prev,
.book-stage.is-first .edge-prev,
.book-stage.is-end .turn-next,
.book-stage.is-end .edge-next,
.book-stage.is-end .page-num,
.book-stage.is-end .swipe-hint,
.book-stage.is-busy .swipe-hint {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* Polvo de hada que suelta la hoja al pasar */
.fairy-dust {
	position: absolute;
	z-index: 80;
	width: var(--size, 4px);
	height: var(--size, 4px);
	border-radius: 50%;
	background: #ffe9b8;
	box-shadow: 0 0 6px 2px rgba(255, 220, 150, .7);
	pointer-events: none;
	opacity: 0;
	animation: dust 1.8s ease-out forwards;
}

@keyframes dust {
	0%   { opacity: 0; transform: translate(0, 0) scale(.4); }
	20%  { opacity: 1; }
	100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); }
}


/* ─────────────────────────────────────────────────────
   9. MARCAPÁGINAS (ÍNDICE)
───────────────────────────────────────────────────── */
.bookmark {
	position: absolute;
	top: 0;
	right: 22px;
	z-index: 70;
	transition: opacity .5s ease;
}

.bookmark-ribbon {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	width: 26px;
	height: 80px;
	padding: 9px 0 0;
	border: none;
	background: linear-gradient(to right, #b95563, var(--color-rose) 50%, #b95563);
	clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 88%, 0 100%);
	box-shadow: 0 2px 4px rgba(15, 28, 46, .25);
	cursor: pointer;
	transform-origin: top center;
	animation: sway 4s ease-in-out infinite;
}

.bookmark-ribbon span {
	writing-mode: vertical-rl;
	font-family: var(--font-body);
	font-weight: 700;
	font-size: .56rem;
	letter-spacing: .08em;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
	color: #fff;
}

@keyframes sway {
	0%, 100% { transform: rotate(0); }
	50%      { transform: rotate(3deg); }
}

.bookmark-panel {
	position: absolute;
	top: 84px;
	right: -10px;
	width: 200px;
	padding: .6rem .4rem;
	border: 1px solid var(--color-gold-light);
	border-radius: 10px;
	background: var(--paper-texture), var(--color-paper);
	box-shadow: 0 10px 30px rgba(15, 28, 46, .25);
	opacity: 0;
	transform: translateY(-8px);
	pointer-events: none;
	transition: opacity .35s ease, transform .35s ease;
}

.bookmark.open .bookmark-panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.bookmark-panel ol,
.bookmark-panel ul { counter-reset: page; }

.bookmark-panel li { counter-increment: page; }

.bookmark-panel a {
	display: flex;
	gap: .6rem;
	padding: .38rem .6rem;
	border-radius: 6px;
	font-family: var(--font-accent);
	font-style: italic;
	font-size: .82rem;
	color: var(--color-ink-soft);
	transition: background .2s, color .2s;
}

.bookmark-panel a::before {
	content: counter(page);
	min-width: 1em;
	font-style: normal;
	color: var(--color-gold);
}

.bookmark-panel a:hover { background: var(--color-rose-pale); color: var(--color-rose); }


/* ─────────────────────────────────────────────────────
   10. BOTÓN DE AUDIO
───────────────────────────────────────────────────── */
#audio-toggle {
	top: 14px;
	left: 14px;
	right: auto;
	bottom: auto;
	width: 34px;
	height: 34px;
	z-index: 900;
	font-size: .9rem;
	transition: opacity .6s ease, transform .2s;
}

body.book-closed #audio-toggle { opacity: 0; pointer-events: none; }

@media (max-width: 899px) {
	/* En móvil queda sobre la esquina superior izquierda de la página */
	#audio-toggle { top: 20px; left: 20px; background: rgba(248, 241, 234, .85); }
}


/* ─────────────────────────────────────────────────────
   11. MOVIMIENTO REDUCIDO
───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	:root { --turn-time: .45s; }

	.ts-heart,
	.turn-arrow,
	.edge-arrow,
	.dog-ear,
	.fireflies i,
	.cover-frame::after,
	.cover-tap,
	.cover-monogram,
	.ts-monogram,
	.ts-date-flower,
	.bookmark-ribbon,
	.btn-glow,
	.swipe-hint,
	.turn-next,
	.turn-next::after,
	.sky,
	.sky::before { animation: none; }

	.leaf.peek { animation: none; }
}
