/* ============================================================
   Our Adventure Book ♡ — estilos
   1. Fuentes y colores
   2. Base y libro
   3. Páginas y transiciones
   4. Texto
   5. Polaroids, cinta, avatares, recortes vintage y doodles
   6. Botones y navegación
   7. Una sección por página especial
   8. Responsive
   ============================================================ */


/* ---------- 1. FUENTES Y COLORES ---------- */

@font-face {
  font-family: 'Caveat';
  src: url('assets/fonts/Caveat-variable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('assets/fonts/IMFellEnglish-normal.woff2') format('woff2');
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('assets/fonts/IMFellEnglish-italic.woff2') format('woff2');
  font-style: italic;
  font-display: swap;
}

:root {
  /* Paleta */
  --cream: #fbf5e9;
  --ivory: #f6eedf;
  --beige: #e9dcc6;
  --kraft: #c9ab85;
  --rose: #d9b3ac;
  --rose-soft: #ecd5cd;
  --burgundy: #7a2e3a;
  --brown: #7a5a3f;
  --ink: #3b2a1f;
  --heart: #b5484f;
  --photo-white: #fbf6ea;

  /* Papeles (vienen de la plantilla) */
  --paper: #e8d4b0 url('assets/decorations/papel.jpg') center / cover;
  --cardboard: #b9a28c url('assets/decorations/kraft.jpg') center / cover;

  /* Fondo: crema cálido que se oscurece un poquito hacia el final */
  --desk: #f2e7d3;
  /* Detallitos dibujados en el fondo (corazones, destellos, puntitos) */
  --desk-doodles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E %3Cg fill='none' stroke='%239a7556' stroke-opacity='.32' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E %3Cpath transform='translate(28 30) rotate(-14 10 10) scale(.22)' d='M50 86 C28 70 9 52 12 31 C15 13 39 10 49 30 C56 10 84 9 89 29 C93 50 71 70 50 86 Z'/%3E %3Cpath transform='translate(212 148) rotate(10 8 8) scale(.16)' d='M50 86 C28 70 9 52 12 31 C15 13 39 10 49 30 C56 10 84 9 89 29 C93 50 71 70 50 86 Z'/%3E %3Cpath transform='translate(120 238) rotate(-6 6 6) scale(.12)' d='M50 86 C28 70 9 52 12 31 C15 13 39 10 49 30 C56 10 84 9 89 29 C93 50 71 70 50 86 Z'/%3E %3C/g%3E %3Cg fill='%23c9727a' fill-opacity='.22'%3E %3Cpath transform='translate(30 32) rotate(-14 10 10) scale(.2)' d='M50 86 C28 70 9 52 12 31 C15 13 39 10 49 30 C56 10 84 9 89 29 C93 50 71 70 50 86 Z'/%3E %3Cpath transform='translate(214 150) rotate(10 8 8) scale(.14)' d='M50 86 C28 70 9 52 12 31 C15 13 39 10 49 30 C56 10 84 9 89 29 C93 50 71 70 50 86 Z'/%3E %3C/g%3E %3Cg fill='%23b89065' fill-opacity='.22'%3E %3Cpath transform='translate(196 26) scale(.2)' d='M50 8 C53 36 62 46 92 50 C62 54 53 64 50 94 C46 64 38 54 8 50 C38 46 46 36 50 8 Z'/%3E %3Cpath transform='translate(64 150) scale(.13)' d='M50 8 C53 36 62 46 92 50 C62 54 53 64 50 94 C46 64 38 54 8 50 C38 46 46 36 50 8 Z'/%3E %3Cpath transform='translate(258 262) scale(.11)' d='M50 8 C53 36 62 46 92 50 C62 54 53 64 50 94 C46 64 38 54 8 50 C38 46 46 36 50 8 Z'/%3E %3C/g%3E %3Cg fill='none' stroke='%239a7556' stroke-opacity='.26' stroke-width='1.5' stroke-linecap='round' stroke-dasharray='2 6'%3E %3Cpath d='M96 96 C130 70 160 110 190 88'/%3E %3Cpath d='M10 250 C40 226 62 268 92 246'/%3E %3C/g%3E %3Cg fill='%239a7556' fill-opacity='.26'%3E %3Ccircle cx='150' cy='30' r='2'/%3E%3Ccircle cx='160' cy='36' r='1.4'/%3E%3Ccircle cx='246' cy='88' r='1.8'/%3E %3Ccircle cx='36' cy='112' r='1.5'/%3E%3Ccircle cx='176' cy='204' r='2'/%3E%3Ccircle cx='280' cy='190' r='1.4'/%3E %3C/g%3E%3C/svg%3E");

  /* Letras */
  --hand: 'Caveat', 'Bradley Hand', 'Segoe Print', cursive;
  --print: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --text-size: clamp(1.35rem, 3.5vh, 1.75rem);

  /* Textura de papel, muy sutil */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .34 0 0 0 0 .22 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Borde de papel rasgado */
  --torn: polygon(0.6% 2%, 8% 0.4%, 17% 1.6%, 28% 0.2%, 41% 1.4%, 55% 0.3%, 68% 1.7%, 81% 0.4%, 92% 1.4%, 99.6% 0.5%,
    99% 14%, 99.8% 31%, 99.1% 49%, 99.9% 66%, 99.2% 83%, 99.7% 99%,
    90% 98.2%, 77% 99.7%, 63% 98.4%, 49% 99.6%, 35% 98.3%, 21% 99.5%, 9% 98.6%, 0.4% 99.4%,
    1% 84%, 0.2% 66%, 0.9% 47%, 0.2% 29%, 0.8% 14%);
}

/* Hacia el final la mesa se oscurece un poquito, sin drama */
body[data-mood='tender'] { --desk: #efe1ca; }
body[data-mood='quiet']  { --desk: #e9d7bd; }
body[data-mood='oath']   { --desk: #e2cbae; }
body[data-mood='reveal'] { --desk: #d3b592; }


/* ---------- 2. BASE Y LIBRO ---------- */

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

html, body {
  height: 100%;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--desk);
  background-image: var(--desk-doodles), var(--grain);
  color: var(--ink);
  font-family: var(--hand);
  font-size: var(--text-size);
  line-height: 1.26;
  overflow: hidden;
  transition: background-color 2.4s ease;
  -webkit-font-smoothing: antialiased;
}

.desk {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: max(14px, env(safe-area-inset-top)) 16px max(6px, env(safe-area-inset-bottom));
}

.book {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 1080px;
  max-height: 700px;
  min-height: 0;
  background: var(--paper);
  border-radius: 6px 9px 7px 10px / 9px 6px 10px 7px;
  /* Las hojas de abajo, no del todo alineadas */
  box-shadow:
    3px 3px 0 #dcc49f,
    6px 6px 0 #ccb08a,
    0 16px 32px rgba(74, 48, 36, .28);
}


/* ---------- 3. PÁGINAS Y TRANSICIONES ---------- */

.page {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden auto;
  border-radius: inherit;
}

.page.is-active { display: grid; }

.page[data-enter='forward'] { animation: page-in-forward .52s ease both; }
.page[data-enter='back']    { animation: page-in-back .52s ease both; }
.page[data-leave='forward'] { animation: page-out-forward .32s ease both; }
.page[data-leave='back']    { animation: page-out-back .32s ease both; }

@keyframes page-in-forward {
  from { opacity: 0; transform: translateX(16px) rotate(.5deg); }
}
@keyframes page-in-back {
  from { opacity: 0; transform: translateX(-16px) rotate(-.5deg); }
}
@keyframes page-out-forward {
  to { opacity: 0; transform: translateX(-12px) rotate(-.5deg); }
}
@keyframes page-out-back {
  to { opacity: 0; transform: translateX(12px) rotate(.5deg); }
}

/* Libro abierto: dos hojas con un doblez suave al centro */
.page--spread {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
}
.page--spread::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 26px);
  width: 52px;
  pointer-events: none;
  background: linear-gradient(90deg,
    transparent,
    rgba(122, 92, 66, .07) 42%,
    rgba(122, 92, 66, .17) 50%,
    rgba(122, 92, 66, .05) 58%,
    transparent);
}
.page--wide-left { grid-template-columns: 1.45fr 1fr; }

.leaf {
  position: relative;
  min-height: 0;
  padding: clamp(1.1rem, 4vh, 2.4rem) clamp(1.4rem, 3.4vw, 3rem);
}
.leaf--center {
  display: flex;
  flex-direction: column;
}
/* Centra sin cortar la parte de arriba cuando el texto no cabe */
.leaf--center::before,
.leaf--center::after {
  content: '';
  flex: 1 0 0;
}
.leaf--collage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3.5vh, 2rem) clamp(1rem, 2vw, 1.6rem);
}
.leaf--tight p { margin-block: .34em; }


