@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Outfit";
  src: url("../fonts/Outfit-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FFF6EC;
  --surface: #FBE3D6;
  --text: #3A2730;
  --muted: #7A5A62;
  --pig: #F2A5A5;
  --accent: #B8435F;
  --wing: #BBD6EA;
  --gold: #F2C879;
  --glow: #FBE3D6;
  --shadow: 0 4px 20px rgba(58, 39, 48, 0.08);
  --rule: rgba(58, 39, 48, 0.14);
  --radius: 1rem;
  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2B1D24;
    --surface: #3A2830;
    --text: #FBEBDD;
    --muted: #C9A98F;
    --pig: #F4A7B0;
    --accent: #F2C879;
    --wing: #A9C8E0;
    --glow: #3A2830;
    --shadow: none;
    --rule: rgba(251, 235, 221, 0.14);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 60% 45% at 50% 28%, var(--glow), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

.hero {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.25rem 2.5rem;
}

.logo-wrap {
  margin: 0 0 1.75rem;
  line-height: 0;
  font-size: 1rem;
  transform-origin: 50% 70%;
}
.logo { display: block; width: min(420px, 82vw); height: auto; }

/* ---- countdown ---- */
.stage {
  position: relative;
  width: 100%;
  min-height: 9.5rem; /* one fixed box for timer, finished message and no-JS fallback */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.timer[hidden], .done[hidden], .fallback[hidden] { display: none; }

.timer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  justify-content: center;
  gap: clamp(0.4rem, 2.4vw, 0.9rem);
  max-width: 100%;
}

.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem clamp(0.5rem, 2.6vw, 1.15rem) 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.num {
  font-family: var(--font-head);
  font-weight: 500;
  font-variation-settings: "SOFT" 100;
  font-size: clamp(1.7rem, 8vw, 3.1rem);
  line-height: 1.05;
  color: var(--accent);
  font-variant-numeric: tabular-nums lining-nums;
  text-align: center;
  min-width: 2ch;
}
/* The days tile reserves room for its digit count, set once by JS (--day-digits) */
#cd-d { min-width: calc(var(--day-digits, 2) * 1ch); }

.unit {
  margin-top: 0.3rem;
  font-size: clamp(0.68rem, 2.6vw, 0.85rem);
  color: var(--muted);
}

.fallback { margin: 0; color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- finished state ---- */
.done { position: relative; padding: 0.25rem 1rem 0; }
.done-title {
  font-family: var(--font-head);
  font-weight: 400;
  font-variation-settings: "SOFT" 100;
  font-size: clamp(1.6rem, 5.4vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 0.6rem;
  color: var(--accent);
  text-wrap: balance;
}
.done-text { margin: 0; font-size: 1.1rem; color: var(--muted); }

.sparkles { position: absolute; inset: -1.5rem 0 auto 0; height: 9rem; pointer-events: none; }
.sparkles i {
  position: absolute;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
}
.sparkles i:nth-child(1) { left: 10%; top: 55%; }
.sparkles i:nth-child(2) { left: 22%; top: 15%; width: 0.35rem; height: 0.35rem; background: var(--wing); }
.sparkles i:nth-child(3) { left: 38%; top: 80%; width: 0.4rem; height: 0.4rem; background: var(--pig); }
.sparkles i:nth-child(4) { left: 62%; top: 10%; background: var(--pig); width: 0.4rem; height: 0.4rem; }
.sparkles i:nth-child(5) { left: 78%; top: 70%; width: 0.35rem; height: 0.35rem; background: var(--wing); }
.sparkles i:nth-child(6) { left: 90%; top: 30%; }

/* ---- motion: only when welcome ---- */
@keyframes settle { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bob {
  0%   { transform: translateY(0) rotate(0); }
  30%  { transform: translateY(-10px) rotate(-3deg); }
  60%  { transform: translateY(2px) rotate(2deg); }
  100% { transform: translateY(0) rotate(0); }
}
@keyframes drift {
  0%   { opacity: 0; transform: translateY(8px) scale(0.6); }
  30%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-26px) scale(1); }
}

@media (prefers-reduced-motion: no-preference) {
  .logo-wrap, .stage { animation: settle 0.9s ease both; }
  .stage { animation-delay: 0.12s; }

  .is-complete .logo-wrap { animation: bob 1.5s ease-in-out 0.2s 1; }
  .done { animation: settle 0.9s ease both; }
  .sparkles i { animation: drift 4.5s ease-out infinite; }
  .sparkles i:nth-child(2) { animation-delay: 0.7s; }
  .sparkles i:nth-child(3) { animation-delay: 1.4s; }
  .sparkles i:nth-child(4) { animation-delay: 2.1s; }
  .sparkles i:nth-child(5) { animation-delay: 2.8s; }
  .sparkles i:nth-child(6) { animation-delay: 3.5s; }
}
@media (prefers-reduced-motion: reduce) {
  .sparkles i { opacity: 0.55; } /* still dots, no movement */
}

.footer {
  padding: 1.25rem 1.5rem 1.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}
.footer p { margin: 0; }
