:root {
  --paper: #f4eee2;
  --paper-2: #ece4d3;
  --desk: #2a2622;
  --ink: #1f2e86;
  --ink-soft: rgba(31, 46, 134, 0.62);
  --red: #b3262e;
  --green: #4d6a1c;
  --hw: 'Caveat', 'Bradley Hand', cursive;
  --serif: 'Bodoni Moda', 'Didot', 'Bodoni 72', serif;
  --col: min(100vw, 520px);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32  0 0 0 0 .27  0 0 0 0 .18  0 0 0 .085 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

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

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

body {
  background: var(--desk);
  color: var(--ink);
  font-family: var(--hw);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.sheet {
  position: relative;
  width: var(--col);
  margin: 0 auto;
  background-color: var(--paper);
  background-image: var(--grain);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  overflow: clip; /* pas hidden : hidden casserait le position: sticky des étoiles */
}

canvas.ink { display: block; mix-blend-mode: multiply; }

/* ---------- Couverture ---------- */

.cover {
  position: relative;
  height: max(100svh, 640px);
  max-height: 980px;
  padding: calc(env(safe-area-inset-top) + 18px) 18px 0;
}

.issue {
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0;
  animation: fade 1.2s 0.2s forwards;
}

.masthead {
  font-family: var(--serif);
  font-weight: 600;
  font-optical-sizing: auto;
  font-size: calc(var(--col) * 0.245);
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-align: center;
  margin-top: 6px;
  color: var(--ink);
  opacity: 0;
  animation: masthead 1.6s 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.portrait-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top) + 18px + var(--col) * 0.2);
  bottom: 0;
}

.portrait {
  position: absolute;
  right: -2%;
  bottom: 0;
  /* largeur et hauteur posées en JS (garder le ratio de la photo) */
}

.cover-doodles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.coverline {
  position: absolute;
  font-size: 25px;
  line-height: 0.95;
  opacity: 0;
  transform: rotate(-3deg);
}
.coverline i { font-style: normal; color: var(--red); }
.coverline .tiny {
  display: block;
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.c1 { left: 18px; top: 38%; animation: fade 1s 3.4s forwards; }
.c2 { left: 18px; top: 58%; transform: rotate(2deg); animation: fade 1s 4.2s forwards; }
.c3 { left: 18px; right: 46%; bottom: 8%; font-size: 23px; transform: rotate(-1deg); animation: fade 1s 5s forwards; }

.turn {
  position: absolute;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  font-size: 19px;
  opacity: 0;
  animation: fade 1s 6s forwards, nudge 2.4s 7s ease-in-out infinite;
}
.turn::after { content: ' ↓'; }

@keyframes fade { to { opacity: 1; } }
@keyframes masthead {
  from { opacity: 0; letter-spacing: 0.25em; filter: blur(6px); }
  to { opacity: 1; letter-spacing: 0.01em; filter: blur(0); }
}
@keyframes nudge { 50% { transform: translateY(5px); } }

/* ---------- Pages ---------- */

.page {
  position: relative;
  padding: 18vh 26px 12vh;
}

.rubrique {
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 26px;
  display: inline-block;
  border-bottom: 1px solid var(--ink-soft);
  padding-bottom: 4px;
}

.hw {
  font-size: clamp(27px, 7.6vw, 34px);
  line-height: 1.12;
  margin-bottom: 0.9em;
}
.hw.quote { padding-left: 18px; border-left: 2px solid var(--ink-soft); color: var(--red); }
.hw.big { font-size: clamp(32px, 9vw, 40px); }

.red { color: var(--red); }

.serif {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(40px, 12vw, 58px);
  line-height: 0.98;
  margin-bottom: 28px;
}
.serif i { font-weight: 400; }

.small {
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.02em;
  opacity: 0.75;
  margin-top: 28px;
}

/* Écriture : les lettres apparaissent une à une. */
[data-write] .ch { opacity: 0; transition: opacity 0.12s linear; }
[data-write].on .ch { opacity: 1; }
[data-write] .w { white-space: nowrap; }

/* ---------- Étoiles ---------- */

.stars { position: relative; height: 280vh; }
.stars .sticky {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}
.stars canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cap {
  position: absolute;
  left: 26px;
  right: 26px;
  font-size: clamp(30px, 8.6vw, 38px);
  line-height: 1.05;
  pointer-events: none;
}
.cap1 { top: 14%; }
.cap2 { bottom: 14%; text-align: right; opacity: 0; }

/* ---------- Coupe ---------- */

.detail-wrap { position: relative; margin: 6px -26px 22px; }
.detail { width: 100%; height: auto; aspect-ratio: 304 / 330; }
.detail-doodles { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- Rome ---------- */

.map { width: calc(100% + 52px); margin: 0 -26px 18px; height: auto; aspect-ratio: 390 / 470; }

.carnet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 6px;
  padding: 10px 16px 10px 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 27px;
  line-height: 1;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.carnet-link b { font-weight: 700; color: var(--red); }
.carnet-link:active { transform: scale(0.98) rotate(-1deg); }
.carnet-icon { width: 76px; height: 76px; flex: none; }

/* ---------- Fin ---------- */

.fin { padding-top: 16vh; padding-bottom: 8vh; }
.jetaime {
  font-size: clamp(64px, 19vw, 92px);
  color: var(--red);
  font-style: italic;
  margin: 10px 0 64px;
}
.next { margin-bottom: 70px; }
.si {
  position: relative;
  width: 132px;
  height: 92px;
  border: 0;
  background: none;
  font-family: var(--hw);
  font-size: 44px;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.si canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.si span { position: relative; }
.si:active { transform: scale(0.96); }
.answer { margin-top: 14px; opacity: 0; transition: opacity 0.8s; color: var(--red); }
.answer.on { opacity: 1; }

.signature {
  font-size: 54px;
  text-align: right;
  padding-right: 6px;
  transform: rotate(-4deg);
}
.signature-line { width: 220px; height: 36px; margin: -6px 0 0 auto; }

.colophon {
  padding: 40px 26px calc(env(safe-area-inset-bottom) + 90px);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0.6;
}

/* ---------- Musique & cœurs ---------- */

.music {
  position: fixed;
  right: max(12px, calc((100vw - var(--col)) / 2 + 12px));
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: rgba(244, 238, 226, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s;
}
.music.show { opacity: 1; transform: none; pointer-events: auto; }
.music canvas { width: 100%; height: 100%; }

.hearts {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-delay: 0s !important; transition-duration: 0.01s !important; }
}
