/* =========================================================
   CHRISTMAS COUNTDOWN — WHITE & RED THEME VARIABLES
   Edit these variables to customize colors & glow easily.
   ========================================================= */
:root {
  --bg-top: #38050d;
  --bg-mid: #7a0d1c;
  --bg-bottom: #a81427;

  --crimson: #b31226;
  --crimson-bright: #e6263e;
  --crimson-deep: #6b0815;
  --snow: #ffffff;
  --snow-soft: #fff2f4;
  --blush-frost: #ffd6dc;
  --muted: rgba(255, 242, 244, 0.84);

  --card-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 238, 241, 0.88));
  --card-border: rgba(255, 255, 255, 0.95);
  --card-glow: rgba(255, 255, 255, 0.28);
  --card-ink: #9c0f22;

  --font-display: "Cinzel Decorative", "Playfair Display", Georgia, serif;
  --font-serif: "Playfair Display", Georgia, serif;
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

/* Reset & Base */
*,
*::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% 18%, var(--bg-bottom) 0%, var(--bg-mid) 48%, var(--bg-top) 100%);
  color: var(--snow);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

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

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

/* Snowy Red & White Winter Scenery */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.aurora {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 60vh;
  background:
    radial-gradient(ellipse at 25% 30%, rgba(255, 255, 255, 0.22), transparent 60%),
    radial-gradient(ellipse at 75% 20%, rgba(255, 72, 96, 0.34), transparent 55%),
    radial-gradient(ellipse at 50% 10%, rgba(255, 224, 230, 0.22), transparent 50%);
  filter: blur(36px);
  animation: auroraDrift 14s ease-in-out infinite alternate;
}

@keyframes auroraDrift {
  0% { transform: translateX(-2%) scale(1); opacity: 0.85; }
  100% { transform: translateX(3%) scale(1.06); opacity: 1; }
}

/* Twinkling Garland */
.garland {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: clamp(56px, 9vw, 108px);
}

.garland-wire {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 2;
}

.bulb {
  animation: bulbTwinkle 3.2s ease-in-out infinite;
}

