/* Sounds Unlimited: Christmas 2026 decoration layer (holiday.js builds the elements).
   Everything is off unless <html data-holiday="on">.
   Rules: decoration never takes clicks, never takes layout space, animates
   transform/opacity only, uses no blur / filter / backdrop-filter.

   z-index map (site: mobile menu 999, nav 1000, top banner 1001, grain 9998, chatbot 9999+):
     snow canvas / phone flakes   997   over the page, under the menu, nav, banner and chat
     page garland                 996   over the first screen, behind the nav
     footer boughs                  1   over the footer's empty top padding
     hat                           inside the nav logo */

.xm,
.xm-snow-toggle {
  display: none;
}
html[data-holiday="on"] .xm {
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Corner garland ----------
   --xm-gw is the photo's own width at the scale in use (sets how big the clusters
   are), --xm-gh its height. The box is the full page width; the transparent strip
   between the clusters takes up the difference.
     phones        photo 92% of the screen width, hung 14px past the right edge
     600-1279px    as wide as the screen, never more than 980px
     from 1280px   980px, growing with the side margins, up to 1400px */
html[data-holiday="on"] .xm-pg {
  --sl: var(--slp);
  --sr: var(--srp);
  --sl-pct: var(--slp-pct);
  --sr-pct: var(--srp-pct);
  --xm-gw: 92vw;
  --xm-gh: calc(var(--xm-gw) / var(--rp));
  position: absolute;
  top: 0; /* holiday.js moves it under the promo banner / solid nav */
  left: 0;
  right: 0;
  height: calc(var(--xm-gh) + 80px);
  overflow: hidden;
  z-index: 996;
}
/* warm light falling from the two clusters onto the top of the page: gradients only */
.xm-pg-spill {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(42% 100% at 0% 0%, rgba(255, 190, 92, 0.13), rgba(255, 190, 92, 0) 70%),
    radial-gradient(36% 92% at 100% 0%, rgba(255, 190, 92, 0.11), rgba(255, 190, 92, 0) 70%);
  opacity: 0;
}
.xm-pg[data-lit] .xm-pg-spill {
  animation: xm-show 1.4s ease-out 0.3s forwards;
}
/* Painted as a border image (keeps it out of Largest Contentful Paint). No rule names
   the file until holiday.js has fetched it at low priority and set data-lit. */
.xm-pg-art {
  position: absolute;
  top: 0;
  left: 0;
  right: -14px;
  height: var(--xm-gh);
  border: 0 solid transparent;
  border-image-slice: 0 var(--sr-pct) 0 var(--sl-pct) fill;
  border-image-width: 0 calc(var(--xm-gw) * var(--sr)) 0 calc(var(--xm-gw) * var(--sl));
  border-image-repeat: stretch;
  opacity: 0;
}
.xm-pg[data-lit] .xm-pg-art {
  border-image-source: var(--img-p);
  animation: xm-show 0.7s ease-out forwards;
}
@keyframes xm-show {
  to { opacity: 1; }
}

/* glow on each bulb: a warm core fading into the bulb's own colour */
.xm-gl {
  display: none;
  position: absolute;
  width: calc(var(--xm-gw) * var(--r) * 7);
  aspect-ratio: 1;
  margin: calc(var(--xm-gw) * var(--r) * -3.5) 0 0 calc(var(--xm-gw) * var(--r) * -3.5);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 222, 0.95) 0, var(--c) 22%, transparent 68%);
  opacity: 0.6;
}
.xm-pg[data-lit] .xm-gl-phone {
  display: block;
  animation: xm-on 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--on) backwards;
}
.xm-pg[data-lit] .xm-gl-phone.xm-tw {
  animation:
    xm-on 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--on) backwards,
    xm-breathe var(--dur) ease-in-out var(--tw) infinite;
}
@media (min-width: 600px) {
  html[data-holiday="on"] .xm-pg {
    --sl: var(--slw);
    --sr: var(--srw);
    --sl-pct: var(--slw-pct);
    --sr-pct: var(--srw-pct);
    --xm-gw: min(100vw, clamp(980px, calc(980px + (100vw - 1280px) * 0.8), 1400px));
    --xm-gh: calc(var(--xm-gw) / var(--rw));
  }
  .xm-pg-art {
    right: 0;
  }
  .xm-pg[data-lit] .xm-pg-art {
    border-image-source: var(--img-w1);
  }
  .xm-pg[data-lit] .xm-gl-phone {
    display: none;
  }
  .xm-pg[data-lit] .xm-gl-wide {
    display: block;
    animation: xm-on 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--on) backwards;
  }
  .xm-pg[data-lit] .xm-gl-wide.xm-tw {
    animation:
      xm-on 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) var(--on) backwards,
      xm-breathe var(--dur) ease-in-out var(--tw) infinite;
  }
}
@keyframes xm-on {
  0% { transform: scale(0); }
  55% { transform: scale(1.7); }
  100% { transform: scale(1); }
}
@keyframes xm-breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: var(--low, 0.18); }
}