/* ---------- 4. TEXTO ---------- */

p { margin: .5em 0; }

.title {
  margin: 0 0 .5em;
  color: var(--burgundy);
  font-family: var(--print);
  font-weight: 400;
  font-style: italic;
  font-size: 1.32em;
  line-height: 1.12;
  letter-spacing: .005em;
}

.big-hand {
  color: var(--burgundy);
  font-size: 1.3em;
  font-weight: 700;
}

.emphasis {
  color: var(--burgundy);
  font-weight: 600;
}
.emphasis--large {
  font-size: 1.5em;
  font-weight: 700;
  transform: rotate(-1deg);
}

/* Frases cortitas, muy juntas */
.stanza { margin: .4em 0 .4em .3em; }
.stanza p { margin: .04em 0; }


/* ---------- 5. POLAROIDS, CINTA, AVATARES Y DOODLES ---------- */

/* Caja donde se acomodan las fotos.
   Dentro, cada elemento se ubica con --x, --y, --w (en %) y --tilt. */
.collage {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
}

.polaroid {
  position: relative;
  margin: 0;
  padding: .42em .42em 1.5em;
  background: var(--photo-white);
  box-shadow: 0 3px 9px rgba(74, 48, 36, .22);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .35s ease;
}
.polaroid:hover { transform: rotate(calc(var(--tilt, 0deg) * .55)) translateY(-3px); }
.polaroid figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: .12em;
  text-align: center;
  font-size: .86em;
  color: var(--brown);
}

