/* =========================================================
   Birthday site styles. Every colour lives in :root below.
   ========================================================= */
:root {
  --bg: #1d0912;          /* deepest plum */
  --wine: #4a1230;        /* wine */
  --plum: #2a0a1a;
  --rose: #e8557a;
  --rose-deep: #a8284b;
  --blush: #ffd6e0;
  --gold: #f2c46d;
  --paper: #fff3e4;       /* love-letter paper */
  --ink: #4a2230;         /* text on paper */
  --text: #fff1f5;
  --card: rgba(255, 214, 224, .07);
  --line: rgba(255, 214, 224, .16);
  --f-script: "Great Vibes", cursive;
  --f-serif: "Cormorant Garamond", Georgia, serif;
  --f-body: "Poppins", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html.locked { overflow: hidden; }
body {
  font-family: var(--f-body);
  font-weight: 300;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--wine), var(--bg) 900px);
  background-repeat: no-repeat;
  overflow-x: hidden;
  min-height: 100vh;
}
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- Canvas layers ---------- */
canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#bg { z-index: 0; }
#fx { z-index: 80; }

/* ---------- Layout ---------- */
section {
  position: relative; z-index: 1;
  max-width: 1040px; margin: 0 auto;
  padding: clamp(64px, 12vw, 110px) 20px;
}
h2 {
  font-family: var(--f-script); font-weight: 400; text-align: center;
  font-size: clamp(2.6rem, 9vw, 4.2rem); line-height: 1.15;
  color: var(--blush); margin-bottom: 36px;
}
.eyebrow { text-align: center; text-transform: uppercase; letter-spacing: .3em; font-size: .75rem; color: var(--gold); margin-bottom: 18px; }
.hint { text-align: center; font-size: .85rem; opacity: .65; margin: -20px 0 28px; letter-spacing: .05em; }
.btn {
  display: block; margin: 22px auto 0; padding: 12px 28px; border-radius: 99px;
  background: linear-gradient(135deg, var(--rose), var(--rose-deep)); color: #fff; font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .4); transition: transform .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn[hidden] { display: none; }

/* ---------- Icons (inline SVG, inherit text colour) ---------- */
.ico { display: inline-flex; width: 1em; height: 1em; vertical-align: -.14em; }
.ico svg { width: 100%; height: 100%; }
.ico.fill svg { fill: currentColor; }

/* ---------- Scroll progress + reveal ---------- */
#progress { position: fixed; inset: 0 0 auto 0; z-index: 85; height: 3px; transform: scaleX(0); transform-origin: left; pointer-events: none;
  background: linear-gradient(90deg, var(--rose), var(--gold)); }
.js .reveal { opacity: 0; transform: translateY(40px) scale(.97); transition: opacity 1.1s cubic-bezier(.22, 1, .36, 1), transform 1.1s cubic-bezier(.22, 1, .36, 1); transition-delay: var(--d, 0s); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- 1. Envelope intro ---------- */
#gate {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px;
  background: linear-gradient(180deg, var(--plum), var(--wine));
  transition: opacity 1s ease, visibility 1s;
}
#gate.gone { opacity: 0; visibility: hidden; }
#gateText { font-family: var(--f-script); font-size: clamp(1.8rem, 7vw, 2.6rem); color: var(--blush); text-align: center; padding: 0 20px; }

