/* ---------- Thanksgiving (November only, see theme.js and thanksgiving.js) ----------
   Everything here is scoped to html.thanksgiving, so the regular site (and
   Halloween) are untouched the rest of the year. The scene is a 390x760 design
   box scaled by --u, exactly like the Halloween house. */

/* The fixed .sky layer sits at z-index -1, so the body's own background would
   paint over it (same note as the Halloween block in style.css). */
html.thanksgiving { background: #2b0c1b; }
html.thanksgiving body { background: transparent; }

html.thanksgiving .sky {
  background:
    radial-gradient(60% 36% at 50% 100%, rgba(255, 150, 70, 0.22), transparent 70%),
    linear-gradient(180deg, #2b0c1b 0%, #3d1426 62%, #4d1b2c 100%);
  -webkit-mask-image: none;
  mask-image: none;
}

/* Leaderboard page: warmer, blurred backing for the panels. */
html.thanksgiving .board-row,
html.thanksgiving .tabs,
html.thanksgiving .boost-panel,
html.thanksgiving .arcade-panel,
html.thanksgiving .signup {
  background: rgba(43, 12, 27, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* The scene is 760 tall in design units, so fit it by that. */
html.thanksgiving { --u: min(calc(100vw / 390), calc(100svh / 760), 1.3px); }

html.thanksgiving body:has(> .stage) {
  padding: 0;
  justify-content: center;
  overflow: hidden;
}

/* No overflow clipping on the stage: the wall, tablecloth and table are drawn
   far wider/taller than the scene so they fill any window; the body clips. */
html.thanksgiving .stage {
  flex: none;
  position: relative;
  display: block;
  width: calc(390 * var(--u));
  max-width: none;
  height: calc(760 * var(--u));
  margin: 0 auto;
}

/* No wheel, ring or hub: the dome and wishbone replace them. Only the head
   that landed (.is-active) is shown, on the body. */
html.thanksgiving .controls,
html.thanksgiving .hub,
html.thanksgiving .orbit,
html.thanksgiving .spotlight,
html.thanksgiving .figure::after {
  display: none;
}

html.thanksgiving .ring-head:not(.is-active) {
  display: none;
}

/* Shoes stand on the platter (y ~628 of 760): the Thanksgiving body's last
   opaque row is 1503/1536, so with the body offset below the shoes end at
   top + 316.6u. */
html.thanksgiving .figure {
  position: absolute;
  left: calc(95 * var(--u));
  top: calc(311.5 * var(--u));
  margin: 0;
  z-index: 2;
}

/* thanksgiving_body has its neck 26 rows (1.7%) HIGHER in the image than
   body.png (neck first reaches 128px wide at row 40 vs 66, out of 1536), so it
   gets the regular body's 6% plus that 1.7%. Its neck centreline is x~502 of
   1024 (body.png: ~500), so the centring shift is 1.0% instead of 1.17%. The
   per-head --chin-dy nudges in style.css then apply unchanged. */
html.thanksgiving .body-img {
  translate: 1% 7.7%;
}

/* ---- the room ---- */

.tg-room {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.tg-room svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tg-flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: tg-flicker var(--fd, 1.2s) ease-in-out infinite alternate;
}

@keyframes tg-flicker {
  0% { transform: scale(1, 1) rotate(-2deg); opacity: 1; }
  50% { transform: scale(0.92, 1.1) rotate(2deg); opacity: 0.92; }
  100% { transform: scale(1.05, 0.94) rotate(-1deg); opacity: 1; }
}

/* Warm light behind the figure; fades in while the dome is up. */
.tg-glow {
  position: absolute;
  left: calc(5 * var(--u));
  top: calc(180 * var(--u));
  width: calc(380 * var(--u));
  height: calc(490 * var(--u));
  z-index: 1;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
  background: radial-gradient(50% 50% at 50% 55%, rgba(255, 196, 96, 0.6), rgba(255, 140, 50, 0.18) 55%, transparent 76%);
}

.stage.door-open .tg-glow { opacity: 1; }

/* ---- the serving dome ("cloche"): covers the figure, lifts off to reveal it ---- */

.cloche-frame {
  position: absolute;
  left: calc(70 * var(--u));
  top: calc(216 * var(--u));
  width: calc(250 * var(--u));
  height: calc(420 * var(--u));
  z-index: 3;
  pointer-events: none;
}

.cloche {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  transition: transform 1.3s cubic-bezier(0.45, 0, 0.2, 1), opacity 0.35s ease;
  filter: drop-shadow(0 calc(8 * var(--u)) calc(14 * var(--u)) rgba(0, 0, 0, 0.5));
  will-change: transform;
}

.cloche svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Lifts straight up and tilts away, fading out near the top of its flight. */
.stage.door-open .cloche {
  transform: translate(calc(-34 * var(--u)), calc(-560 * var(--u))) rotate(-16deg);
  opacity: 0;
  transition: transform 1.3s cubic-bezier(0.45, 0, 0.2, 1), opacity 0.5s ease 0.85s;
}

/* While the dome is down and the new head is being chosen it rattles. */
.stage.is-waiting .cloche { animation: cloche-rattle 0.42s ease-in-out infinite; }
.stage.is-waiting .tg-flame { animation-duration: 0.28s; }

@keyframes cloche-rattle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(calc(-4 * var(--u))) rotate(-1.4deg); }
  75% { transform: translateY(calc(-2 * var(--u))) rotate(1.2deg); }
}

/* Steam rising off the platter as the dome comes off. */
.tg-steam {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.tg-steam .puff {
  position: absolute;
  top: calc(560 * var(--u));
  width: calc(54 * var(--u));
  height: calc(54 * var(--u));
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 70%);
  filter: blur(2px);
}

.tg-steam .puff.p0 { left: calc(96 * var(--u)); }
.tg-steam .puff.p1 { left: calc(130 * var(--u)); --d: 0.1s; }
.tg-steam .puff.p2 { left: calc(164 * var(--u)); --d: 0.2s; }
.tg-steam .puff.p3 { left: calc(198 * var(--u)); --d: 0.05s; }
.tg-steam .puff.p4 { left: calc(232 * var(--u)); --d: 0.15s; }
.tg-steam .puff.p5 { left: calc(266 * var(--u)); --d: 0.25s; }
.tg-steam .puff.p6 { left: calc(180 * var(--u)); --d: 0.35s; }

.stage.door-open .puff {
  animation: steam-rise 2.4s ease-out both;
  animation-delay: var(--d, 0s);
}

@keyframes steam-rise {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  18% { opacity: 0.75; }
  100% { transform: translateY(calc(-240 * var(--u))) scale(1.9); opacity: 0; }
}

/* ---- sign and the wishbone button ---- */

.tg-sign {
  position: absolute;
  left: calc(103 * var(--u));
  top: calc(62 * var(--u));
  width: calc(184 * var(--u));
  z-index: 5;
  text-align: center;
  pointer-events: none;
}

.tg-eyebrow {
  margin: 0 0 calc(7 * var(--u));
  font-family: "DM Mono", "Space Grotesk", monospace;
  font-weight: 500;
  font-size: calc(8.5 * var(--u));
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffe2b0;
  text-shadow: 0 0 calc(6 * var(--u)) rgba(20, 4, 10, 0.95);
}

.tg-plate {
  position: relative;
  padding: calc(8 * var(--u)) calc(4 * var(--u));
  background: linear-gradient(180deg, #8a5a30, #5b3a22);
  border: calc(3 * var(--u)) solid #2a160c;
  border-radius: calc(8 * var(--u));
  box-shadow: 0 calc(4 * var(--u)) calc(14 * var(--u)) rgba(0, 0, 0, 0.5), inset 0 0 0 calc(1.5 * var(--u)) rgba(255, 230, 180, 0.2);
}

.tg-plate::before,
.tg-plate::after {
  content: "";
  position: absolute;
  top: calc(-12 * var(--u));
  width: calc(2 * var(--u));
  height: calc(12 * var(--u));
  background: #8a6a3a;
}

.tg-plate::before { left: calc(24 * var(--u)); }
.tg-plate::after { right: calc(24 * var(--u)); }

.tg-wordmark {
  display: block;
  font-family: "Bungee", "Space Grotesk", sans-serif;
  font-size: calc(23 * var(--u));
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: linear-gradient(180deg, var(--gold), var(--magenta) 60%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 calc(6 * var(--u)) rgba(255, 46, 154, 0.45));
}

.wishbone-btn {
  position: absolute;
  left: calc(88 * var(--u));
  top: calc(702 * var(--u));
  width: calc(214 * var(--u));
  min-height: max(44px, calc(50 * var(--u)));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: calc(8 * var(--u));
  padding: calc(5 * var(--u)) calc(12 * var(--u)) calc(5 * var(--u)) calc(9 * var(--u));
  border: calc(3 * var(--u)) solid #b8791f;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6dc, #f0d8a2);
  color: #5a2412;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 calc(3 * var(--u)) 0 #8a5a14, 0 0 calc(16 * var(--u)) rgba(255, 190, 80, 0.45);
  animation: wb-pulse 1.8s ease-in-out infinite;
  transition: transform 0.12s ease;
}

@keyframes wb-pulse {
  0%, 100% { box-shadow: 0 calc(3 * var(--u)) 0 #8a5a14, 0 0 calc(10 * var(--u)) rgba(255, 190, 80, 0.35); }
  50% { box-shadow: 0 calc(3 * var(--u)) 0 #8a5a14, 0 0 calc(24 * var(--u)) rgba(255, 214, 120, 0.8); }
}

.wishbone-btn:hover { transform: scale(1.03); }
.wishbone-btn:active,
.wishbone-btn.is-pressed { transform: translateY(calc(2 * var(--u))) scale(0.97); }
.wishbone-btn:disabled { cursor: progress; animation: none; filter: saturate(0.5) brightness(0.8); }

.wb-icon {
  flex: none;
  width: calc(34 * var(--u));
  height: calc(34 * var(--u));
  overflow: visible;
}

.wb-icon g {
  transform-box: view-box;
  transform-origin: 50% 87%;
}

/* The wishbone snaps: each prong kicks outward and settles back. */
.wishbone-btn.is-pressed .wb-l { animation: wb-snap-l 0.3s ease-out; }
.wishbone-btn.is-pressed .wb-r { animation: wb-snap-r 0.3s ease-out; }

@keyframes wb-snap-l { 40% { transform: rotate(-26deg) translateX(-3px); } }
@keyframes wb-snap-r { 40% { transform: rotate(14deg) translateX(2px); } }

.wb-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }

.wb-text strong {
  font-family: "Bungee", "Space Grotesk", sans-serif;
  font-weight: 400;
  font-size: calc(11 * var(--u));
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wb-text span {
  margin-top: calc(2 * var(--u));
  font-family: "Space Grotesk", sans-serif;
  font-size: calc(8.5 * var(--u));
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #8a4a28;
  white-space: nowrap;
}

/* ---- leaves: drifting ambient ones, and the burst when a head lands ---- */

.tg-leaves {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.tg-leaf {
  position: absolute;
  top: 0;
  display: block;
  opacity: 0.85;
  animation: tg-fall linear infinite;
  will-change: transform;
}

.tg-leaf svg { display: block; width: 100%; height: auto; }

@keyframes tg-fall {
  0% { transform: translate(0, -60px) rotate(0deg); }
  50% { transform: translate(var(--sway, 40px), 52vh) rotate(calc(var(--spin, 300deg) * 0.5)); }
  100% { transform: translate(calc(var(--sway, 40px) * -0.4), 112vh) rotate(var(--spin, 300deg)); }
}

.tg-burst-leaf {
  position: absolute;
  display: block;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 1px 3px rgba(40, 8, 0, 0.5));
}

.tg-burst-leaf svg { display: block; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  .tg-flame,
  .tg-leaf,
  .tg-glow,
  .cloche,
  .stage.is-waiting .cloche,
  .stage.door-open .puff,
  .wishbone-btn,
  .wishbone-btn.is-pressed .wb-l,
  .wishbone-btn.is-pressed .wb-r {
    animation: none !important;
    transition: none !important;
  }

  .tg-leaves { display: none; }
}