.collage > .polaroid,
.collage > .avatar {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
}

/* Espacio para la foto mientras no exista la imagen real */
.photo-placeholder,
.photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
}
.photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .6em;
  text-align: center;
  font-size: .9em;
  line-height: 1.1;
  color: var(--brown);
  background-color: var(--rose-soft);
  background-image: var(--grain);
}
/* Para mover el encuadre de una foto: cambia object-position */
.photo {
  object-fit: cover;
  object-position: center 35%;
}
.cover__photo .photo-placeholder,
.cover__photo .photo { aspect-ratio: 3 / 4; }

/* Foto pegada con esquinas de álbum (como en la plantilla) */
.polaroid.is-mounted { padding: .32em; }
.is-mounted figcaption { display: none; }
.corners {
  --corner: #2b211b;
  --corner-size: 1.5em;
  position: absolute;
  inset: -3px;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(135deg, var(--corner) 50%, transparent 50%) top left / var(--corner-size) var(--corner-size) no-repeat,
    linear-gradient(225deg, var(--corner) 50%, transparent 50%) top right / var(--corner-size) var(--corner-size) no-repeat,
    linear-gradient(45deg, var(--corner) 50%, transparent 50%) bottom left / var(--corner-size) var(--corner-size) no-repeat,
    linear-gradient(315deg, var(--corner) 50%, transparent 50%) bottom right / var(--corner-size) var(--corner-size) no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3));
}

/* Recortes vintage: sellos, sobre, hoja, pluma...
   Se ubican con --top/--right/--bottom/--left, --w y --r (giro). */
