/* ============================================================
   Joyeux 2 ans — nuit → crépuscule → aube au scroll
   --p    : progression brute du scroll (0 → 1), écrite par JS
   --dawn : progression easée du lever de soleil (0 → 1)
   Le dégradé passe par un crépuscule indigo/prune pour éviter
   les mélanges boueux entre le bleu nuit et l'or de l'aube.
   ============================================================ */

:root {
  /* Palette nuit */
  --night-top: #06181C;
  --night-mid: #0C3438;
  --night-sea: #0A2E31;
  /* Palette crépuscule (étape intermédiaire) */
  --twi-top: #2C2144;
  --twi-mid: #553052;
  --twi-sea: #63394E;
  /* Palette aube */
  --dawn-top: #F7C873;
  --dawn-hor: #F58C6E;
  /* Encres & accents */
  --paper: #F5EFE6;
  --gold: #F4B860;
  --coral: #EC6A5A;
  --ink-dark: #33160F;

  --p: 0;
  --dawn: 0;

  /* Deux étapes : nuit → crépuscule (dawn 0→.5), crépuscule → aube (dawn .5→1) */
  --dawn1: clamp(0, calc(var(--dawn) * 2), 1);
  --dawn2: clamp(0, calc((var(--dawn) - 0.5) * 2), 1);

  /* Le texte bascule clair → sombre quand l'aube s'installe.
     Bascule franche, calée entre la section indices et le reveal,
     pour ne jamais afficher une encre intermédiaire illisible. */
  --ink-t: clamp(0, calc((var(--dawn) - 0.82) * 12), 1);
  --ink: color-mix(in oklab, var(--paper), var(--ink-dark) calc(var(--ink-t) * 100%));
}

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

html {
  /* Pas de scroll-behavior:smooth ici : Chrome anime alors la restauration
     de scroll et la page dérive toute seule. Les scrolls doux passent par JS.
     Le scroll anchoring + reveals en translateY = même problème → désactivé. */
  overflow-anchor: none;
}

body {
  font-family: "Instrument Sans", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--night-mid); /* secours si color-mix indisponible */
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------
   Décor fixe
   ------------------------------------------------------------ */

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.sky {
  position: absolute;
  inset: 0;
  background-color: var(--night-mid);
  background-image: linear-gradient(
    to bottom,
    color-mix(in oklab,
      color-mix(in oklab, var(--night-top), var(--twi-top) calc(var(--dawn1) * 100%)),
      var(--dawn-top) calc(var(--dawn2) * 100%)) 0%,
    color-mix(in oklab,
      color-mix(in oklab, var(--night-mid), var(--twi-mid) calc(var(--dawn1) * 100%)),
      color-mix(in oklab, var(--dawn-top), var(--dawn-hor) 55%) calc(var(--dawn2) * 100%)) 58%,
    color-mix(in oklab,
      color-mix(in oklab, var(--night-sea), var(--twi-sea) calc(var(--dawn1) * 100%)),
      var(--dawn-hor) calc(var(--dawn2) * 100%)) 100%
  );
}

.stars {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 72%;
  fill: var(--paper);
  opacity: calc(1 - var(--dawn) * 1.5);
}
.stars .tw { animation: twinkle 3.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.05; } }

.sun {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(46vw, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in oklab, #B9C8CF, var(--gold) calc(var(--dawn) * 100%));
  transform: translate(-50%, calc(30vh - var(--dawn) * 58vh));
  opacity: calc(0.3 + var(--dawn) * 0.7);
}
.sun::before {
  content: "";
  position: absolute;
  inset: -95%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in oklab, rgba(185, 200, 207, 0.4), rgba(244, 184, 96, 0.55) calc(var(--dawn) * 100%)) 0%,
    transparent 62%
  );
}