/* While the garland is behind the transparent top-of-page nav, give the phone number
   and the link pill a soft dark backing so they read over the boughs. Colour only. */
html[data-holiday="on"][data-garland] .nav:not(.scrolled) .nav-phone,
html[data-holiday="on"][data-garland] .nav:not(.scrolled) .nav-phone-mobile {
  background: rgba(0, 0, 0, 0.62);
  border-radius: 999px;
  color: #fff;
}
html[data-holiday="on"][data-garland] .nav:not(.scrolled) .nav-phone {
  padding: 8px 14px;
  margin: -8px -14px;
}
html[data-holiday="on"][data-garland] .nav:not(.scrolled) .nav-links {
  background: rgba(0, 0, 0, 0.55);
}

/* ---------- Santa hat on the first "s" of the logo ----------
   Logo box 349 x 50 units; the "s" x-height top is at about x 6-14%, y 35%.
   Percentages of the logo box, so it lands on the same spot at 38px and 28px. */
html[data-holiday="on"] .xm-hat {
  position: absolute;
  left: 3.6%;
  top: -34%;
  width: 11.5%;
  aspect-ratio: 1;
  transform: rotate(-14deg);
  transform-origin: 50% 80%;
}
.xm-hat img {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Footer boughs ----------
   Hangs down from the footer's top edge inside its empty 96px top padding; capped so
   it is never taller than 84px. Phones: photo at 140% of the screen width from the
   left. Wider: the screen width up to 1048px, then only the plain snow strip widens. */
html[data-holiday="on"] .xm-boughs {
  --xm-bw: min(140vw, 520px);
  --xm-bh: calc(var(--xm-bw) / var(--rp));
  position: relative;
  z-index: 1;
  height: 0;
}
.xm-boughs-row {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--xm-bh);
  overflow: hidden;
}
/* fade the photo's last strip into the footer's black */
.xm-boughs-row::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 14px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), #000 90%);
}
.xm-boughs-art {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--xm-bw);
  height: 100%;
}
.xm-boughs[data-near] .xm-boughs-art {
  border: 0 solid transparent;
  border-image: var(--img-p) 0 fill / 0 / 0 stretch;
}
@media (min-width: 600px) {
  html[data-holiday="on"] .xm-boughs {
    --xm-bw: min(100vw, 1000px);
    --xm-bh: calc(var(--xm-bw) / var(--rw));
  }
  .xm-boughs-art {
    width: 100%;
  }
  .xm-boughs[data-near] .xm-boughs-art {
    border-image-source: var(--img-w1);
    border-image-slice: 0 var(--sr-pct) 0 var(--sl-pct) fill;
    border-image-width: 0 calc(var(--xm-bw) * var(--sr)) 0 calc(var(--xm-bw) * var(--sl));
  }
}
/* Sharp screens get the 2x file. A media query, not image-set(): Safari mis-sizes
   the slices of an image-set() border image. */
@media (min-width: 600px) and (min-resolution: 1.5dppx), (min-width: 600px) and (-webkit-min-device-pixel-ratio: 1.5) {
  .xm-pg[data-lit] .xm-pg-art,
  .xm-boughs[data-near] .xm-boughs-art {
    border-image-source: var(--img-w2);
  }
}