.deco {
  position: absolute;
  z-index: 1;
  top: var(--top, auto);
  right: var(--right, auto);
  bottom: var(--bottom, auto);
  left: var(--left, auto);
  width: var(--w, 5rem);
  height: auto;
  transform: rotate(var(--r, 0deg));
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(60, 38, 24, .22));
}
.collage > .deco { width: var(--w); }

/* Cinta adhesiva */
.tape {
  position: absolute;
  z-index: 2;
  width: 4.4em;
  height: 1.3em;
  background-color: rgba(226, 209, 172, .78);
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .14) 0 2px, transparent 2px 6px);
  transform: rotate(var(--tape-tilt, -3deg));
  clip-path: polygon(0 0, 2.5% 16%, 0 33%, 2.5% 50%, 0 66%, 2.5% 83%, 0 100%,
    100% 100%, 97.5% 83%, 100% 66%, 97.5% 50%, 100% 33%, 97.5% 16%, 100% 0);
}
.tape--rose { background-color: rgba(217, 179, 172, .76); }

/* Avatares: siempre pequeños, las fotos mandan */
.avatar {
  display: block;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(74, 48, 36, .14));
}
[data-beats] .avatar { animation: none; }
.avatar--corner {
  position: absolute;
  right: clamp(.8rem, 2vw, 1.8rem);
  bottom: clamp(.6rem, 2vh, 1.2rem);
  width: clamp(5.2rem, 11vw, 7.6rem);
}

.doodle {
  fill: none;
  stroke: var(--burgundy);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}


/* ---------- 6. BOTONES Y NAVEGACIÓN ---------- */

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

/* Etiqueta de papel */
.btn-paper {
  align-self: flex-start;
  margin-top: .8em;
  padding: .36em 1em .42em;
  border: 0;
  border-radius: 3px 6px 4px 7px;
  background: var(--burgundy);
  color: var(--cream);
  font-size: 1.08em;
  font-weight: 600;
  box-shadow: 0 3px 6px rgba(74, 48, 36, .28);
  transform: rotate(-1deg);
  transition: transform .22s ease, box-shadow .22s ease;
}
.btn-paper:hover {
  transform: rotate(0) translateY(-2px);
  box-shadow: 0 5px 10px rgba(74, 48, 36, .3);
}
.btn-paper:active { transform: rotate(0) translateY(1px); }

.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1080px;
  min-height: 2.1rem;
  padding: .2rem .4rem 0;
  font-size: 1.3rem;
  color: var(--brown);
  transition: opacity .5s ease;
}
.nav.is-gone {
  opacity: 0;
  visibility: hidden;
  transition: opacity .6s ease, visibility 0s linear .6s;
}

