/* =================================================================
   Bearly Wait — A Little Storybook Keepsake
   Boy baby-shower invitation · kawaii watercolor · mobile-first
   ================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --bg-primary: #F4F9FF;
  --bg-wash:    #E7F1FC;
  --blue-light: #CFE6FB;
  --blue-mid:   #A9D2F5;
  --blue-deep:  #5B97D6;
  --blue-ink:   #3E6FA8;
  --brown:      #8A5A3B;
  --brown-soft: #A77B5A;
  --cream:      #FFFBF3;
  --cream-deep: #F4ECDD;
  --gold:       #D4B164;
  --gold-deep:  #B8954A;
  --ink:        #4A4036;
  --star:       #E7C66B;
  --white:      #FFFFFF;

  --shadow-blue: rgba(91,151,214,0.22);
  --shadow-soft: rgba(74,64,54,0.10);
  --grain-opacity: 0.045;

  --radius-card: 26px;
  --radius-deckle: 26px 30px 24px 32px / 30px 24px 32px 26px;

  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-soft:   cubic-bezier(.16,1,.3,1);
  --tap-min: 56px;

  --font-display: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-script:  "Caveat", "Brush Script MT", "Segoe Script", cursive;
  --font-body:    "Quicksand", ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-primary);
  line-height: 1.6;
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* lock scroll while the envelope intro is up */
body.intro-active { overflow: hidden; height: 100svh; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Fixed paper-grain + cool-blue vignette ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background-image:
    radial-gradient(120% 90% at 50% 0%, transparent 55%, var(--bg-wash) 130%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: cover, 160px 160px;
  opacity: 1;
  mix-blend-mode: multiply;
}
.grain::after { content: ""; position: absolute; inset: 0; opacity: var(--grain-opacity); }

/* shared helper: gold double-hairline keepsake frame */
.gold-frame {
  border: 1.5px solid var(--gold);
  box-shadow: inset 0 0 0 5px var(--cream), inset 0 0 0 6.5px rgba(212,177,100,.5);
}

/* =================================================================
   DECOR — clouds · balloons · confetti · stars
   ================================================================= */
.cloud {
  position: absolute;
  width: 120px; height: 46px;
  background: var(--white);
  border-radius: 60px;
  filter: blur(.3px);
  opacity: .92;
  box-shadow:
    34px 8px 0 -4px var(--white),
    -34px 10px 0 -6px var(--white),
    0 -16px 0 -6px var(--white);
}

.balloon {
  position: absolute;
  width: 46px; height: 58px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 32% 28%, #ffffffcc, var(--blue-light) 55%);
  box-shadow: 0 6px 14px var(--shadow-blue);
}
.balloon::before { /* knot */
  content: ""; position: absolute; bottom: -6px; left: 50%;
  width: 8px; height: 8px; transform: translateX(-50%);
  background: inherit; border-radius: 2px;
}
.balloon::after { /* string */
  content: ""; position: absolute; bottom: -54px; left: 50%;
  width: 1.5px; height: 54px;
  background: linear-gradient(var(--gold), transparent);
  transform-origin: top center;
}
.balloon--2 { background: radial-gradient(circle at 32% 28%, #fff, #ffffff 55%); }
.balloon--3 { background: radial-gradient(circle at 32% 28%, #ffffffcc, var(--blue-mid) 58%); }

/* =================================================================
   INTRO — scroll-scrubbed envelope reveal.
   #reveal gives the scroll distance; #stage is pinned (sticky) and
   reads progress vars set by JS: --p --pf (flap) --pl (letter)
   --pe (envelope fade) --pt (title/cue fade).
   ================================================================= */
#reveal { position: relative; height: 240vh; z-index: 20; }
#stage {
  position: sticky; top: 0;
  height: 100svh; height: 100dvh;
  overflow: hidden;
  perspective: 1300px;
  background: linear-gradient(180deg, var(--bg-primary), var(--bg-wash));
}

.sky-clouds { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sky-clouds .cloud { opacity: .85; }
.cloud--a { top: 14%; left: -10%; transform: scale(1.3); animation: drift 40s linear infinite; }
.cloud--b { top: 70%; left: -20%; transform: scale(.9); animation: drift 52s linear infinite 6s; }
.cloud--c { top: 40%; left: -30%; transform: scale(1.6); opacity: .6; animation: drift 64s linear infinite 3s; }

/* soft script title — fades out as the reveal progresses */
.intro-title {
  position: absolute; top: clamp(36px, 9vh, 92px); left: 0; right: 0; z-index: 6;
  font-family: var(--font-script); font-weight: 700;
  color: var(--brown); font-size: clamp(2.2rem, 9vw, 3rem);
  line-height: 1; text-align: center;
  opacity: calc(1 - var(--pt, 0));
  transition: opacity .12s linear;
}

/* floating hearts drifting in the intro sky */
.floaties { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.floaties .fh { position: absolute; bottom: -8%; opacity: 0; }
.floaties .fh svg { width: 100%; height: 100%; fill: var(--blue-mid); }
.floaties .fh:nth-child(1){ left: 8%;  width: 18px; height: 18px; animation: floatUp 11s linear infinite 0s; }
.floaties .fh:nth-child(2){ left: 22%; width: 12px; height: 12px; animation: floatUp 14s linear infinite 2s; }
.floaties .fh:nth-child(3){ left: 35%; width: 22px; height: 22px; animation: floatUp 13s linear infinite 5s; }
.floaties .fh:nth-child(4){ left: 48%; width: 14px; height: 14px; animation: floatUp 16s linear infinite 1s; }
.floaties .fh:nth-child(5){ left: 60%; width: 20px; height: 20px; animation: floatUp 12s linear infinite 6s; }
.floaties .fh:nth-child(6){ left: 72%; width: 12px; height: 12px; animation: floatUp 15s linear infinite 3s; }
.floaties .fh:nth-child(7){ left: 84%; width: 18px; height: 18px; animation: floatUp 13s linear infinite 7s; }
.floaties .fh:nth-child(8){ left: 92%; width: 11px; height: 11px; animation: floatUp 17s linear infinite 4s; }
.floaties .fh:nth-child(9){ left: 15%; width: 14px; height: 14px; animation: floatUp 18s linear infinite 8s; }
.floaties .fh:nth-child(even) svg { fill: var(--blue-light); }
.floaties .fh:nth-child(3n) svg { fill: var(--gold); opacity: .9; }

/* envelope graphic — centered; flap opens (--pf) and it fades + sinks (--pe) */
.envelope {
  position: absolute; left: 50%; top: 50%;
  width: clamp(290px, 86vw, 430px);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%) translateY(calc(var(--pe, 0) * 7vh)) scale(calc(1 - var(--pe, 0) * 0.07));
  transform-style: preserve-3d;
  opacity: calc(1 - var(--pe, 0));
  z-index: 3; cursor: pointer;
  will-change: transform, opacity;
}

/* envelope panels — a realistic paper envelope: ivory paper flaps + blue patterned liner */
.env-liner {
  position: absolute; inset: 0;
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.5) 1px, transparent 1.7px) 0 0 / 13px 13px,
    linear-gradient(168deg, #cfe6fb, #a6cdee);
  box-shadow:
    0 20px 36px var(--shadow-blue),
    inset 0 0 0 1.5px rgba(255,255,255,.5),
    inset 0 3px 14px rgba(43,86,133,.16);
}
/* folded paper flaps forming the front pocket (the classic back-of-envelope look) */
.env-fl { position: absolute; inset: 0; }
.env-fl--left  { z-index: 2; clip-path: polygon(0 0, 0 100%, 51% 50%); background: linear-gradient(100deg, #efe7d8, #fbf6ec); }
.env-fl--right { z-index: 2; clip-path: polygon(100% 0, 100% 100%, 49% 50%); background: linear-gradient(260deg, #efe7d8, #fbf6ec); }
.env-fl--bottom {
  z-index: 3;
  clip-path: polygon(0 100%, 100% 100%, 50% 30%);
  background: linear-gradient(185deg, #fffdf8 0%, #f3ecdd 100%);
  filter: drop-shadow(0 -1.5px 1.5px rgba(60,46,33,.07));
}

/* top flap — opens on its hinge (--pf); ivory paper outside, blue liner inside */
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 60%;
  z-index: 6;
  background: linear-gradient(168deg, #ffffff 0%, #efe7d7 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 8px 8px 0 0;
  transform-origin: top center;
  transform: rotateX(calc(var(--pf, 0) * -162deg));
  box-shadow: 0 4px 9px rgba(60,46,33,.12);
  will-change: transform;
}
.env-flap::after { /* blue patterned liner shown as the flap lifts */
  content: ""; position: absolute; inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background:
    radial-gradient(circle at center, rgba(255,255,255,.45) 1px, transparent 1.7px) 0 0 / 13px 13px,
    linear-gradient(180deg, #c3ddf6, #9ec5ed);
  opacity: calc(var(--pf, 0) * 0.95);
}
/* a soft fold-shadow line where the closed flap tip meets the pocket */
.env-flap::before {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 26%;
  background: linear-gradient(180deg, transparent, rgba(60,46,33,.05));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: calc(1 - var(--pf, 0));
}

/* THE MAIN LETTER = the invitation itself; rises out + grows as you scroll (--pl) */
.letter {
  position: absolute; left: 50%; top: 50%;
  width: min(600px, 92vw);
  z-index: 4;
  transform-origin: center center;
  transform:
    translate(-50%, -50%)
    translateY(calc((1 - var(--pl, 0)) * 24%))
    scale(calc(0.5 + var(--pl, 0) * 0.5));
  opacity: var(--pl, 0);
  pointer-events: none;
  will-change: transform, opacity;
}
.letter.live { pointer-events: auto; }

.letter-card {
  position: relative;
  background:
    radial-gradient(circle, rgba(91,151,214,.07) 1px, transparent 1.2px) 0 0 / 9px 9px,
    var(--cream);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-card);
  box-shadow: 0 18px 42px var(--shadow-blue);
  padding: clamp(18px, 4.5vw, 34px) clamp(16px, 5vw, 32px) clamp(20px, 5vw, 34px);
  text-align: center;
}
.letter-card::before { /* gold double hairline */
  content: ""; position: absolute; inset: 8px;
  border: 1.5px solid var(--gold); border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--cream), inset 0 0 0 4px rgba(212,177,100,.45);
  pointer-events: none;
}

/* wax seal — single piece, fades as the flap opens (--pf) */
.seal {
  position: absolute;
  top: calc(53% - 24px); left: 50%;
  width: 48px; height: 48px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, var(--blue-deep), #3a6ba3 78%, #2f5685);
  box-shadow: inset 0 2px 6px #ffffff44, inset 0 -3px 8px #00000033, 0 3px 8px var(--shadow-blue);
  border: 1.5px solid var(--gold);
  z-index: 7;
  opacity: calc(1 - var(--pf, 0));
  pointer-events: none; /* decorative — never blocks the tap target underneath */
}
.seal-art { position: absolute; inset: 0; width: 100%; height: 100%; }

/* scroll-to-open cue */
.cue {
  position: absolute; bottom: clamp(74px, 17vh, 150px); left: 0; right: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--font-body);
  font-size: .78rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--blue-ink); font-weight: 600;
  opacity: calc(1 - var(--pt, 0)); transition: opacity .12s linear;
}
.cue .chevrons { display: grid; animation: chevBounce 1.6s ease-in-out infinite; }
.cue .chevrons b {
  display: block; width: 14px; height: 8px;
  border-right: 2.5px solid var(--brown-soft);
  border-bottom: 2.5px solid var(--brown-soft);
  transform: rotate(45deg);
  margin-top: -4px;
}
.cue .chevrons b:nth-child(2) { opacity: .5; }

.skip-intro {
  position: absolute; bottom: clamp(28px, 8.5vh, 88px); left: 50%; transform: translateX(-50%); z-index: 6;
  font-family: var(--font-body);
  font-size: .82rem; color: var(--blue-ink);
  text-decoration: underline; text-underline-offset: 3px;
  padding: 8px 14px;
  min-height: 44px;
  opacity: calc((1 - var(--pt, 0)) * .8);
}
.skip-intro:hover { opacity: 1; }

/* floating action button (echoes the reference's heart button) — tap to auto-open */
.fab {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 6;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 8px 20px var(--shadow-blue);
  display: grid; place-items: center;
  border: 1.5px solid var(--gold);
  opacity: calc(1 - var(--pt, 0));
  transition: opacity .15s linear, transform .15s var(--ease-spring);
}
.fab svg { width: 25px; height: 25px; fill: var(--blue-deep); }
.fab:active { transform: scale(.92); }

/* burst confetti injected by JS */
.burst-fleck {
  position: fixed; z-index: 60;
  width: 9px; height: 9px; border-radius: 2px;
  pointer-events: none;
  animation: burstFall var(--dur,1.4s) ease-in forwards;
}

/* =================================================================
   SITE
   ================================================================= */
#site { position: relative; z-index: 2; }

.section {
  position: relative;
  padding: clamp(48px, 9vw, 96px) max(clamp(18px, 5vw, 40px), env(safe-area-inset-right)) clamp(48px, 9vw, 96px) max(clamp(18px, 5vw, 40px), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  width: min(100%, 540px);
  background: var(--cream);
  border-radius: var(--radius-card);
  padding: clamp(26px, 6vw, 44px);
  box-shadow: 0 16px 40px var(--shadow-blue);
  text-align: center;
  z-index: 2;
}
.card::before { /* gold double hairline */
  content: "";
  position: absolute; inset: 9px;
  border: 1.5px solid var(--gold);
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--cream), inset 0 0 0 4px rgba(212,177,100,.45);
  pointer-events: none;
}
.card--deckle { border-radius: var(--radius-deckle); }
.card--deckle::before { border-radius: var(--radius-deckle); }

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  justify-content: flex-start;
  padding-top: max(clamp(8px, 3vw, 28px), env(safe-area-inset-top));
  background:
    radial-gradient(80% 55% at 50% 64%, var(--bg-wash), transparent 70%),
    var(--bg-primary);
}
.hero-garland {
  position: relative;
  width: 100%;
  text-align: center;
  margin-bottom: -36px;
  z-index: 1;
  pointer-events: none;
}
.garland-img {
  display: block; margin: 0 auto;
  width: min(540px, 96%); height: auto;
  filter: drop-shadow(0 6px 12px var(--shadow-blue));
  animation: garlandBob 6.5s ease-in-out infinite;
}
/* CSS fallback garland (hidden once the image is in) */
.garland-img ~ .cloud, .garland-img ~ .balloon { display: none; }
.garland-img.is-missing { display: none; }
.garland-img.is-missing ~ .cloud, .garland-img.is-missing ~ .balloon { display: block; }
.garland-img.is-missing ~ .balloon { animation: sway 5s ease-in-out infinite; }
.balloon--g1 { top: 60px; right: 40px; animation-delay: .3s; }
.balloon--g2 { top: 30px; right: 96px; animation-delay: 1.1s; }
.balloon--g3 { top: 76px; right: 150px; animation-delay: .7s; }
.cloud--g1 { top: 18px; right: 10px; transform: scale(.8); }
.cloud--g2 { top: 70px; right: 180px; transform: scale(1); opacity: .8; }

.card--hero { position: relative; z-index: 2; padding-top: clamp(34px, 8vw, 52px); }
.hero-kicker { font-family: var(--font-script); color: var(--brown-soft); font-size: clamp(1.3rem, 5vw, 1.7rem); line-height: 1; }
.hero-script {
  font-family: var(--font-script); color: var(--brown);
  font-size: clamp(3.4rem, 16vw, 5.2rem); line-height: .82; font-weight: 700;
  position: relative; display: inline-block;
}
.heart-gold { width: 1em; height: 1em; fill: var(--gold); }
.hero-script .heart-gold {
  position: absolute; right: -.1em; top: -.1em;
  width: .34em; height: .34em; fill: none;
  stroke: var(--gold); stroke-width: 2;
}
.hero-baby { margin-top: 8px; }
.word-baby {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(3rem, 17vw, 5rem); line-height: .9;
  color: var(--blue-deep); letter-spacing: .04em;
  text-shadow: 0 2px 0 #fff, 0 5px 10px var(--shadow-blue);
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
}
.hero-name {
  font-family: var(--font-script); color: var(--blue-deep);
  font-size: clamp(2rem, 9vw, 3rem); line-height: 1; font-weight: 700; margin-top: 2px;
}
.hero-ontheway { font-family: var(--font-display); color: var(--blue-deep); font-weight: 500; letter-spacing: .05em; font-size: clamp(1rem,4vw,1.3rem); }

.teddy-wrap { position: relative; margin: 18px auto 6px; width: clamp(190px, 56vw, 280px); }
.teddy-blob {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 78%; height: 26px; border-radius: 50%;
  background: var(--blue-mid); filter: blur(8px); opacity: .5;
}
.teddy { position: relative; width: 100%; height: auto; animation: breathe 4.2s ease-in-out infinite; will-change: transform; }
.teddy.booped { animation: boop .9s var(--ease-spring); }
.teddy-fallback { display: none; width: 100%; height: auto; }
.teddy.is-missing { display: none; }
.teddy.is-missing + .teddy-fallback { display: block; animation: breathe 4.2s ease-in-out infinite; }

.hero-honoring { margin-top: 14px; color: var(--ink); font-size: clamp(.95rem,3.6vw,1.05rem); }
.hero-parents { font-family: var(--font-script); color: var(--blue-deep); font-size: clamp(2rem, 9vw, 2.8rem); line-height: 1; font-weight: 700; }
.hero-sub { margin-top: 12px; color: var(--ink); font-size: .96rem; opacity: .9; max-width: 34ch; margin-inline: auto; }

.scroll-cue {
  margin-top: auto; min-height: 44px; padding-top: 22px; padding-bottom: 8px; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: var(--font-script); color: var(--brown-soft); font-size: 1.2rem;
  animation: heartBob 1.6s ease-in-out infinite;
  z-index: 2;
}
.scroll-cue .heart-gold { width: 18px; height: 18px; fill: var(--gold); }
.scroll-cue.hide { opacity: 0; transition: opacity .5s; pointer-events: none; }

/* ---- Compact the hero content so the whole letter fits one screen when pinned ---- */
.letter .hero-garland { margin-bottom: -24px; }
.letter .garland-img { width: min(360px, 74%); animation: none; }
.letter .hero-kicker { font-size: clamp(1.05rem, 4.4vw, 1.3rem); }
.letter .hero-script { font-size: clamp(2.5rem, 12vw, 3.3rem); line-height: .85; }
.letter .hero-baby { margin-top: 4px; }
.letter .word-baby { font-size: clamp(2.4rem, 12.5vw, 3.3rem); }
.letter .hero-name { font-size: clamp(1.5rem, 7vw, 2.05rem); }
.letter .hero-ontheway { font-size: clamp(.85rem, 3.6vw, 1.02rem); }
.letter .teddy-wrap { width: clamp(135px, 38vw, 185px); margin: 8px auto 2px; }
.letter .hero-honoring { margin-top: 8px; font-size: clamp(.82rem, 3.3vw, .95rem); }
.letter .hero-parents { font-size: clamp(1.5rem, 6.4vw, 1.95rem); }
.letter .hero-sub { display: block; margin-top: 7px; font-size: clamp(.8rem, 3.2vw, .92rem); max-width: 32ch; }

/* Extra compaction on short viewports (e.g. iPhone SE) so the pinned letter never clips */
@media (max-height: 700px) {
  .letter .hero-garland { margin-bottom: -18px; }
  .letter .garland-img { width: min(300px, 62%); }
  .letter .hero-kicker { font-size: 1rem; }
  .letter .hero-script { font-size: clamp(2rem, 10vw, 2.6rem); }
  .letter .word-baby { font-size: clamp(1.9rem, 10.5vw, 2.6rem); }
  .letter .hero-name { font-size: 1.45rem; }
  .letter .hero-ontheway { font-size: .8rem; }
  .letter .teddy-wrap { width: clamp(100px, 28vw, 135px); margin: 4px auto 0; }
  .letter .hero-honoring { margin-top: 4px; font-size: .8rem; }
  .letter .hero-parents { font-size: clamp(1.3rem, 6vw, 1.7rem); }
  .letter .hero-sub { margin-top: 4px; font-size: .76rem; }
  .letter-card { padding: clamp(12px, 3.5vw, 22px) clamp(14px, 4vw, 24px); }
}

/* ---------- Section titles ---------- */
.section-title {
  font-family: var(--font-display); font-weight: 600;
  color: var(--blue-deep); font-size: clamp(1.5rem, 6vw, 2rem);
  letter-spacing: .02em; margin-bottom: 6px;
}
.script-title {
  font-family: var(--font-script); font-weight: 700;
  color: var(--brown); font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1.05; margin-bottom: 14px;
}

/* ---------- Details ---------- */
.section--details { background: linear-gradient(180deg, var(--bg-primary), var(--bg-wash)); }
.moon-emblem { position: relative; height: 120px; display: grid; place-items: center; margin-bottom: 4px; }
.teddy-moon { width: auto; height: 120px; }
.teddy-moon.is-missing { display: none; }
.moon-motif { display: none; }
.moon-motif--lg { width: 160px; }
.moon-emblem .teddy-moon.is-missing + .moon-motif--lg { display: block; }
.moon-motif svg { width: 100%; height: auto; overflow: visible; }
.moon-motif .star { animation: twinkle 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.moon-motif .star:nth-child(4){ animation-delay: .8s }
.moon-motif .star:nth-child(5){ animation-delay: 1.5s }

.banner-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 18px; }
.banner { position: relative; display: inline-grid; place-items: center; min-width: 124px; padding: 10px 14px; }
.banner-ribbon { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 3px 4px var(--shadow-soft)); }
.banner-label { position: relative; font-family: var(--font-script); font-weight: 700; color: var(--cream); font-size: 1.5rem; line-height: 1; }
.moon-motif--sm { display: block; width: 60px; }
.moon-motif--sm svg { width: 100%; }

.venue-name { font-family: var(--font-display); font-weight: 600; color: var(--ink); font-size: clamp(1.2rem, 5vw, 1.5rem); }
.venue-address { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; color: var(--blue-ink); font-weight: 500; margin-top: 2px; }
.paw-dot { width: 16px; height: 16px; fill: var(--gold); }
.dress-chip {
  margin: 14px auto 0; display: inline-block;
  background: rgba(91,151,214,.12); color: var(--blue-ink);
  padding: 7px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  border: 1px solid rgba(91,151,214,.25);
}
.details-note { margin-top: 14px; color: var(--ink); opacity: .88; font-size: .95rem; max-width: 36ch; margin-inline: auto; }

/* ---------- Countdown ---------- */
.section--countdown { background: var(--bg-wash); }
.moon-motif--corner { display: block; position: absolute; top: 24px; right: 18px; width: 70px; opacity: .9; }
.countdown {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px; width: min(100%, 420px);
}
.cd-tile {
  background: var(--cream); border-radius: 20px; padding: 18px 8px 12px;
  box-shadow: 0 10px 24px var(--shadow-blue), inset 0 2px 0 #fff;
  position: relative;
}
.cd-tile::before { content:""; position:absolute; inset:6px; border:1.2px solid rgba(212,177,100,.5); border-radius:14px; pointer-events:none; }
.cd-num { display: block; font-family: var(--font-display); font-weight: 700; color: var(--blue-deep); font-size: clamp(2.4rem, 12vw, 3.4rem); line-height: 1; }
.cd-num.pop { animation: cdPop .4s var(--ease-spring); }
.cd-label { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--brown); font-weight: 600; }
.cd-arrived { font-family: var(--font-script); color: var(--brown); font-size: clamp(2rem, 9vw, 2.8rem); }

/* ---------- RSVP ---------- */
.section--rsvp { background: linear-gradient(180deg, var(--bg-wash), var(--bg-primary)); }
.rsvp-sub { color: var(--ink); opacity: .9; margin-bottom: 18px; }
.rsvp-actions { display: grid; gap: 12px; margin: 4px 0 16px; }

/* ---------- RSVP form ---------- */
.rsvp-form { display: grid; gap: 14px; text-align: left; margin: 4px 0 16px; }
.hp-field { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.rsvp-row { display: grid; gap: 14px; }
@media (min-width: 460px) { .rsvp-row { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 5px; }
.field > span { font-family: var(--font-display); font-weight: 600; font-size: .82rem; color: var(--blue-ink); padding-left: 4px; }
.field > span em { color: var(--brown-soft); font-style: italic; font-weight: 500; }
.rsvp-form input,
.rsvp-form textarea {
  font-family: var(--font-body); font-size: 1rem; color: var(--ink);
  background: #fffdf8; border: 1.5px solid #e7d9bf; border-radius: 14px;
  padding: 12px 14px; width: 100%; -webkit-appearance: none; appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  min-height: var(--tap-min);
}
.rsvp-form textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.rsvp-form input::placeholder,
.rsvp-form textarea::placeholder { color: #b9ab93; }
.rsvp-form input:focus,
.rsvp-form textarea:focus {
  outline: none; border-color: var(--blue-deep);
  box-shadow: 0 0 0 3px rgba(91,151,214,.18);
}
.rsvp-form input:invalid:not(:placeholder-shown) { border-color: #e0a3a3; }

.rsvp-attend { border: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rsvp-attend legend { font-family: var(--font-display); font-weight: 600; font-size: .82rem; color: var(--blue-ink); padding-left: 4px; }
.rsvp-attend > label { display: flex; }
.pillradio { position: relative; }
.pillradio input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pillradio span {
  flex: 1; display: block; text-align: center;
  padding: 12px 14px; min-height: var(--tap-min); line-height: 1.9;
  border-radius: 14px; border: 1.5px solid #e7d9bf; background: #fffdf8;
  font-family: var(--font-display); font-weight: 600; color: var(--ink);
  transition: all .15s var(--ease-spring); cursor: pointer;
}
@media (min-width: 460px) { .rsvp-attend { grid-template-columns: 1fr 1fr; } }
.pillradio input:checked + span {
  background: var(--blue-deep); color: #fff; border-color: var(--blue-deep);
  box-shadow: 0 6px 14px var(--shadow-blue); transform: translateY(-1px);
}
.pillradio input:focus-visible + span { box-shadow: 0 0 0 3px rgba(91,151,214,.25); }

.rsvp-submit { width: 100%; margin-top: 2px; }
.rsvp-submit[disabled] { opacity: .7; cursor: progress; }
.rsvp-status { min-height: 1.2em; margin-top: 2px; text-align: center; font-weight: 600; font-size: .92rem; }
.rsvp-status.is-error { color: #c0656a; }
.rsvp-status.is-ok { color: var(--blue-deep); }
.rsvp-form.is-done { display: none; }
.rsvp-thanks { display: none; text-align: center; padding: 8px 0 4px; }
.rsvp-thanks.show { display: block; animation: fadeInDown .5s var(--ease-soft) both; }
.rsvp-thanks .big { font-family: var(--font-script); color: var(--brown); font-size: clamp(1.8rem, 8vw, 2.4rem); line-height: 1.05; }
.rsvp-thanks p { color: var(--ink); margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap-min); padding: 14px 24px;
  border-radius: 999px; font-family: var(--font-display); font-weight: 600;
  font-size: 1.05rem; text-decoration: none;
  position: relative; overflow: hidden;
  transition: transform .15s var(--ease-spring), box-shadow .15s ease;
  will-change: transform;
}
.btn .paw, .btn .heart-gold { width: 20px; height: 20px; }
.btn--primary { background: var(--blue-deep); color: #fff; box-shadow: 0 8px 18px var(--shadow-blue); }
.btn--primary .paw { fill: #fff; }
.btn--ghost { background: var(--cream); color: var(--blue-ink); border: 1.5px solid var(--gold); }
.btn--ghost .heart-gold { fill: var(--gold); }
.btn::after { /* shimmer on press */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 40%, #ffffff66 50%, transparent 60%);
  transform: translateX(-120%);
}
.btn:active { transform: scale(.96); box-shadow: 0 4px 10px var(--shadow-blue); }
.btn.shimmer::after { animation: shimmerOnce .5s ease; }

.rsvp-fallback { margin-top: 4px; color: var(--blue-ink); font-weight: 500; }
.rsvp-fallback a { color: var(--blue-ink); font-weight: 700; text-decoration: none; border-bottom: 1.5px dotted var(--blue-mid); }
.rsvp-deadline {
  margin-top: 14px; display: inline-block;
  background: rgba(212,177,100,.16); color: var(--ink);
  padding: 6px 16px; border-radius: 999px; font-style: italic; font-size: .92rem;
}

/* ---------- Map ---------- */
.section--map { background: var(--bg-primary); }
.card--map { overflow: hidden; }
.map-doodle {
  position: relative; height: 150px; margin: -6px -6px 14px;
  border-radius: 18px; overflow: hidden;
  background: linear-gradient(160deg, #eaf4ff, var(--blue-light));
}
.road { position: absolute; background: #fff; opacity: .85; border-radius: 6px; }
.road--h { top: 58%; left: -5%; width: 110%; height: 16px; transform: rotate(-4deg); }
.road--v { top: -5%; left: 40%; width: 16px; height: 110%; transform: rotate(6deg); }
.map-block { position: absolute; background: var(--cream); border-radius: 8px; box-shadow: 0 2px 6px var(--shadow-soft); }
.map-block--1 { width: 30%; height: 28%; top: 14%; left: 10%; }
.map-block--2 { width: 26%; height: 30%; bottom: 12%; right: 14%; background: var(--cream-deep); }
.map-pin { position: absolute; top: 50%; left: 50%; width: 44px; transform: translate(-50%,-72%); filter: drop-shadow(0 6px 6px var(--shadow-blue)); }
.map-pin.drop { animation: pinDrop .7s var(--ease-spring); }
.map-address { color: var(--blue-ink); font-weight: 500; margin-bottom: 16px; }

/* ---------- Registry ---------- */
.section--registry { background: linear-gradient(180deg, var(--bg-primary), var(--bg-wash)); }
.registry-sub { color: var(--ink); opacity: .9; margin-bottom: 22px; }
.registry-grid { display: grid; grid-template-columns: minmax(0, 360px); justify-content: center; gap: 16px; width: 100%; }
.gift-tag {
  position: relative; display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "swatch name" "swatch cta";
  align-items: center; column-gap: 16px; row-gap: 2px;
  text-decoration: none; background: var(--cream);
  border-radius: 16px 16px 16px 6px; padding: 16px 20px 16px 28px;
  box-shadow: 0 8px 20px var(--shadow-blue);
  border: 1.5px solid rgba(212,177,100,.55);
  transition: transform .18s var(--ease-spring), box-shadow .18s ease;
  min-height: var(--tap-min);
}
.gift-tag .tag-swatch { grid-area: swatch; }
.gift-tag .tag-name { grid-area: name; align-self: end; }
.gift-tag .tag-cta { grid-area: cta; align-self: start; justify-self: start; }
.gift-tag::before { /* punched hole + string */
  content: ""; position: absolute; top: 14px; left: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg-primary); box-shadow: inset 0 0 0 1.5px var(--gold);
}
.tag-swatch { width: 34px; height: 34px; border-radius: 9px; }
.tag-swatch--1 { background: radial-gradient(circle at 35% 30%, #fff, var(--blue-light)); }
.tag-swatch--2 { background: radial-gradient(circle at 35% 30%, #fff, #f6c9c0); }
.tag-swatch--3 { background: radial-gradient(circle at 35% 30%, #fff, #cfe3c2); }
.tag-name { font-family: var(--font-display); font-weight: 600; color: var(--ink); font-size: 1.15rem; text-align: left; }
.tag-cta { font-family: var(--font-body); font-weight: 600; color: var(--blue-deep); font-size: .9rem; white-space: nowrap; }
.gift-tag:hover, .gift-tag:focus-visible { transform: translateY(-3px) rotate(-1.2deg); box-shadow: 0 14px 28px var(--shadow-blue); }

/* ---------- Footer ---------- */
.site-footer {
  position: relative; text-align: center;
  padding: clamp(70px, 14vw, 120px) 24px max(clamp(40px, 8vw, 64px), env(safe-area-inset-bottom));
  background: var(--bg-wash);
  border-radius: 50% 50% 0 0 / 60px 60px 0 0;
  margin-top: -30px;
  overflow: hidden;
}
.footer-clouds { position: absolute; top: 0; left: 0; right: 0; height: 80px; }
.cloud--f1 { top: 6px; left: 8%; transform: scale(.9); }
.cloud--f2 { top: 30px; left: 44%; transform: scale(1.2); }
.cloud--f3 { top: 10px; right: 8%; transform: scale(.8); }
.footer-stars { position: absolute; inset: 0 0 auto 0; height: 100%; pointer-events: none; }
.footer-stars i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--star); opacity: .5;
  animation: twinkle 3s ease-in-out infinite;
}
.footer-stars i:nth-child(1){ top:30%; left:14% } .footer-stars i:nth-child(2){ top:46%; left:30%; animation-delay:.6s }
.footer-stars i:nth-child(3){ top:24%; left:54%; animation-delay:1.2s } .footer-stars i:nth-child(4){ top:50%; left:72%; animation-delay:.4s }
.footer-stars i:nth-child(5){ top:36%; left:86%; animation-delay:1.6s } .footer-stars i:nth-child(6){ top:60%; left:20%; animation-delay:2s }
.footer-stars i:nth-child(7){ top:62%; left:60%; animation-delay:.9s } .footer-stars i:nth-child(8){ top:28%; left:40%; animation-delay:2.3s }

.footer-signoff { position: relative; font-family: var(--font-script); font-weight: 700; color: var(--brown); font-size: clamp(1.8rem, 8vw, 2.6rem); }
.footer-closing { position: relative; color: var(--ink); opacity: .85; max-width: 30ch; margin: 6px auto 0; font-size: .95rem; }
.paw-trail { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.paw-trail .paw { width: 22px; height: 22px; fill: var(--brown-soft); transform: rotate(var(--r, 0deg)); }
.paw-trail .paw:nth-child(odd){ --r: -16deg; margin-top: 8px; }
.paw-trail .paw:nth-child(even){ --r: 12deg; }
.footer-family { position: relative; font-weight: 600; color: var(--blue-ink); margin-top: 4px; }
.footer-made { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--brown-soft); font-size: .85rem; margin-top: 8px; }
.footer-made .heart-gold { width: 14px; height: 14px; fill: var(--gold); }

/* =================================================================
   Scroll-reveal
   ================================================================= */
.reveal { opacity: 0; transform: translateY(18px) scale(.985); transition: opacity .6s var(--ease-soft), transform .6s var(--ease-soft); }
.reveal.in { opacity: 1; transform: none; }
.gift-tag.reveal:nth-child(2) { transition-delay: .1s; }
.gift-tag.reveal:nth-child(3) { transition-delay: .2s; }

/* =================================================================
   Keyframes
   ================================================================= */
@keyframes breathe { 0%,100%{ transform: translateY(0) scale(1) rotate(0); } 50%{ transform: translateY(-10px) scale(1.015) rotate(.6deg); } }
@keyframes wiggle  { 0%,100%{ transform: rotate(0); } 25%{ transform: rotate(-2deg); } 75%{ transform: rotate(2deg); } }
@keyframes sway    { 0%,100%{ transform: rotate(-3deg); } 50%{ transform: rotate(3deg); } }
@keyframes drift   { from{ transform: translateX(0); } to{ transform: translateX(130vw); } }
@keyframes twinkle { 0%,100%{ opacity:.4; transform: scale(.85) rotate(0); } 50%{ opacity:1; transform: scale(1.1) rotate(8deg); } }
@keyframes shimmer { 0%{ transform: translateX(-120%);} 18%,100%{ transform: translateX(120%);} }
@keyframes shimmerOnce { from{ transform: translateX(-120%);} to{ transform: translateX(120%);} }
@keyframes cuePulse{ 0%,100%{ opacity:.65; } 50%{ opacity:1; } }
@keyframes pawBounce{ 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-5px);} }
@keyframes heartBob{ 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(6px);} }
@keyframes boop { 0%{ transform: scale(1);} 30%{ transform: scale(1.06,.92);} 60%{ transform: scale(.96,1.05);} 100%{ transform: scale(1);} }
@keyframes cdPop { 0%{ transform: scale(1);} 40%{ transform: scale(1.22);} 100%{ transform: scale(1);} }
@keyframes pinDrop { 0%{ transform: translate(-50%,-160%) scale(.8);} 60%{ transform: translate(-50%,-66%) scale(1.05);} 100%{ transform: translate(-50%,-72%) scale(1);} }

/* open choreography */
@keyframes sealPop { 0%{ transform: translateX(-50%) scale(1);} 50%{ transform: translateX(-50%) scale(.86);} 100%{ transform: translateX(-50%) scale(1.06);} }
@keyframes crackL { to { transform: translate(-26px, 40px) rotate(-26deg); opacity: 0; } }
@keyframes crackR { to { transform: translate(20px, 46px) rotate(24deg); opacity: 0; } }
@keyframes sparkle { 0%{ opacity:1; transform: translate(-50%,-50%) scale(.4);} 100%{ opacity:0; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.2);} }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes liningShow { to { opacity: .8; } }
@keyframes flapOpen { 0%{ transform: rotateX(0); } 100%{ transform: rotateX(-168deg); } }
@keyframes floatAway { to { transform: translateY(-120px) scale(.9); opacity: 0; } }
@keyframes garlandBob { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(6px); } }
@keyframes floatUp {
  0%   { transform: translateY(0) scale(.6) rotate(0); opacity: 0; }
  12%  { opacity: .9; }
  85%  { opacity: .9; }
  100% { transform: translateY(-110vh) scale(1) rotate(18deg); opacity: 0; }
}
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes chevBounce { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(5px); } }
@keyframes letterOut {
  0%   { transform: translateX(-50%) translateY(6%) scale(.9);  opacity: 0; }
  22%  { opacity: 1; }
  70%  { transform: translateX(-50%) translateY(-58%) scale(1.5); }
  100% { transform: translateX(-50%) translateY(-62%) scale(1.5); opacity: 1; }
}
@keyframes burstFall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(var(--fall, 60vh)) translateX(var(--drift,0)) rotate(var(--spin,180deg)); opacity: 0; }
}

/* =================================================================
   Responsive
   ================================================================= */
@media (min-width: 600px) {
  .countdown { grid-template-columns: repeat(4, 1fr); }
  .gift-tag {
    grid-template-columns: 1fr;
    grid-template-areas: "swatch" "name" "cta";
    justify-items: center; text-align: center; padding-top: 24px; row-gap: 8px;
  }
  .gift-tag .tag-name, .gift-tag .tag-cta { text-align: center; justify-self: center; align-self: center; }
}
@media (min-width: 900px) {
  .card { width: min(100%, 600px); }
}

/* =================================================================
   Reduced motion — calm, no envelope theatrics
   ================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .15s !important;
    scroll-behavior: auto !important;
  }
  .envelope, .teddy, .cloud, .balloon, .seal::before, .footer-stars i, .moon-motif .star,
  .fab, .cue .chevrons, .garland-img, .intro-title { animation: none !important; }
  .floaties { display: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
  /* Skip the scroll-scrub entirely — show the invitation directly, then the page */
  #reveal { height: auto; }
  #stage {
    position: static; height: auto; min-height: 100svh;
    display: grid; place-items: center; overflow: visible;
    padding: max(24px, env(safe-area-inset-top)) 16px 24px;
  }
  .envelope, .cue, .skip-intro, .fab, .intro-title { display: none !important; }
  .letter {
    position: static; transform: none !important; opacity: 1 !important;
    margin: 0 auto; pointer-events: auto;
  }
}