/* ---------- Snow ---------- */
.xm-snow-canvas {
  position: fixed;
  inset: 0;
  z-index: 997;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
/* phones and touch screens: seven soft CSS flakes, each its own small fixed box.
   Two loops of unrelated length (fall + sideways wander), so no visible pattern. */
.xm-flakes > i {
  --wa: -22px;
  --wb: 30px;
  position: fixed;
  top: -24px;
  z-index: 997;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0, rgba(255, 255, 255, 0.85) 30%, rgba(255, 255, 255, 0) 68%);
  opacity: 0.8;
  pointer-events: none;
  will-change: transform, translate;
  animation:
    xm-fall 19s linear infinite,
    xm-wander 7.3s ease-in-out infinite alternate;
}
.xm-flakes > i:nth-child(1) { left: 5%; animation-duration: 19s, 7.3s; animation-delay: -3s, -1s; }
.xm-flakes > i:nth-child(2) { left: 17%; width: 6px; height: 6px; opacity: 0.55; --wa: -14px; --wb: 18px; animation-duration: 31s, 11.9s; animation-delay: -17s, -6s; }
.xm-flakes > i:nth-child(3) { left: 39%; width: 18px; height: 18px; opacity: 0.8; --wa: -46px; --wb: 34px; animation-duration: 13s, 8.7s; animation-delay: -7s, -3s; }
.xm-flakes > i:nth-child(4) { left: 48%; width: 5px; height: 5px; opacity: 0.5; --wa: -10px; --wb: 26px; animation-duration: 37s, 13.3s; animation-delay: -29s, -9s; }
.xm-flakes > i:nth-child(5) { left: 71%; width: 10px; height: 10px; --wa: -38px; --wb: 12px; animation-duration: 23s, 9.7s; animation-delay: -12s, -4s; }
.xm-flakes > i:nth-child(6) { left: 78%; width: 15px; height: 15px; opacity: 0.75; --wa: -30px; --wb: 52px; animation-duration: 16s, 10.1s; animation-delay: -1s, -7s; }
.xm-flakes > i:nth-child(7) { left: 94%; width: 7px; height: 7px; opacity: 0.65; --wa: -44px; --wb: 8px; animation-duration: 27s, 6.1s; animation-delay: -21s, -2s; }
.xm-flakes > i:nth-child(3),
.xm-flakes > i:nth-child(6) {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0, rgba(255, 255, 255, 0.4) 35%, rgba(255, 255, 255, 0) 70%);
}
@keyframes xm-fall {
  from { translate: 0 0; }
  to { translate: 0 118vh; }
}
@keyframes xm-wander {
  from { transform: translate3d(var(--wa), 0, 0); }
  to { transform: translate3d(var(--wb), 0, 0); }
}

/* ---------- "Snow on/off" in the footer's bottom row ---------- */
html[data-holiday="on"] .xm-snow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 32px;
  padding: 4px 12px;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--color-gray-400, #9ca3af);
  background: transparent;
  border: 1px solid var(--color-dark-border, #222);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
html[data-holiday="on"] .xm-snow-toggle:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
html[data-holiday="on"] .xm-snow-toggle:focus-visible {
  outline: 2px solid var(--color-accent-light, #60a5fa);
  outline-offset: 2px;
}
.xm-snow-state {
  color: #fff;
  font-weight: 600;
}
.xm-snow-toggle[aria-pressed="false"] .xm-snow-state {
  color: inherit;
  font-weight: 400;
}

/* ---------- Reduced motion: lights on but still, no snow, no toggle ---------- */
@media (prefers-reduced-motion: reduce) {
  .xm-pg[data-lit] .xm-gl {
    animation: none !important;
  }
  .xm-pg[data-lit] .xm-pg-art,
  .xm-pg[data-lit] .xm-pg-spill {
    opacity: 1;
    animation: none !important;
  }
  .xm-flakes,
  .xm-snow-canvas,
  html[data-holiday="on"] .xm-snow-toggle {
    display: none;
  }
}