.nav__btn {
  padding: .1rem .4rem;
  border: 0;
  background: none;
  color: #6f533d;
  font-weight: 600;
  opacity: .78;
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.nav__btn:hover { opacity: 1; transform: translateY(-1px); }
.nav__btn.is-hidden { visibility: hidden; opacity: 0; }

.nav__page {
  color: #6f533d;
  opacity: .78;
}

:focus-visible {
  outline: 2px dashed var(--burgundy);
  outline-offset: 3px;
}


/* ---------- 7. PÁGINAS ESPECIALES ---------- */

/* Portada */
.page--cover {
  grid-template-columns: 1.08fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2.2rem);
  padding: clamp(1.2rem, 4vh, 2.4rem) clamp(1.4rem, 4vw, 3.4rem);
  background: var(--cardboard);
}
.cover__label {
  position: relative;
  padding: clamp(1.1rem, 4vh, 2.2rem) clamp(1.2rem, 3vw, 2.4rem);
  filter: drop-shadow(0 3px 6px rgba(74, 48, 36, .24));
  transform: rotate(-1.2deg);
}
/* El papel rasgado va en una capa aparte para no recortar la cinta */
.cover__label::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--cream);
  background-image: var(--grain);
  clip-path: var(--torn);
  background: #f4e7cf url('assets/decorations/papel.jpg') center / 260% auto;
}
.cover__title {
  margin: 0;
  color: var(--burgundy);
  font-family: var(--print);
  font-weight: 400;
  font-size: clamp(2.4rem, 8.6vh, 3.9rem);
  line-height: .98;
  letter-spacing: .02em;
}
.cover__title span { display: block; }
/* Corazón dibujado a mano (portada y botón del juramento) */
.heart {
  overflow: visible;
  transform-origin: 50% 55%;
  animation: latido 3.4s ease-in-out infinite;
}
.heart__fill { fill: var(--heart); opacity: .9; }
.heart__line {
  fill: none;
  stroke: var(--burgundy);
  stroke-width: 4;
  stroke-linecap: round;
}
.heart__shine {
  fill: none;
  stroke: #fff6ee;
  stroke-width: 5;
  stroke-linecap: round;
  opacity: .75;
}
.cover__heart {
  width: .78em;
  height: .78em;
  margin-left: .06em;
  vertical-align: -.04em;
}
/* El mismo corazón, dentro de títulos, frases y botones */
.heart--inline {
  width: .8em;
  height: .8em;
  margin-left: .04em;
  vertical-align: -.1em;
}
.btn-paper .heart__fill,
.btn-oath .heart__fill { fill: #f2c4c6; opacity: 1; }
.btn-paper .heart__line { stroke: var(--cream); }
@keyframes latido {
  0%, 60%, 100% { transform: scale(1) rotate(-6deg); }
  8%  { transform: scale(1.12) rotate(-6deg); }
  16% { transform: scale(1) rotate(-6deg); }
  24% { transform: scale(1.07) rotate(-6deg); }
  32% { transform: scale(1) rotate(-6deg); }
}
.cover__squiggle {
  display: block;
  width: 9em;
  height: 1em;
  margin: .3em 0 .1em;
  stroke-width: 2.2;
}
.cover__names {
  margin: .2em 0 0;
  font-size: 1.5em;
  font-weight: 700;
}
.cover__tagline {
  margin: 0;
  font-family: var(--print);
  font-style: italic;
  font-size: .86em;
  color: var(--brown);
}
.cover__photo {
  position: relative;
  max-width: min(100%, 44vh);
  justify-self: center;
  width: 100%;
}
.cover__stamp {
  --top: 4%;
  --right: 3%;
  --w: clamp(3.4rem, 8vw, 5.4rem);
  --r: 7deg;
}
.cover__twine {
  position: absolute;
  z-index: 3;
  top: -1.1em;
  left: 50%;
  width: 62%;
  transform: translateX(-50%) rotate(-3deg);
  pointer-events: none;
}
.cover__avatar {
  position: absolute;
  right: -7%;
  bottom: -5%;
  width: 34%;
}

/* Página 6: la promesa (una sola hoja, centrada) */
.page--promise {
  place-items: center;
  padding: clamp(1.4rem, 5vh, 3rem) clamp(1.4rem, 8vw, 7rem);
}
.promise {
  position: relative;
  z-index: 1;
  max-width: 30em;
  text-align: center;
  font-size: 1.12em;
  line-height: 1.32;
}
.promise .emphasis { font-size: 1.12em; }
.promise__twine {
  display: block;
  width: 8.5em;
  margin: .5em auto 0;
}
.promise .btn-paper {
  display: block;
  margin: .3em auto 0;
}
.promise__avatar {
  position: absolute;
  right: clamp(.8rem, 3vw, 2.4rem);
  bottom: clamp(.6rem, 2vh, 1.4rem);
  width: clamp(5.5rem, 12vw, 8.5rem);
}

/* Página 7: lista que se puede marcar y completar */
.checklist__hint {
  margin: -.45em 0 .35em;
  font-size: .78em;
  color: var(--brown);
}
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 1.22;
}
.checklist li { margin: .16em 0; }
.check {
  display: flex;
  align-items: flex-start;
  gap: .45em;
  cursor: pointer;
}
/* Cajita dibujada a mano */
.check__box {
  flex: none;
  font-size: inherit;
  width: .84em;
  height: .84em;
  margin: .18em 0 0 .1em;
  border: 2px solid var(--ink);
  border-radius: 2px 4px 3px 5px / 4px 2px 5px 3px;
  background: transparent center / 135% no-repeat;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transform: rotate(-2deg);
  transition: transform .2s ease;
}
.checklist li:nth-child(even) .check__box { transform: rotate(3deg); }
.check__box:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 13 C6 15 8 18 9 20 C12 13 16 7 23 2' fill='none' stroke='%237a2e3a' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  animation: marcado .35s ease;
}
@keyframes marcado {
  50% { transform: scale(1.3) rotate(-6deg); }
}
.check__label { transition: color .3s ease; }
.check__box:checked + .check__label,
.check__box:checked + .check__text {
  color: var(--brown);
  text-decoration: line-through;
  text-decoration-color: var(--burgundy);
  text-decoration-thickness: 2px;
}
/* Líneas en blanco para escribir */
.check--write {
  display: flex;
  align-items: flex-start;
  gap: .45em;
}
.check__text {
  flex: 1;
  min-width: 0;
  margin-right: 10%;
  padding: 0 .1em;
  border: 0;
  border-bottom: 2px solid rgba(59, 42, 31, .45);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.15;
  outline: none;
}
.check__text::placeholder { color: rgba(122, 90, 63, .5); }
.check__text:focus { border-bottom-color: var(--burgundy); }