.envelope { position: relative; width: min(320px, 78vw); aspect-ratio: 3 / 2; perspective: 900px; animation: bob 3.2s ease-in-out infinite; }
.envelope > span { position: absolute; display: block; }
.env-back { inset: 0; background: linear-gradient(160deg, #c9446a, #8f1f40); border-radius: 8px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.envelope > .env-card { z-index: 1; left: 6%; right: 6%; top: 8%; height: 80%; background: var(--paper); border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 12px;
  font-family: var(--f-script); line-height: 1.15; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transition: transform 1.1s cubic-bezier(.22, 1, .36, 1) .55s; }
.env-msg { display: block; opacity: 0; transform: translateY(10px); transition: opacity 1s ease, transform 1s cubic-bezier(.22, 1, .36, 1); }
.env-hi { font-size: 2rem; color: var(--wine); transition-delay: .8s; }
.env-name { font-size: 2.4rem; color: var(--rose-deep); transition-delay: 1.3s; }
/* Front pocket: left, right and bottom triangles */
.env-front { z-index: 2; inset: 0; background: linear-gradient(160deg, #d9577a, #a8284b); border-radius: 8px;
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%); }
.env-flap { left: 0; right: 0; top: 0; height: 56%; z-index: 3; background: linear-gradient(#e0607f, #b8335a);
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .9s cubic-bezier(.45, 0, .2, 1), z-index 0s .45s; }
.env-seal { left: 50%; top: 56%; z-index: 4; font-size: 2.4rem; line-height: 1; color: var(--blush); transform: translate(-50%, -50%); transition: opacity .3s; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
.envelope.open { animation-play-state: paused; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-seal { opacity: 0; }
/* 1) card slides fully out of the pocket */
.envelope.open .env-card { transform: translateY(-92%); }
/* 2) envelope fades, card settles in the centre, then the message is revealed */
.envelope.read .env-back, .envelope.read .env-front, .envelope.read .env-flap { opacity: 0; transition: opacity 1s ease .1s, transform .9s cubic-bezier(.45, 0, .2, 1); }
.envelope.read .env-card { z-index: 5; transform: translateY(-8%) scale(1.3); transition: transform 1.2s cubic-bezier(.65, 0, .35, 1); }
.envelope.read .env-msg { opacity: 1; transform: none; }
#gateText { transition: opacity .8s ease; }
.envelope.read ~ #gateText { opacity: 0; }
@keyframes bob { 50% { transform: translateY(-12px); } }

/* ---------- 2. Hero ---------- */
#hero { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#hero h1 {
  font-family: var(--f-script); font-weight: 400; line-height: 1.12;
  font-size: clamp(3.4rem, 15vw, 8rem); padding: 0 .1em .12em;
  background: linear-gradient(100deg, var(--blush), var(--rose), var(--gold), var(--blush), var(--rose));
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 7s linear infinite;
}
#hero h1 span { display: block; }
@keyframes shimmer { to { background-position: -250% 0; } }
.tagline { font-family: var(--f-serif); font-style: italic; font-size: clamp(1.2rem, 4vw, 1.7rem); max-width: 30ch; margin-top: 14px; color: var(--blush); }
.scroll { margin-top: 56px; font-size: .8rem; letter-spacing: .2em; color: inherit; text-decoration: none; text-transform: lowercase; opacity: .55; animation: bob 2.4s ease-in-out infinite; }

/* ---------- 3. Counter ---------- */
.counter { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 2.5vw, 18px); max-width: 640px; margin: 0 auto; }
.counter > div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: clamp(14px, 4vw, 26px) 4px; text-align: center; backdrop-filter: blur(6px); }
.counter b { display: block; font-weight: 500; font-size: clamp(1.5rem, 7vw, 2.8rem); line-height: 1.1; color: var(--rose); font-variant-numeric: tabular-nums; }
.counter span { font-size: clamp(.58rem, 2.4vw, .75rem); text-transform: uppercase; letter-spacing: .15em; opacity: .7; }
.sub { text-align: center; margin-top: 26px; font-family: var(--f-serif); font-style: italic; font-size: clamp(1.2rem, 4vw, 1.5rem); color: var(--blush); }

/* ---------- 4. Gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 34px 26px; padding: 0 6px; }
.polaroid { background: #fff; padding: 12px 12px 0; border-radius: 3px; box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.polaroid { --rot: -2.5deg; transform: rotate(var(--rot)); }
.polaroid:nth-child(even) { --rot: 2.2deg; }
.js .polaroid.reveal { transform: translateY(40px) rotate(var(--rot)) scale(.96); }
.js .polaroid.reveal.in { transform: rotate(var(--rot)); }
.polaroid:hover, .js .polaroid.reveal.in:hover { transform: rotate(0) scale(1.03); z-index: 2; transition-delay: 0s; }
.polaroid .photo { aspect-ratio: 4 / 5; background: linear-gradient(135deg, var(--blush), var(--rose) 60%, var(--rose-deep)); display: grid; place-items: center; overflow: hidden; font-size: 2.6rem; }
.polaroid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.polaroid figcaption { font-family: var(--f-script); font-size: 1.7rem; line-height: 1.2; color: var(--wine); text-align: center; padding: 12px 6px 16px; min-height: 3.4rem; }

/* ---------- 5. Reasons (3D flip cards) ---------- */
.reasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 14px; }
.flip { perspective: 900px; height: 190px; display: block; }
.flip-in { display: block; position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.4, .2, .2, 1); }
.flip.flipped .flip-in { transform: rotateY(180deg); }
.flip .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; display: grid; place-items: center; padding: 14px; text-align: center; }
.flip .front { background: linear-gradient(145deg, var(--rose), var(--rose-deep)); font-size: 2.8rem; color: var(--blush); box-shadow: 0 10px 28px rgba(0, 0, 0, .35); }
.flip .back { transform: rotateY(180deg); background: var(--blush); color: var(--ink); font-family: var(--f-serif); font-weight: 600; font-size: clamp(1.05rem, 4vw, 1.25rem); line-height: 1.3; }

