/* =========================================================
   THANKSGIVING — AUTUMN HARVEST RUSTIC THEME VARIABLES
   ========================================================= */
:root {
  --bg-espresso: #1c0c04;
  --bg-chestnut: #3b1c0b;
  --burnt-orange: #d45b18;
  --mustard: #e6a938;
  --parchment: #fbf1df;
  --muted: rgba(251, 241, 223, 0.72);

  --card-bg: linear-gradient(160deg, rgba(72, 34, 14, 0.82), rgba(38, 17, 7, 0.92));
  --card-border: rgba(230, 169, 56, 0.45);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Bitter", Georgia, serif;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 22%, #592a11 0%, var(--bg-chestnut) 46%, var(--bg-espresso) 100%);
  color: var(--parchment);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.autumn-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.hearth-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(230, 169, 56, 0.16), transparent 52%),
    radial-gradient(ellipse at 82% 28%, rgba(212, 91, 24, 0.2), transparent 55%);
}

.harvest-border {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: clamp(90px, 18vh, 190px);
}

/* Controls */
.controls {
  position: fixed;
  top: clamp(14px, 2.5vw, 24px);
  right: clamp(14px, 2.5vw, 24px);
  z-index: 25;
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--card-border);
  background: rgba(44, 20, 8, 0.78);
  color: var(--mustard);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.ctrl-btn svg { width: 18px; height: 18px; }
.ctrl-btn:hover, .ctrl-btn:focus-visible {
  transform: translateY(-2px);
  background: rgba(212, 91, 24, 0.45);
  outline: none;
}
.ctrl-btn[aria-pressed="true"] { background: var(--mustard); color: #241005; }

#sound-btn .icon-on { display: none; }
#sound-btn[aria-pressed="true"] .icon-on { display: block; }
#sound-btn[aria-pressed="true"] .icon-off { display: none; }
#fullscreen-btn .icon-compress { display: none; }
body.is-fullscreen #fullscreen-btn .icon-compress { display: block; }
body.is-fullscreen #fullscreen-btn .icon-expand { display: none; }

.toast {
  position: fixed;
  top: 72px;
  right: clamp(14px, 2.5vw, 24px);
  z-index: 30;
  padding: 9px 16px;
  border-radius: 8px;
  background: rgba(46, 22, 9, 0.94);
  border: 1px solid var(--mustard);
  color: var(--parchment);
  font-size: 0.84rem;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Stage */
.stage {
  position: relative;
  z-index: 10;
  width: min(920px, 92vw);
  padding: clamp(32px, 5vh, 56px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 3vh, 30px);
}

.hero-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.wheat-divider {
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--mustard);
}

.eyebrow {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8.2vw, 5.8rem);
  font-weight: 800;
  line-height: 1.04;
  background: linear-gradient(180deg, #fff8eb 0%, #f5c86b 55%, #d46b24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.55));
}

.milestone-badge {
  margin-top: 4px;
  padding: 6px 18px;
  border-radius: 6px;
  background: rgba(212, 91, 24, 0.28);
  border: 1px dashed var(--mustard);
  color: #fff3da;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Stitched Rustic Harvest Cards */
.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 2.2vw, 22px);
  width: 100%;
}

.harvest-card {
  position: relative;
  padding: clamp(22px, 3.4vw, 36px) 10px clamp(16px, 2.4vw, 24px);
  border-radius: 14px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  box-shadow: 0 20px 42px rgba(15, 6, 2, 0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.28s ease, border-color 0.28s ease;
}

.harvest-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 8px;
  border: 1px dashed rgba(230, 169, 56, 0.35);
  pointer-events: none;
}

.harvest-card:hover {
  transform: translateY(-4px);
  border-color: var(--mustard);
}

body.final-ten .harvest-card[data-unit="seconds"] {
  transform: scale(1.08);
  border-color: var(--mustard);
  box-shadow: 0 0 42px rgba(230, 169, 56, 0.55);
}

.digits {
  display: inline-flex;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6.2vw, 4.7rem);
  font-weight: 800;
  line-height: 1.06;
  color: #fff6e6;
}

.digit-slot {
  position: relative;
  display: inline-block;
  width: 0.65em;
  height: 1.15em;
  overflow: hidden;
}

.digit-char {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.digit-char.enter { transform: translateY(75%); opacity: 0; }
.digit-char.active {
  transform: translateY(0%);
  opacity: 1;
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
.digit-char.exit {
  transform: translateY(-75%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.24s ease;
}

.unit-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mustard);
}

.final-pulse {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(10rem, 30vw, 24rem);
  font-weight: 800;
  color: rgba(230, 169, 56, 0.16);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}
.final-pulse.pop { animation: harvestPop 0.9s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes harvestPop {
  0% { opacity: 0; transform: scale(0.68); }
  25% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.24); }
}

/* Progress */
.progress-wrap {
  width: min(580px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--muted);
}

#progress-percent { color: var(--mustard); font-weight: 700; }

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 245, 224, 0.1);
  border: 1px solid rgba(230, 169, 56, 0.35);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #96340c, var(--burnt-orange), var(--mustard));
  transition: width 0.8s ease;
}

.fact-line {
  max-width: 58ch;
  min-height: 2.8em;
  font-style: italic;
  font-size: clamp(0.96rem, 1.75vw, 1.18rem);
  line-height: 1.5;
  color: rgba(251, 241, 223, 0.9);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.fact-line.fading { opacity: 0; transform: translateY(5px); }

/* Celebration */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(212, 91, 24, 0.36), rgba(28, 12, 4, 0.86));
  backdrop-filter: blur(8px);
}
.celebration[hidden] { display: none; }

.celebration-card {
  max-width: 660px;
  padding: clamp(32px, 6vw, 56px) clamp(24px, 5vw, 48px);
  border-radius: 20px;
  background: rgba(44, 20, 8, 0.92);
  border: 2px solid var(--mustard);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.celebration-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  color: var(--mustard);
}

.celebration-sub {
  font-style: italic;
  font-size: clamp(1.02rem, 1.8vw, 1.24rem);
  color: var(--parchment);
  max-width: 40ch;
}

.celebration-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mustard);
}

@media (max-width: 680px) {
  .countdown { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 380px; }
}

@media (prefers-reduced-motion: reduce) {
  .final-pulse.pop { animation: none !important; }
  .digit-char.active, .digit-char.exit, .fact-line, .progress-fill { transition: none !important; }
}