.leaf--walk::after { display: none; }
.walkers {
  position: relative;
  margin-top: 1.2em;
}
.walkers .avatar {
  position: relative;
  width: clamp(8rem, 26vh, 13rem);
  margin-left: auto;
  margin-right: 8%;
}
.doodle--trail {
  position: absolute;
  left: -4%;
  bottom: 6%;
  width: 92%;
  height: 3.2em;
  stroke: var(--brown);
  stroke-opacity: .4;
  stroke-width: 2;
  stroke-dasharray: 3 11;
}

/* Página 8: el mensaje de Ellie */
.scrap-quote {
  position: relative;
  margin: .8em 0 .2em;
  padding: 1.3em 1.9em 1.4em;
  background: url('assets/decorations/etiqueta.png') center / 100% 100% no-repeat;
  color: var(--burgundy);
  font-family: var(--print);
  font-style: italic;
  font-size: 1.04em;
  line-height: 1.3;
  text-align: center;
  transform: rotate(-1.2deg);
  filter: drop-shadow(0 2px 4px rgba(74, 48, 36, .2));
}

/* Páginas 9 y 10: frases que aparecen una por una */
/* Todas las páginas: cada elemento aparece uno por uno (lo ordena script.js) */
[data-beats] .beat {
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition: opacity .75s ease, translate .75s ease;
}
[data-beats] .beat.is-shown {
  opacity: 1;
  translate: none;
  pointer-events: auto;
}
[data-beats] .avatar.beat { animation: none; }
.leaf--quiet { align-items: center; text-align: center; }
.beat--dots {
  margin: 0;
  color: var(--burgundy);
  font-size: 2em;
  letter-spacing: .14em;
}
.beat--turn {
  color: var(--burgundy);
  font-size: 1.32em;
  font-weight: 700;
}

/* Página 10: el juramento */
.page--oath .leaf { transition: opacity 1.2s ease; }
.page--oath.is-fading .leaf { opacity: 0; }
.page--oath.is-fading::after { opacity: 0; transition: opacity 1.2s ease; }

.oath__name {
  margin: .2em 0 0;
  color: var(--burgundy);
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1;
}
.oath__call {
  margin: .1em 0 .5em;
  color: var(--burgundy);
  font-size: 1.2em;
  font-weight: 700;
}