.bulb-snow {
  fill: #ffffff;
  filter: drop-shadow(0 0 9px #ffffff);
}

.bulb-red {
  fill: #ff3b52;
  filter: drop-shadow(0 0 10px #ff1e3a);
  animation-delay: 0.7s;
}

.bulb-warm {
  fill: #ffe8eb;
  filter: drop-shadow(0 0 9px #ffffff);
  animation-delay: 1.4s;
}

@keyframes bulbTwinkle {
  0%, 100% { opacity: 0.56; }
  50% { opacity: 1; }
}

/* Horizon & Frosted White Tree */
.winter-horizon {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: clamp(160px, 30vh, 330px);
}

.tree-star {
  filter: drop-shadow(0 0 14px #ffffff);
  animation: starPulse 2.8s ease-in-out infinite;
}

@keyframes starPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.tree-light {
  fill: #d91c34;
  filter: drop-shadow(0 0 6px rgba(217, 28, 52, 0.75));
  animation: bulbTwinkle 2.4s ease-in-out infinite;
}

.tree-light.l2,
.tree-light.l6,
.tree-light.l9 {
  fill: #ff334b;
  filter: drop-shadow(0 0 7px #ff1f3a);
  animation-delay: 0.8s;
}

.tree-light.l4,
.tree-light.l8 {
  fill: #ffffff;
  filter: drop-shadow(0 0 7px #ffffff);
  animation-delay: 1.5s;
}

.tree-light.l3,
.tree-light.l7 {
  fill: #b81226;
  animation-delay: 0.4s;
}

/* Floating Controls */
.controls {
  position: fixed;
  top: clamp(14px, 2.5vw, 26px);
  right: clamp(14px, 2.5vw, 26px);
  z-index: 20;
  display: flex;
  gap: 10px;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(94, 10, 22, 0.58);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--snow);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ctrl-btn svg {
  width: 19px;
  height: 19px;
}

.ctrl-btn:hover,
.ctrl-btn:focus-visible {
  transform: translateY(-2px);
  background: var(--snow);
  border-color: var(--snow);
  color: var(--crimson);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.45);
  outline: none;
}

.ctrl-btn[aria-pressed="true"] {
  background: var(--snow);
  border-color: var(--snow);
  color: var(--crimson);
}

#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 */
.toast {
  position: fixed;
  top: 74px;
  right: clamp(14px, 2.5vw, 26px);
  z-index: 30;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--snow);
  border: 1.5px solid var(--crimson-bright);
  color: var(--crimson-deep);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 26px rgba(40, 2, 10, 0.35);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Main Stage */
.stage {
  position: relative;
  z-index: 10;
  width: min(960px, 92vw);
  padding: clamp(56px, 8vh, 84px) 0 clamp(44px, 6vh, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(20px, 3.2vh, 34px);
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(0.76rem, 1.3vw, 0.95rem);
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--blush-frost);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.38);
}

.star-ornament {
  font-size: 0.85em;
  color: var(--snow);
}

.title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7.6vw, 5.4rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 0%, #fff2f4 65%, #ffd1d8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(56, 5, 13, 0.6));
}

/* Milestone Badge (100, 50, 10, 1 days) */
.milestone-badge {
  margin-top: 4px;
  padding: 7px 18px;
  border-radius: 999px;
  background: var(--snow);
  border: 1.5px solid var(--blush-frost);
  color: var(--crimson);
  font-size: clamp(0.78rem, 1.3vw, 0.92rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.45);
  animation: milestoneGlow 2s ease-in-out infinite;
}

@keyframes milestoneGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 18px rgba(255, 255, 255, 0.35); }
  50% { transform: scale(1.04); box-shadow: 0 0 34px rgba(255, 255, 255, 0.72); }
}

/* Countdown Grid */
.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.8vw, 20px);
  width: 100%;
}

.separator {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4.5vw, 3.6rem);
  color: rgba(255, 255, 255, 0.72);
  transform: translateY(-12px);
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.35);
}

/* Frosted Snow-White & Red Glass Ornament Cards */
.unit-card {
  position: relative;
  flex: 1 1 0;
  max-width: 196px;
  min-width: 72px;
  padding: clamp(18px, 3vw, 32px) clamp(10px, 1.8vw, 20px) clamp(14px, 2.2vw, 22px);
  border-radius: 22px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 20px 44px rgba(56, 5, 13, 0.42),
    inset 0 1px 0 #ffffff,
    0 0 28px var(--card-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.3vh, 14px);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.unit-card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 16px;
  border: 1px solid rgba(179, 18, 38, 0.22);
  pointer-events: none;
}

/* Crimson Ornament Cap at Top of Each Card */
.ornament-cap {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 10px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(90deg, #8c0c1c, #e6263e, #8c0c1c);
  box-shadow: 0 2px 10px rgba(179, 18, 38, 0.45);
}

.ornament-cap::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 10px;
  border: 2px solid var(--snow);
  border-radius: 50%;
}

.unit-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 24px 52px rgba(56, 5, 13, 0.48),
    0 0 40px rgba(255, 255, 255, 0.42);
}

/* Smooth Rolling Digit Slots */
.digits {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 6.2vw, 4.7rem);
  font-weight: 700;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  color: var(--card-ink);
  text-shadow: 0 2px 12px rgba(179, 18, 38, 0.16);
}

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

.digit-char {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  will-change: transform, opacity;
}

.digit-char.enter {
  transform: translateY(85%);
  opacity: 0;
}

.digit-char.active {
  transform: translateY(0%);
  opacity: 1;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease;
}