.mountains {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  height: min(36vh, 340px);
  /* Opaque : sinon le soleil transparaît à travers la silhouette */
}
.mountains .m1 { fill: color-mix(in oklab, #0E3236, #7A4636 calc(var(--dawn) * 70%)); }
.mountains .m2 { fill: color-mix(in oklab, #0A272B, #4A2620 calc(var(--dawn) * 80%)); }
.mountains .m3 { fill: color-mix(in oklab, #071D20, #2B140F calc(var(--dawn) * 90%)); }

.bloom {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(
    60% 52% at 50% 70%,
    rgba(244, 184, 96, 0.55),
    rgba(245, 140, 110, 0.28) 45%,
    transparent 72%
  );
}
body.climax .bloom { animation: bloom 2.6s ease-out forwards; }
@keyframes bloom {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Cœurs flottants discrets, en fond */
.floaties { position: absolute; inset: 0; }
.floatie {
  position: absolute;
  bottom: -6vh;
  left: var(--x);
  font-style: normal;
  font-size: calc(15px * var(--s));
  color: color-mix(in oklab, var(--coral), var(--gold) var(--mix, 30%));
  opacity: 0;
  animation: rise var(--dur) linear both;
}
@keyframes rise {
  0%   { transform: translate(0, 0) rotate(-10deg); opacity: 0; }
  12%  { opacity: var(--o, 0.35); }
  85%  { opacity: calc(var(--o, 0.35) * 0.6); }
  100% { transform: translate(var(--dx), -115vh) rotate(12deg); opacity: 0; }
}

/* Pétales d'hibiscus (+ quelques cœurs) au climax */
.petals { position: absolute; inset: 0; pointer-events: none; }
.petal {
  position: absolute;
  top: -8vh;
  left: var(--x);
  width: calc(18px * var(--s));
  height: calc(26px * var(--s));
  background: linear-gradient(135deg, var(--coral), var(--gold));
  border-radius: 80% 20% 65% 35% / 65% 35% 80% 20%;
  opacity: 0;
  animation: fall var(--dur) linear var(--delay) both;
}
.petal.heart {
  background: none;
  border-radius: 0;
  width: auto;
  height: auto;
  font-style: normal;
  font-size: calc(19px * var(--s));
  line-height: 1;
  color: color-mix(in oklab, var(--coral), var(--gold) var(--mix, 20%));
}
@keyframes fall {
  0%   { transform: translate(0, 0) rotate(var(--rot)); opacity: 0; }
  8%   { opacity: 0.9; }
  80%  { opacity: 0.8; }
  100% { transform: translate(var(--dx), 118vh) rotate(calc(var(--rot) + 280deg)); opacity: 0; }
}

/* Cœurs qui popent sous le doigt */
.tap-hearts { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.tap-heart {
  position: absolute;
  font-style: normal;
  font-size: var(--fs, 16px);
  color: var(--coral);
  text-shadow: 0 1px 6px rgba(6, 24, 28, 0.25);
  animation: tap-pop 1.1s ease-out forwards;
}
@keyframes tap-pop {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.15); opacity: 0.95; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% - 80px)) scale(0.85); opacity: 0; }
}

/* ------------------------------------------------------------
   Sections
   ------------------------------------------------------------ */

.panel {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 4.5rem 1.6rem;
  text-align: center;
}

.stack { max-width: 34rem; }
.stack > * + * { margin-top: 1.1rem; }
.stack { text-shadow: 0 1px 18px rgba(6, 24, 28, 0.15); }

/* Le texte et le billet passent devant les photos volantes */
.stack, .ticket, .hint { position: relative; z-index: 1; }

/* Petites photos volantes */
.minis { position: absolute; inset: 0; pointer-events: none; }
.mini {
  position: absolute;
  width: var(--ms, 72px);
  padding: 4px 4px 6px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 8px 20px -8px rgba(6, 24, 28, 0.5);
  rotate: var(--mr, 0deg);
  opacity: 0.95;
  animation: mini-bob var(--md, 6s) ease-in-out var(--mdel, 0s) infinite alternate;
}
.mini img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  border-radius: 2px;
  background: #efe8dc;
}
@keyframes mini-bob {
  from { transform: translateY(-5px) rotate(-1.5deg); }
  to   { transform: translateY(6px) rotate(1.5deg); }
}

/* Apparitions au scroll */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.9s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
  transition-delay: var(--d, 0s);
}
.reveal.in { opacity: 1; transform: none; }

/* Typo */
.display {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: -0.015em;
}

.hero-title { font-size: clamp(3.2rem, 16vw, 6.5rem); }
.hero-title.reveal {
  transform: translateY(30px) scale(0.92);
  transition:
    opacity 1s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 1s cubic-bezier(0.3, 1.4, 0.45, 1);
}
.hero-title.reveal.in { transform: none; }

.sub {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.05rem, 4.4vw, 1.4rem);
  opacity: 0.85;
}

.her-name {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.5rem, 6.5vw, 2.1rem);
  color: var(--gold);
  margin-top: 1.6rem;
}
.her-name::after { content: " ♥"; color: var(--coral); font-style: normal; }

.line {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.45rem, 6vw, 2rem);
  line-height: 1.25;
  text-wrap: balance;
}
.line.big { font-size: clamp(1.6rem, 6.8vw, 2.2rem); }
.line.dim { opacity: 0.75; font-weight: 500; }
.line.ital { font-style: italic; }

.wink {
  display: block;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 0.55em;
  font-weight: 400;
  font-style: italic;
  opacity: 0.7;
  margin-top: 0.25rem;
}

