/*
 * ===== SEASON: Christmas scene =====
 * Flying sleigh, Santa peeking in from the right, Christmas trees + hanging baubles in the hero,
 * sleigh in the intro. Driven by js/effects/season-scene.js. Whole file is seasonal.
 * Performance: transform/opacity only, few long-running layers (twinkle = 2 glow layers per tree).
 */

/* ---------- Hero: two decorated trees framing the logo ---------- */
.xs-trees { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.xs-tree {
  position: absolute; bottom: -3%; aspect-ratio: 200 / 290; transform-origin: 50% 100%;
  animation: xsGrow 1s cubic-bezier(.2, 1.25, .4, 1) .3s both;
}
.xs-tree img { display: block; width: 100%; height: 100%; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .45)); }
.xs-tree--big { left: -17%; height: 60%; }
.xs-tree--small { right: -9%; height: 38%; animation-delay: .5s; }
@keyframes xsGrow { from { transform: translate3d(0, 18px, 0) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }

/* Ornament glows: positions match the ornaments in assets/season-tree.svg */
.xs-tw { position: absolute; inset: 0; will-change: opacity; animation: xsTwinkle 1.7s ease-in-out infinite alternate; }
.xs-tw--1 {
  background:
    radial-gradient(9% 6.2% at 43% 31.7%, rgba(244, 63, 94, .75), transparent),
    radial-gradient(9% 6.2% at 36% 47.6%, rgba(192, 132, 252, .75), transparent),
    radial-gradient(9% 6.2% at 50% 40%, rgba(186, 230, 253, .8), transparent),
    radial-gradient(10% 7% at 46% 60%, rgba(244, 63, 94, .75), transparent),
    radial-gradient(10% 7% at 58% 55.2%, rgba(251, 191, 36, .8), transparent),
    radial-gradient(10% 7% at 38% 76.6%, rgba(186, 230, 253, .8), transparent),
    radial-gradient(10% 7% at 75% 77.9%, rgba(244, 63, 94, .75), transparent),
    radial-gradient(10% 7% at 33% 55.2%, rgba(74, 222, 128, .75), transparent);
}
.xs-tw--2 {
  animation-duration: 2.1s; animation-delay: -1s;
  background:
    radial-gradient(9% 6.2% at 58% 30.3%, rgba(251, 191, 36, .8), transparent),
    radial-gradient(9% 6.2% at 62% 46.9%, rgba(244, 63, 94, .75), transparent),
    radial-gradient(10% 7% at 28% 64.8%, rgba(251, 191, 36, .8), transparent),
    radial-gradient(10% 7% at 68% 63.4%, rgba(192, 132, 252, .75), transparent),
    radial-gradient(10% 7% at 20% 80%, rgba(244, 63, 94, .75), transparent),
    radial-gradient(10% 7% at 56% 79.3%, rgba(251, 191, 36, .8), transparent),
    radial-gradient(10% 7% at 82% 70.3%, rgba(186, 230, 253, .8), transparent);
}
@keyframes xsTwinkle { from { opacity: .1; } to { opacity: 1; } }
.xs-star {
  position: absolute; left: 30%; top: -5%; width: 40%; aspect-ratio: 1; border-radius: 50%; will-change: transform, opacity;
  background:
    linear-gradient(90deg, transparent 47%, rgba(255, 247, 214, .9) 50%, transparent 53%) center / 100% 8% no-repeat,
    linear-gradient(0deg, transparent 47%, rgba(255, 247, 214, .9) 50%, transparent 53%) center / 8% 100% no-repeat,
    radial-gradient(circle, rgba(253, 230, 138, .75), rgba(251, 191, 36, .25) 35%, transparent 65%);
  animation: xsStar 2.4s ease-in-out infinite alternate;
}
@keyframes xsStar { from { transform: scale(.75) rotate(0deg); opacity: .55; } to { transform: scale(1.1) rotate(45deg); opacity: 1; } }

/* Warm candle-light glow behind the trees (static) */
.xs-trees::before {
  content: ''; position: absolute; left: -60%; right: -40%; top: 20%; bottom: -30%; pointer-events: none;
  background:
    radial-gradient(30% 30% at 30% 65%, rgba(251, 146, 60, .34), transparent),
    radial-gradient(20% 26% at 78% 68%, rgba(251, 191, 36, .22), transparent);
}

/* ---------- Hero: snowy ground along the bottom edge ---------- */
.xs-ground {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 74px; z-index: 1; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='60' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff'/%3E%3Cstop offset='1' stop-color='%23c9def0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 30Q65 6 130 24T260 22T390 26T520 28V60H0Z' fill='url(%23g)'/%3E%3C/svg%3E") left bottom / 520px 60px repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='380' height='60' preserveAspectRatio='none'%3E%3Cpath d='M0 22Q60 0 120 16T250 12T380 20V60H0Z' fill='%23dbeafe' fill-opacity='.35'/%3E%3C/svg%3E") 90px bottom / 380px 74px repeat-x;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

/* ---------- Snow drift along the bottom of the screen ---------- */
.xs-drift {
  position: fixed; left: 0; right: 0; bottom: 0; height: 26px; z-index: 37; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='460' height='26' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff'/%3E%3Cstop offset='1' stop-color='%23d4e6f5'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 18Q40 6 85 14T175 10T270 16T360 9T460 16V26H0Z' fill='url(%23g)'/%3E%3C/svg%3E") left bottom / 460px 26px repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='330' height='26' preserveAspectRatio='none'%3E%3Cpath d='M0 12Q50 0 105 9T215 6T330 11V26H0Z' fill='%23b9d3ea' fill-opacity='.6'/%3E%3C/svg%3E") 140px bottom / 330px 26px repeat-x;
  filter: drop-shadow(0 -2px 6px rgba(186, 230, 253, .25));
}

/* ---------- Hero: baubles hanging from the light string ---------- */
.xs-baubles { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.xs-bauble {
  --s: 24px; --len: 70px; --c: #e11d48; --t: 3.2s; --d: 0s;
  position: absolute; top: 0; width: var(--s); height: calc(var(--len) + var(--s)); margin-left: calc(var(--s) / -2);
  transform-origin: 50% 0; will-change: transform;
  animation: xsSwing var(--t) ease-in-out var(--d) infinite alternate;
}
.xs-bauble::before {
  content: ''; position: absolute; left: 50%; top: 0; width: 1px; height: calc(var(--len) + 2px);
  background: linear-gradient(180deg, rgba(251, 191, 36, .15), rgba(251, 191, 36, .8));
}
.xs-bauble::after {
  content: ''; position: absolute; left: 0; top: var(--len); width: var(--s); height: var(--s); border-radius: 50%;
  background:
    linear-gradient(#d4a017, #a16207) 50% 0 / 32% 14% no-repeat,
    radial-gradient(circle at 34% 32%, #fff 0 9%, var(--c) 42%, color-mix(in srgb, var(--c) 55%, #000) 100%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 60%, transparent), inset 0 -3px 6px rgba(0, 0, 0, .25);
}
.xs-bauble:nth-child(1) { left: 2.5%; --len: 70px; --c: #e11d48; --t: 3.1s; }
.xs-bauble:nth-child(2) { left: 5.6%; --len: 128px; --s: 32px; --c: #fbbf24; --t: 3.8s; --d: -1.2s; }
.xs-bauble:nth-child(3) { left: 8.6%; --len: 44px; --s: 20px; --c: #a855f7; --t: 2.7s; --d: -.6s; }
.xs-bauble:nth-child(4) { left: 33%; --len: 30px; --s: 18px; --c: #22c55e; --t: 2.9s; --d: -2s; }
.xs-bauble:nth-child(5) { left: 44%; --len: 96px; --s: 24px; --c: #bae6fd; --t: 3.5s; --d: -.9s; }
.xs-bauble:nth-child(6) { left: 47.6%; --len: 54px; --s: 28px; --c: #e11d48; --t: 3.3s; --d: -1.7s; }
@keyframes xsSwing { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* ---------- Santa's sleigh flying across the screen ---------- */
.xs-sleigh {
  position: fixed; left: 0; top: 20vh; z-index: 38; width: clamp(240px, 27vw, 420px); pointer-events: none;
  display: none; will-change: transform;
}
.xs-sleigh.is-flying { display: block; animation: xsFly 10s linear both; }
@keyframes xsFly { from { transform: translate3d(-100%, 46px, 0); } to { transform: translate3d(100vw, -40px, 0); } }
.xs-sleigh-bob { position: relative; animation: xsBob 1.3s ease-in-out infinite alternate; }
.xs-sleigh-bob > img { position: relative; display: block; width: 100%; filter: drop-shadow(0 0 18px rgba(251, 191, 36, .25)); }
@keyframes xsBob { from { transform: translate3d(0, -6px, 0) rotate(-1.5deg); } to { transform: translate3d(0, 6px, 0) rotate(1deg); } }
.xs-rudolph {
  position: absolute; left: 91%; top: 28%; width: 7%; aspect-ratio: 1; border-radius: 50%; will-change: opacity;
  background: radial-gradient(circle, rgba(248, 113, 113, .95), rgba(239, 68, 68, .35) 45%, transparent 70%);
  animation: xsTwinkle .6s ease-in-out infinite alternate;
}
.xs-trail {
  position: absolute; right: 94%; top: 66%; width: 70%; height: 26%; pointer-events: none; will-change: opacity;
  background:
    radial-gradient(circle, #fff7d6 0 1.3px, transparent 2px) 0 0 / 15px 11px,
    radial-gradient(circle, rgba(251, 191, 36, .9) 0 1px, transparent 1.8px) 7px 5px / 19px 13px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
  mask-image: linear-gradient(90deg, transparent, #000);
  animation: xsTwinkle .35s steps(2) infinite alternate;
}
.xs-sparks { position: absolute; left: 4%; top: 80%; width: 0; height: 0; }
.xs-sparks i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #fde68a; box-shadow: 0 0 8px #fbbf24;
  animation: xsSpark 1.5s linear calc(var(--i) * -.21s) infinite;
}
.xs-sparks i:nth-child(even) { background: #fff; box-shadow: 0 0 8px #bae6fd; }
@keyframes xsSpark { from { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } to { transform: translate3d(-110px, 70px, 0) scale(.2); opacity: 0; } }

/* ---------- Santa peeking in from the right edge (click = advent calendar) ---------- */
.xs-peek {
  position: fixed; right: 0; top: 40vh; z-index: 45; width: 176px; height: 220px; padding: 0; border: 0; background: none;
  cursor: pointer; display: none; transform-origin: 100% 100%; will-change: transform;
}
.xs-peek.is-peeking { display: block; animation: xsPeek 7.5s cubic-bezier(.3, .9, .3, 1) both; }
@keyframes xsPeek {
  0% { transform: translate3d(110%, 0, 0) rotate(0deg); }
  12% { transform: translate3d(12%, 0, 0) rotate(-9deg); }
  18%, 84% { transform: translate3d(16%, 0, 0) rotate(-6deg); }
  100% { transform: translate3d(110%, 0, 0) rotate(0deg); }
}
.xs-peek-body { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(-6px 8px 18px rgba(0, 0, 0, .45)); }
.xs-peek-arm {
  position: absolute; left: -16%; top: 42%; width: 45%; transform-origin: 86% 93%;
  animation: xsWave .45s ease-in-out 1s 10 alternate both;
}
@keyframes xsWave { from { transform: rotate(-24deg); } to { transform: rotate(16deg); } }
.xs-peek-bubble {
  position: absolute; right: 92%; top: -6%; padding: 9px 14px; border-radius: 14px 14px 4px 14px; white-space: nowrap;
  font: 700 14px var(--font-display); letter-spacing: .04em; color: #9f1239; background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35), 0 0 0 2px rgba(225, 29, 72, .35);
  transform-origin: 100% 100%; animation: xsBubble 7.5s ease-out both;
}
@keyframes xsBubble { 0%, 14% { transform: scale(0); opacity: 0; } 20%, 80% { transform: scale(1); opacity: 1; } 86%, 100% { transform: scale(0); opacity: 0; } }

/* ---------- Intro: the sleigh crosses the sky behind the logo ---------- */
.xi-sleigh {
  position: absolute; left: 0; top: 10%; width: min(440px, 62vw); pointer-events: none;
  animation: xiSleigh 3.6s cubic-bezier(.45, .05, .55, .95) 1.1s both;
}
.xi-sleigh img { position: relative; display: block; width: 100%; filter: drop-shadow(0 0 22px rgba(251, 191, 36, .3)); }
@keyframes xiSleigh { from { transform: translate3d(-100%, 70px, 0); } to { transform: translate3d(100vw, -50px, 0); } }
.xmas-intro.xi-out .xi-sleigh { opacity: 0; transition: opacity .3s ease; }

@media (max-width: 1100px) {
  .xs-baubles .xs-bauble:nth-child(n + 4) { display: none; }
}
@media (max-width: 720px) {
  .xs-baubles { display: none; }
  .xs-drift { height: 16px; background-size: 300px 16px, 220px 16px; }
  .xs-ground { height: 48px; }
  .xs-tree--big { left: -4%; height: 46%; }
  .xs-tree--small { right: -2%; height: 30%; }
}

@media (prefers-reduced-motion: reduce) {
  .xs-tree, .xs-tw, .xs-star, .xs-bauble, .xi-sleigh { animation: none; }
  .xi-sleigh { display: none; }
}
/* ===== /SEASON ===== */
