/* ============================================================
   hbd.baby — candlelight in the dark
   ============================================================ */

:root {
  --ink:        #f6f0e4;   /* cream paper — the background */
  --ink-2:      #efe7d7;   /* raised panel                */
  --cream:      #33291f;   /* warm near-black — the text  */
  --cream-dim:  #6a5d50;   /* softer body text            */
  --muted:      #a09484;   /* warm taupe for hints        */
  --amber:      #e0994f;   /* candle / warm accent        */
  --peach:      #d9744f;   /* terracotta glow             */
  --rose:       #cf6f86;   /* dusty rose                  */
  --gold:       #d9a94e;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* the hidden attribute must beat the display:grid on .gate/.card below */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- atmosphere ---------- */
.aurora {
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 46% at 26% 28%, rgba(217,116,79,0.20), transparent 72%),
    radial-gradient(36% 42% at 76% 24%, rgba(207,111,134,0.16), transparent 72%),
    radial-gradient(48% 52% at 56% 84%, rgba(224,153,79,0.18), transparent 74%);
  filter: blur(26px) saturate(108%);
  animation: drift 22s var(--ease) infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1);    opacity: .85; }
  50%  { transform: translate3d(2%, 2%, 0)   scale(1.08); opacity: 1;   }
  100% { transform: translate3d(1%, -2%, 0)  scale(1.03); opacity: .9;  }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%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)'/%3E%3C/svg%3E");
}

/* ---------- shared centering ---------- */
.gate, .card {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
}

/* =========================================================
   PIN GATE
   ========================================================= */
.gate__inner {
  max-width: 30rem;
  transition: opacity .6s var(--ease), transform .6s var(--ease), filter .6s var(--ease);
}
.gate.is-leaving .gate__inner {
  opacity: 0;
  transform: translateY(-14px) scale(.97);
  filter: blur(6px);
}
.gate.is-gone { opacity: 0; pointer-events: none; transition: opacity .5s ease; }

.gate__eyebrow {
  font-size: .78rem;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

.gate__title {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.9rem, 6vw, 2.9rem);
  letter-spacing: -0.01em;
  color: var(--cream);
  margin-bottom: 2.2rem;
}

.pin__cells {
  display: flex;
  gap: clamp(.4rem, 2.4vw, .75rem);
  justify-content: center;
}

.pin__cell {
  width: clamp(2.6rem, 12vw, 3.4rem);
  height: clamp(3.4rem, 15vw, 4.4rem);
  border: 1px solid rgba(51,41,31,0.16);
  border-radius: 14px;
  background: rgba(51,41,31,0.03);
  color: var(--cream);
  font-family: var(--serif);
  font-size: clamp(1.5rem, 6vw, 2rem);
  text-align: center;
  outline: none;
  caret-color: var(--peach);
  transition: border-color .25s ease, background .25s ease, box-shadow .25s ease, transform .25s var(--ease);
}
.pin__cell:focus {
  border-color: rgba(217,116,79,0.65);
  background: rgba(217,116,79,0.07);
  box-shadow: 0 0 0 4px rgba(217,116,79,0.12), 0 6px 22px rgba(217,116,79,0.14);
  transform: translateY(-2px);
}
.pin__cell.is-filled { border-color: rgba(51,41,31,0.3); }

.pin__hint {
  margin-top: 1.4rem;
  font-size: .82rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .25s ease;
}
.pin.is-wrong .pin__cells { animation: shake .4s ease; }
.pin.is-wrong .pin__hint  { color: var(--rose); }
.pin.is-wrong .pin__cell  { border-color: rgba(207,111,134,0.6); }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* =========================================================
   THE CARD
   ========================================================= */
.card { display: none; }
.card.is-open { display: grid; }

.confetti {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.card__inner {
  position: relative;
  z-index: 4;
  max-width: 40rem;
}

.card__eyebrow {
  font-size: .78rem;
  letter-spacing: .4em;
  text-transform: uppercase;
  color: var(--peach);
  margin-bottom: 1.6rem;
}

.card__title {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 300;
  line-height: 0.92;
  letter-spacing: -0.02em;
  margin-bottom: 1.9rem;
}
.card__title span { display: block; }
.card__title .reveal:first-child,
.card__name {
  font-size: clamp(2.6rem, 11vw, 5rem);
  color: var(--cream);
}
.card__birthday {
  font-style: italic;
  font-weight: 400;
  font-size: clamp(3.4rem, 17vw, 8rem);
  line-height: 1.08;          /* room for the italic "y" descender */
  padding-bottom: 0.12em;     /* keep the descender inside the clip box */
  background: linear-gradient(105deg, #d98a3f 0%, #d16340 48%, #c85f7e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 34px rgba(209,99,64,0.14);
}

.card__note {
  font-size: clamp(1rem, 2.5vw, 1.18rem);
  line-height: 1.7;
  color: var(--cream-dim);
  max-width: 32rem;
  margin: 0 auto 2.4rem;
}

.card__sign {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  font-size: .8rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--muted);
}

.card__flame {
  width: 9px;
  height: 9px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 65%, var(--gold), var(--peach) 60%, transparent 72%);
  box-shadow: 0 0 12px 3px rgba(255,184,119,0.7), 0 0 22px 6px rgba(255,154,118,0.35);
  animation: flicker 2.4s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: scale(1)    translateY(0);    opacity: 1;   }
  25%      { transform: scale(1.14) translateY(-1px); opacity: .92; }
  50%      { transform: scale(.94)  translateY(1px);  opacity: 1;   }
  75%      { transform: scale(1.08) translateY(-1px); opacity: .95; }
}

/* ---------- photo deck ----------
   Camera looks straight down at the page; each photo falls in from
   behind the camera (large translateZ) and lands on the stack. */
.deck {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  perspective: 1200px;
  perspective-origin: 50% 50%;
}
.deck__card {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: .25in;                 /* the white border */
  background: #fff;
  border-radius: 2px;
  opacity: 0;                     /* JS reveals it as it falls */
  box-shadow: 0 2px 3px rgba(51,41,31,0.18), 0 16px 36px rgba(51,41,31,0.2);
  will-change: transform, opacity;
}
/* fit the whole photo inside ~86% of the width and 62% of the height,
   so portrait and landscape both fill a phone without cropping */
.deck__card img {
  display: block;
  height: min(62vh, calc((86vw - .5in) / var(--ratio, 1.333)));
  width: auto;
  aspect-ratio: var(--ratio, 1.333);
  object-fit: cover;
}

.card__wait {
  margin-top: 1.6rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--muted);
}
.card__wait i { font-style: normal; animation: dot 1.4s ease-in-out infinite; }
.card__wait i:nth-child(2) { animation-delay: .2s; }
.card__wait i:nth-child(3) { animation-delay: .4s; }
@keyframes dot {
  0%, 100% { opacity: .25; }
  40%      { opacity: 1; }
}
/* the <p> is held visible by its reveal animation, so fade the inner span */
.card__wait-text { display: inline-block; transition: opacity .8s ease; }
.card__wait.is-done .card__wait-text { opacity: 0; }

/* ---------- staggered reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
}
.card.is-open .reveal {
  animation: rise 1.1s var(--ease) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes rise {
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora, .card__flame, .card__wait i { animation: none; }
  .reveal { animation: none !important; opacity: 1; transform: none; filter: none; }
}