.label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  opacity: 0.7;
}
#reveal .label::before { content: "♥ "; color: var(--coral); }
#reveal .label::after  { content: " ♥"; color: var(--coral); }

.huge {
  font-size: clamp(2.7rem, 12.5vw, 5rem);
  text-wrap: balance;
}

.dest {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.6rem, 7.5vw, 2.5rem);
}

.context {
  font-size: clamp(1rem, 4.2vw, 1.15rem);
  opacity: 0.85;
  margin-top: 1.5rem;
}

/* Indice de scroll */
.hint {
  position: absolute;
  bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  opacity: 0.8;
  text-align: center;
}
.hint-2 { font-style: italic; opacity: 0.8; }
.arrow {
  display: block;
  margin-top: 0.45rem;
  font-size: 1.1rem;
  animation: bob 1.9s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(7px); } }

/* ------------------------------------------------------------
   Le paquet à déballer
   ------------------------------------------------------------ */

.gift {
  position: relative;
  width: 160px;
  height: 150px;
  margin: 1.8rem auto 0.6rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.g-shadow {
  position: absolute;
  left: 12%; right: 12%;
  bottom: -12px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(6, 24, 28, 0.35), transparent);
}

.g-wrap { position: absolute; inset: 0; transform-origin: 50% 92%; }
.gift.s1 .g-wrap { --amp: 4deg; animation: wiggle 0.5s ease-in-out; }
.gift.s2 .g-wrap { --amp: 9deg; animation: wiggle 0.5s ease-in-out; }
@keyframes wiggle {
  25% { transform: rotate(var(--amp, 5deg)); }
  55% { transform: rotate(calc(var(--amp, 5deg) * -1)); }
  80% { transform: rotate(calc(var(--amp, 5deg) * 0.5)); }
}

.g-box {
  position: absolute;
  left: 10px; right: 10px;
  bottom: 0;
  height: 92px;
  background: linear-gradient(160deg, #F0705E, #D9503F);
  border-radius: 10px;
  box-shadow: inset 0 -14px 24px rgba(120, 30, 20, 0.25);
}

.g-ribbon {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 26px;
  height: 88px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #F4B860, #E2A44A);
}

.g-lid {
  position: absolute;
  left: 0; right: 0;
  bottom: 86px;
  height: 30px;
  background: linear-gradient(160deg, #F58C6E, #E2604C);
  border-radius: 8px;
  box-shadow: 0 5px 12px rgba(6, 24, 28, 0.22);
  transition: transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1), opacity 0.6s ease;
}
.g-lid-ribbon {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 26px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #F4B860, #E2A44A);
}
.g-bow {
  position: absolute;
  left: 50%;
  top: -16px;
  width: 70px;
  height: 26px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 55%, #E2A44A 0 7px, transparent 8px);
}
.g-bow::before, .g-bow::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 26px;
  height: 20px;
  border: 6px solid #EFB558;
  border-radius: 50% / 60% 60% 45% 45%;
}
.g-bow::before { left: 2px; transform: rotate(-16deg); }
.g-bow::after  { right: 2px; transform: rotate(16deg); }

.gift.open .g-lid { transform: translateY(-110px) rotate(-16deg); opacity: 0; }
.gift.open .g-wrap { animation: openpop 0.5s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes openpop {
  40%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

.g-burst { position: absolute; inset: -40px; pointer-events: none; }
.bit {
  position: absolute;
  left: 50%;
  top: 46%;
  font-style: normal;
  font-size: var(--fs, 14px);
  color: var(--c, var(--coral));
  opacity: 0;
  animation: burst 0.95s ease-out var(--bd, 0s) forwards;
}
@keyframes burst {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  18%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--bx, 0px)), calc(-50% + var(--by, -60px))) rotate(var(--br, 0deg)) scale(1); opacity: 0; }
}

.btn-gift {
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin-top: 1.4rem;
  font-size: 1.05rem;
  padding: 0.9rem 1.8rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.5s ease;
}
.btn-gift:focus-visible { outline-color: var(--paper); }
.btn-gift.gone { opacity: 0; pointer-events: none; }

.gate-hint { font-size: 0.85rem; font-style: italic; opacity: 0.7; }

/* ------------------------------------------------------------
   Le billet
   ------------------------------------------------------------ */

.ticket {
  width: min(420px, 100%);
  background: var(--paper);
  color: #3a2a20;
  border-radius: 18px;
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow:
    0 24px 60px -18px rgba(6, 24, 28, 0.5),
    0 4px 14px rgba(6, 24, 28, 0.18);
  text-align: left;
  text-shadow: none;
}