/* Botón del juramento: un listón con puntas, costura y sello de cera */
.oath__action {
  margin-top: .25em;
  padding: 0 1.3em 0 1.6em;
}
.btn-oath {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--cream);
  transform: rotate(-1deg);
  filter: drop-shadow(0 5px 7px rgba(70, 25, 30, .3));
  transition: transform .3s ease;
}
/* Puntas del listón, detrás de la banda */
.btn-oath::before,
.btn-oath::after {
  content: '';
  position: absolute;
  top: .5em;
  bottom: -.5em;
  width: 2.4em;
  background: #5b1e29;
}
.btn-oath::before {
  left: -1.3em;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 34% 50%);
}
.btn-oath::after {
  right: -1.3em;
  clip-path: polygon(0 0, 100% 0, 66% 50%, 100% 100%, 0 100%);
}
.btn-oath__band {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  padding: .66em .9em .66em 1.9em;
  border-radius: 3px;
  background: linear-gradient(180deg, #974452 0%, #7a2e3a 48%, #67232f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 240, 235, .22), inset 0 -2px 0 rgba(0, 0, 0, .16);
}
/* Costura */
.btn-oath__band::before {
  content: '';
  position: absolute;
  inset: .3em;
  border: 1.5px dashed rgba(251, 245, 233, .58);
  border-radius: 2px;
  pointer-events: none;
}
.btn-oath__text {
  font-family: var(--print);
  font-size: .94em;
  letter-spacing: .04em;
  text-wrap: balance;
}
.btn-oath__heart {
  flex: none;
  width: 1.15em;
  height: 1.15em;
}
.btn-oath__heart .heart__fill { fill: #f2c4c6; opacity: 1; }
.btn-oath__heart .heart__line { stroke: var(--cream); }
.btn-oath__seal {
  position: absolute;
  z-index: 2;
  left: -1.3em;
  top: 50%;
  width: 3.2em;
  transform: translateY(-50%) rotate(-12deg);
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(40, 20, 15, .35));
  transition: transform .35s ease;
}
.btn-oath:hover:not(:disabled) { transform: rotate(0) translateY(-2px); }
.btn-oath:hover:not(:disabled) .btn-oath__seal { transform: translateY(-50%) rotate(-24deg) scale(1.05); }
.btn-oath:active:not(:disabled) { transform: rotate(0) translateY(1px); }
.btn-oath:disabled { cursor: default; }
.btn-oath:disabled .heart { animation: none; }

/* Secuencia final: la hoja queda en blanco */
.page--reveal {
  place-items: center;
  padding: 1.4rem clamp(1.4rem, 7vw, 6rem);
}
.reveal__stage {
  width: 100%;
  max-width: 40rem;
  text-align: center;
  transition: opacity 1s ease;
}
.reveal__stage.is-clearing { opacity: 0; }
.reveal__line {
  margin: .5em 0;
  font-size: 1.32em;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}
.reveal__line.is-shown {
  opacity: 1;
  transform: none;
}
.reveal__line--final {
  margin: 0;
  color: var(--burgundy);
  font-family: var(--print);
  font-size: clamp(2.5rem, 7vw, 4.4rem);
  line-height: 1.1;
  transition-duration: 1.8s;
}


/* ---------- 8. RESPONSIVE ---------- */

/* Tablet vertical y teléfono: una hoja a la vez, con scroll interno si hace falta */
@media (max-width: 760px) {
  :root { --text-size: 1.5rem; }

  .desk { padding-inline: 12px; }

  .page--spread.is-active,
  .page--cover.is-active {
    display: block;
  }
  .page--spread::after { display: none; }

  .leaf { padding: 1.3rem 1.3rem 1rem; }
  .leaf--center { display: block; }
  .leaf--center::before,
  .leaf--center::after { display: none; }
  .leaf--collage { padding: 1.4rem 1rem .4rem; }

  .collage { height: 128vw; max-height: 32rem; }
  .collage--five { height: 128vw; max-height: 34rem; }
  .collage--single { height: 118vw; max-height: 30rem; }

  .avatar--corner {
    position: static;
    width: 8rem;
    margin: .8rem .2rem 0 auto;
  }

  /* Los detallitos junto al texto ocupan su propio lugar para no tapar nada */
  .deco--roomy {
    position: relative;
    inset: auto;
    display: block;
    width: min(48%, 10.5rem);
    margin: .2rem auto 1rem;
  }
  .leaf > .deco--roomy:last-child,
  .leaf > p + .deco--roomy { margin: 1rem 0 0 auto; width: min(40%, 8.5rem); }
  .cover__stamp {
    --top: auto;
    --bottom: 9%;
    --right: 6%;
    --w: 3.8rem;
    --r: 10deg;
  }

  .page--cover { padding: 1.2rem 1.1rem 1.8rem; }
  .cover__photo { max-width: 11rem; margin: 1.2rem auto .3rem; }
  .cover__title { font-size: 2.55rem; }

  .btn-paper { display: block; padding-inline: .5em; font-size: .96em; }

  .page--promise.is-active { display: block; }
  .page--promise { padding: 1.8rem 1.3rem 1.2rem; }
  .promise__avatar { position: static; width: 7.5rem; margin: 1rem auto 0; }

  .walkers .avatar { width: 11rem; }

  .page--letter .leaf--quiet {
    display: flex;
    min-height: 14rem;
    padding-top: .4rem;
  }
  .page--letter .avatar--corner { margin-inline: auto; }

  .leaf--tight + .leaf--tight { padding-top: 0; }
}

/* Tablet vertical: el libro aprovecha el alto de la pantalla */
@media (min-width: 761px) and (max-aspect-ratio: 1/1) {
  .book { max-height: 940px; }
}

/* Pantallas muy bajitas (laptop pequeño con la barra del navegador) */
@media (max-height: 620px) and (min-width: 761px) {
  :root { --text-size: 1.28rem; }
  .avatar--corner { width: 4.8rem; }
  .deco--roomy { display: none; }
}

/* Si la persona prefiere menos movimiento, solo fades */
@media (prefers-reduced-motion: reduce) {
  .page[data-enter],
  .page[data-leave] { animation-name: page-fade; }
  @keyframes page-fade { 50% { opacity: .4; } }
  .polaroid:hover,
  .btn-paper:hover,
  .btn-oath:hover:not(:disabled) { transform: rotate(var(--tilt, 0deg)); }
  .heart,
  .check__box:checked { animation: none; }
}


/* ============================================================
   MÚSICA · bienvenida y botón para pausar
   ============================================================ */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background-color: var(--desk);
  background-image: var(--desk-doodles), var(--grain);
  text-align: center;
  transition: opacity .9s ease, visibility 0s linear .9s;
}
.welcome.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.welcome__text {
  margin: 0;
  max-width: 18ch;
  color: var(--ink);
  font-family: var(--hand);
  font-size: clamp(2.1rem, 8vw, 3.4rem);
  line-height: 1.1;
  animation: welcome-in 1.4s ease both;
}
.welcome__btn {
  align-self: center;
  margin-top: 0;
  font-family: var(--hand);
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  animation: welcome-in 1.4s ease .6s both;
}
@keyframes welcome-in {
  from { opacity: 0; translate: 0 8px; }
  to   { opacity: 1; translate: none; }
}

.music-toggle {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(122, 90, 63, .35);
  border-radius: 50%;
  background: rgba(251, 245, 233, .82);
  color: var(--burgundy);
  box-shadow: 0 2px 5px rgba(74, 48, 36, .16);
  opacity: .72;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .25s ease, transform .25s ease;
}
.music-toggle[hidden] { display: none; }
.music-toggle:hover,
.music-toggle:focus-visible { opacity: 1; transform: translateY(-1px); }
.music-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.music-toggle circle { fill: currentColor; }
.music-toggle__slash { display: none; }
.music-toggle.is-paused { color: var(--brown); opacity: .55; }
.music-toggle.is-paused .music-toggle__slash { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .welcome__text,
  .welcome__btn { animation: none; }
}

/* Página 4: el avatar con nuestra foto en la polaroid va un poco más grande */
.avatar--corner.avatar--polaroid { width: clamp(6.6rem, 11vw, 8.8rem); }
@media (max-width: 760px) {
  .avatar--corner.avatar--polaroid { width: 11.5rem; }
}
@media (max-height: 620px) and (min-width: 761px) {
  .avatar--corner.avatar--polaroid { width: 6.4rem; }
}