/* ---------- 6. Timeline ---------- */
.timeline { position: relative; list-style: none; max-width: 900px; margin: 0 auto; padding-left: 36px; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--rose), var(--gold)); }
.tl { position: relative; margin-bottom: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; backdrop-filter: blur(6px); }
.tl::before { content: ""; position: absolute; left: -36px; top: 18px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--rose);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e8557a' d='M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z'/%3E%3C/svg%3E") center / 10px no-repeat; }
.tl time { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.tl h3 { font-family: var(--f-serif); font-weight: 600; font-size: 1.55rem; line-height: 1.2; margin: 4px 0 6px; color: var(--blush); }
.tl p { font-size: .95rem; opacity: .85; }
@media (min-width: 800px) {
  .timeline { padding-left: 0; }
  .timeline::before { left: 50%; margin-left: -1px; }
  .tl { width: calc(50% - 40px); }
  .tl:nth-child(even) { margin-left: auto; }
  .tl::before { left: auto; right: -52px; }
  .tl:nth-child(even)::before { right: auto; left: -52px; }
}

/* ---------- 7. Love letter ---------- */
.paper {
  max-width: 680px; margin: 0 auto; padding: clamp(28px, 7vw, 56px) clamp(22px, 6vw, 52px);
  background: var(--paper); color: var(--ink); border-radius: 6px;
  background-image: repeating-linear-gradient(transparent 0 33px, rgba(168, 40, 75, .08) 33px 34px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.letter-text { font-family: var(--f-serif); font-size: clamp(1.15rem, 4.2vw, 1.45rem); line-height: 34px; white-space: pre-wrap; }
.letter-text .rest { visibility: hidden; }
.letter-text.typing .typed::after { content: "|"; color: var(--rose); animation: blink .8s steps(1) infinite; }
.signature { font-family: var(--f-script); font-size: clamp(2rem, 8vw, 2.8rem); color: var(--rose-deep); margin-top: 18px; text-align: right; opacity: 0; transition: opacity 1s; }
.signature.show { opacity: 1; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 8. Cake (all sizes in em, scaled via font-size) ---------- */
#cake-section { text-align: center; }
.cake { position: relative; width: 24em; height: 25em; margin: 18px auto 0; font-size: clamp(10px, 3.4vw, 16px); cursor: pointer; }
.cake span { position: absolute; display: block; }
.plate { left: 0; right: 0; bottom: 0; height: 2em; border-radius: 50%; background: linear-gradient(#f4e9ee, #cdb9c2); box-shadow: 0 1em 2em rgba(0, 0, 0, .45); }
.layer { left: 50%; transform: translateX(-50%); border-radius: 1em 1em .5em .5em; overflow: hidden; box-shadow: inset 0 -.6em 1em rgba(0, 0, 0, .18); }
/* Scalloped icing along the top of every layer */
.layer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1.8em;
  background: radial-gradient(circle at 1em 0, var(--blush) .95em, transparent 1em) 0 0 / 2em 1.8em repeat-x; }
.l1 { bottom: .9em; width: 21em; height: 7em; background: linear-gradient(#7a2a45, #55162f); }
.l2 { bottom: 7.9em; width: 16em; height: 6em; background: linear-gradient(var(--rose), var(--rose-deep)); }
.l3 { bottom: 13.9em; width: 11em; height: 5em; background: linear-gradient(#f7b3c6, #e08aa3); }
.l1::after, .l2::after { content: ""; position: absolute; inset: 2.2em 0 0;
  background: radial-gradient(circle, var(--gold) .22em, transparent .26em) 0 0 / 2.4em 1.8em; opacity: .55; }
.candle { bottom: 18.9em; width: .9em; height: 3.4em; border-radius: .2em; background: repeating-linear-gradient(135deg, #fff 0 .5em, var(--gold) .5em 1em); }
.c1 { left: calc(50% - 3em); } .c2 { left: calc(50% - .45em); height: 4em; } .c3 { left: calc(50% + 2.1em); }
.flame { position: absolute; left: 50%; bottom: 100%; margin: 0 0 .15em -.45em; width: .9em; height: 1.7em; transform-origin: 50% 90%;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; background: radial-gradient(ellipse at 50% 75%, #fff6c9, var(--gold) 55%, #ff8a3d);
  box-shadow: 0 0 1em .3em rgba(242, 196, 109, .55); animation: flicker .35s ease-in-out infinite alternate; transition: opacity .4s, transform .4s; }
.c2 .flame { animation-duration: .42s; } .c3 .flame { animation-duration: .3s; }
@keyframes flicker { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(.9, 1.1) rotate(3deg); } }
.cake.out .flame { opacity: 0; transform: scale(0); animation: none; }
/* A wisp of smoke after blowing out */
.candle::after { content: ""; position: absolute; left: 50%; bottom: 100%; width: .5em; height: 1.4em; margin-left: -.25em; border-radius: 50%; background: rgba(255, 255, 255, .5); filter: blur(.3em); opacity: 0; }
.cake.out .candle::after { animation: smoke 1.8s ease-out; }
@keyframes smoke { 0% { opacity: .7; transform: translateY(0) scaleX(1); } 100% { opacity: 0; transform: translateY(-3em) scaleX(2.2); } }
.wish { font-family: var(--f-script); font-size: clamp(2rem, 8vw, 3rem); color: var(--gold); margin-top: 24px; opacity: 0; transform: translateY(12px); transition: opacity .8s, transform .8s; min-height: 1.4em; }
.wish.show { opacity: 1; transform: none; }

/* ---------- 9. Footer ---------- */
footer { position: relative; z-index: 1; text-align: center; padding: 60px 20px 110px; font-family: var(--f-script); font-size: clamp(2rem, 8vw, 3rem); color: var(--blush); }
footer b { color: var(--rose); font-weight: 400; }

/* ---------- Music button ---------- */
.music { position: fixed; z-index: 90; right: 16px; bottom: 16px; width: 52px; height: 52px; border-radius: 50%; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--rose), var(--rose-deep)); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.music[aria-pressed="true"] { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 8px 24px rgba(0, 0, 0, .5), 0 0 0 10px rgba(255, 255, 255, .12); } }

/* ---------- Reduced motion: no movement, content simply appears ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .js .reveal { opacity: 1; transform: none; }
}