.t-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #8a7566;
  padding-bottom: 1rem;
}
.t-heart {
  color: var(--coral);
  font-size: 1.05rem;
  letter-spacing: 0;
  display: inline-block;
  animation: beat 1.8s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  22%      { transform: scale(1.3); }
  40%      { transform: scale(1); }
  55%      { transform: scale(1.18); }
  70%      { transform: scale(1); }
}

.t-main > * + * { margin-top: 0.9rem; }

.t-field { display: flex; flex-direction: column; gap: 0.15rem; }
.t-k {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #a08d7c;
}
.t-v {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.2;
}

.t-sub { font-size: 0.95rem; color: #6d5b4c; margin-top: 0.3rem; }

.t-joke {
  font-size: 0.88rem;
  font-style: italic;
  color: #8a7566;
  margin-top: 1.1rem;
}

.t-cut {
  border-top: 2px dashed #d9cdbc;
  margin: 1.2rem -1.5rem;
}

.t-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.btn {
  display: inline-block;
  background: var(--coral);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.98rem;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  box-shadow: 0 8px 20px -6px rgba(236, 106, 90, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -6px rgba(236, 106, 90, 0.6); }
.btn:focus-visible { outline: 3px solid #3a2a20; outline-offset: 3px; }

.barcode {
  flex: 1;
  max-width: 110px;
  height: 34px;
  background: repeating-linear-gradient(
    90deg,
    #4a3a2e 0 2px, transparent 2px 5px,
    #4a3a2e 5px 6px, transparent 6px 10px,
    #4a3a2e 10px 13px, transparent 13px 16px
  );
  opacity: 0.75;
}

/* ------------------------------------------------------------
   Photos — polaroïds le long du scroll
   ------------------------------------------------------------ */

.interlude {
  min-height: 70vh;
  min-height: 72svh;
  display: grid;
  place-items: center;
  padding: 3rem 1.6rem;
}

.interlude .solo .polaroid { width: min(255px, 72vw); }

.duo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.6rem 1.1rem;
  width: min(440px, 100%);
}
.duo-grid > :nth-child(even) { translate: 0 1.4rem; }

.polaroid {
  background: #fff;
  padding: 9px 9px 12px;
  border-radius: 4px;
  box-shadow: 0 14px 34px -12px rgba(6, 24, 28, 0.45);
  rotate: var(--rot);
  text-shadow: none;
}
.polaroid.reveal {
  transition:
    opacity 0.9s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.95s cubic-bezier(0.3, 1.45, 0.45, 1);
  transition-delay: var(--d, 0s);
}
.polaroid img,
.polaroid .ph {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  border-radius: 2px;
  background: #efe8dc;
}
.polaroid .ph {
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-style: italic;
  color: #b0a493;
  border: 1.5px dashed #d9cdbc;
}
.polaroid figcaption {
  font-family: "Caveat", cursive;
  font-size: 1.15rem;
  color: #4a3a2e;
  text-align: center;
  margin-top: 0.5rem;
  line-height: 1.1;
}

/* ------------------------------------------------------------
   Clôture
   ------------------------------------------------------------ */

/* On remonte le contenu pour ne pas chevaucher la silhouette du Piton */
.outro { padding-bottom: max(30vh, 240px); }

.outro-title { font-size: clamp(2.2rem, 10vw, 3.6rem); text-wrap: balance; }

.sig {
  font-family: "Caveat", cursive;
  font-size: clamp(2rem, 8vw, 2.6rem);
  rotate: -2.5deg;
  margin-top: 1.8rem;
}

.heart-row { color: var(--coral); font-size: 1.1rem; letter-spacing: 0.9em; padding-left: 0.9em; }
.heart-row span { display: inline-block; }
.heart-row.in span { animation: pop 0.55s cubic-bezier(0.3, 1.6, 0.45, 1) var(--hd, 0s) backwards; }
@keyframes pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

.ps {
  font-size: 0.92rem;
  opacity: 0.8;
  margin-top: 2.4rem;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------
   Reduced motion : aube douce figée, tout visible
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  :root { --p: 0.9; --dawn: 0.95; }
  .reveal, .hero-title.reveal, .polaroid.reveal { opacity: 1; transform: none; transition: none; }
  .arrow, .stars .tw, .petal, .floatie, .tap-heart, .t-heart,
  .heart-row.in span, body.climax .bloom, .mini,
  .gift.s1 .g-wrap, .gift.s2 .g-wrap, .gift.open .g-wrap, .bit { animation: none; }
  .btn, .g-lid { transition: none; }
  .gift.open .g-lid { opacity: 0; }
}

/* Desktop : on resserre, ça reste propre */
@media (min-width: 700px) {
  .stack { max-width: 40rem; }
  .interlude .solo .polaroid { width: 280px; }
  .duo-grid { gap: 2rem 1.6rem; }
}