.digit-char.exit {
  transform: translateY(-85%);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.unit-label {
  font-size: clamp(0.68rem, 1.1vw, 0.85rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--crimson);
}

/* Dramatic Final 10-Second Mode */
body.final-ten .unit-card {
  border-color: #ffffff;
  box-shadow:
    0 0 42px rgba(255, 255, 255, 0.55),
    inset 0 0 18px rgba(230, 38, 62, 0.18);
}

body.final-ten .unit-card[data-unit="seconds"] {
  transform: scale(1.09);
  background: linear-gradient(160deg, #e6263e, #a81023);
  border-color: #ffffff;
  box-shadow: 0 0 56px rgba(255, 255, 255, 0.65);
}

body.final-ten .unit-card[data-unit="seconds"] .digits,
body.final-ten .unit-card[data-unit="seconds"] .unit-label {
  color: #ffffff;
}

.final-pulse {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(9rem, 28vw, 24rem);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.18);
  text-shadow: 0 0 60px rgba(255, 255, 255, 0.4);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: scale(0.75);
}

.final-pulse.pop {
  animation: finalNumberPop 0.92s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes finalNumberPop {
  0% { opacity: 0; transform: scale(0.65); }
  25% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.28); }
}

/* Milestone Shimmer State */
body.milestone-active .unit-card {
  box-shadow:
    0 20px 44px rgba(56, 5, 13, 0.45),
    0 0 44px rgba(255, 255, 255, 0.48);
}

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

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(0.75rem, 1.2vw, 0.88rem);
  color: var(--muted);
  letter-spacing: 0.05em;
}

#progress-percent {
  color: var(--snow);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.45);
  overflow: visible;
}

.progress-fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff596e, #ffd1d8 48%, #ffffff);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.6);
  transition: width 0.8s ease;
}

.progress-star {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: #ffffff;
  text-shadow: 0 0 12px #ffffff;
}

/* Rotating Fun Fact */
.fact-line {
  max-width: 60ch;
  min-height: 2.8em;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(0.98rem, 1.8vw, 1.24rem);
  line-height: 1.5;
  color: #ffffff;
  text-shadow: 0 2px 14px rgba(56, 5, 13, 0.72);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.fact-line.fading {
  opacity: 0;
  transform: translateY(6px);
}

/* Full-Screen Celebration Overlay */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 45%, rgba(179, 18, 38, 0.48), rgba(56, 5, 13, 0.84));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.8s ease forwards;
}

.celebration[hidden] {
  display: none;
}

.celebration-card {
  max-width: 720px;
  padding: clamp(32px, 6vw, 60px) clamp(24px, 5vw, 52px);
  border-radius: 30px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.96), rgba(255, 236, 240, 0.92));
  border: 2px solid #ffffff;
  box-shadow:
    0 24px 80px rgba(45, 3, 10, 0.55),
    0 0 60px rgba(255, 255, 255, 0.35);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.celebration-star {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  color: var(--crimson);
  text-shadow: 0 0 22px rgba(230, 38, 62, 0.45);
  animation: starPulse 1.8s ease-in-out infinite;
}

.celebration-kicker {
  font-size: clamp(0.78rem, 1.3vw, 0.96rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--crimson);
}

.celebration-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: 1.1;
  background: linear-gradient(180deg, #d91c34 0%, #9c0f22 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.celebration-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: #5c101b;
  max-width: 40ch;
}

.celebration-hint {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--crimson-bright);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 680px) {
  .countdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 14px;
    max-width: 390px;
  }

  .separator {
    display: none;
  }

  .unit-card {
    max-width: none;
    padding: 20px 10px 16px;
  }

  .digits {
    font-size: clamp(2.25rem, 11vw, 3.2rem);
  }
}

@media (min-width: 1800px) {
  .stage {
    width: min(1320px, 86vw);
    gap: 44px;
  }

  .unit-card {
    max-width: 260px;
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .aurora,
  .bulb,
  .tree-star,
  .tree-light,
  .milestone-badge,
  .celebration-star {
    animation: none !important;
  }

  .digit-char.active,
  .digit-char.exit,
  .fact-line,
  .progress-fill {
    transition: none !important;
  }
}
