/* The Christmas look (/shared/christmas.js puts html.xmas on while it's on): home's here - its glow, the lights on the
   start card, Santa and the snow behind it, the wreaths in the drift and the snow and hat on the title (home/christmas.js
   and fillDrift in home/script.js). The lobby's hats, the podium's presents and the Daily Jam's advent calendar are with
   their screens' own styles. Every rule needs html.xmas, so outside the season none of it applies. */

/* Home's backdrop glows red, gold and green instead of pink and orange */
html.xmas .page-body.home {
  --glow-a: rgba(229, 56, 79, 0.40);
  --glow-b: rgba(251, 191, 36, 0.24);
  --glow-c: rgba(16, 185, 129, 0.32);
}

/* ---------- The lights on the start card ---------- */

/* Room above the card for the lights to hang in, under the admin page's banner */
html.xmas :where([data-styles~="home"]) .start { gap: 28px; }
/* Warm light on the top of the card, from the bulbs */
html.xmas :where([data-styles~="home"]) .start-card {
  position: relative;
  background: radial-gradient(120% 46px at 50% 0, rgba(255, 196, 110, 0.16), transparent), var(--card);
}

/* The drawing sits UP (30px) above the card's top edge and SIDE (12px) past each side (home/christmas.js). Only the
   bulbs and the plug can be tapped. */
:where([data-styles~="home"]) .xmas-lights {
  position: absolute;
  left: -12px;
  top: -30px;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}
:where([data-styles~="home"]) .xmas-lights .wire { fill: none; stroke: #173a26; stroke-width: 2; stroke-linecap: round; }
html[data-theme="dark"] :where([data-styles~="home"]) .xmas-lights .wire { stroke: #2b5a3e; }
:where([data-styles~="home"]) .xmas-lights :is(.clip, .wire-end) { fill: #102a1b; }
:where([data-styles~="home"]) .xmas-lights .socket { fill: #24502f; }
:where([data-styles~="home"]) .xmas-lights .plug-body { fill: #1d4029; }
:where([data-styles~="home"]) .xmas-lights .prong { fill: #c9ccd3; }
:where([data-styles~="home"]) .xmas-lights .hit { fill: transparent; }
:where([data-styles~="home"]) .xmas-lights .shine { fill: #fff; opacity: 0.7; }
:where([data-styles~="home"]) .xmas-lights .flash { fill: #fff; transform-box: fill-box; transform-origin: 50% 50%; }
:where([data-styles~="home"]) .xmas-lights :is(.bulb, .plug) {
  pointer-events: all;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* A bulb swings from its socket, and grows back out of it when it's screwed back in */
:where([data-styles~="home"]) .xmas-lights .swing { transform-box: view-box; transform-origin: 0 0; }
:where([data-styles~="home"]) .xmas-lights .glass-of { transform-box: fill-box; transform-origin: 50% 0; }
/* Broken: just the jagged bit of glass left in the socket */
:where([data-styles~="home"]) .xmas-lights .stub { display: none; fill: #c9d3dc; opacity: 0.85; }
:where([data-styles~="home"]) .xmas-lights .bulb.broken .stub { display: inline; }
:where([data-styles~="home"]) .xmas-lights .bulb.broken :is(.glass-of, .glow) { display: none; }

/* Lit: the light glass over the darker, and the glow round it. Twinkling: each dims now and then on its own time
   (--tw, --td); chasing: home/christmas.js dims all but every third. */
:where([data-styles~="home"]) .xmas-lights :is(.lit, .glow) { transition: opacity 0.25s ease; }
:where([data-styles~="home"]) .xmas-lights.twinkle .lit { animation: xmasTwinkle var(--tw) ease-in-out var(--td) infinite alternate; }
:where([data-styles~="home"]) .xmas-lights.twinkle .glow { animation: xmasTwinkleGlow var(--tw) ease-in-out var(--td) infinite alternate; }
:where([data-styles~="home"]) .xmas-lights.chase .bulb.dim .lit { opacity: 0.18; }
:where([data-styles~="home"]) .xmas-lights.chase .bulb.dim .glow { opacity: 0.12; }
@keyframes xmasTwinkle {
  0%, 60% { opacity: 1; }
  100% { opacity: 0.22; }
}
@keyframes xmasTwinkleGlow {
  0%, 60% { opacity: 1; }
  100% { opacity: 0.15; }
}
/* Less motion: lit and still (the global rule would leave them stopped wherever the twinkle had got to) */
html.reduce-motion :where([data-styles~="home"]) .xmas-lights :is(.lit, .glow) { animation: none !important; }

/* ---------- Santa and the snow, behind everything ---------- */

/* On the drift's level: over the backdrop and the drifting letters, under the title and the card */
:where([data-styles~="home"]) .xmas-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
:where([data-styles~="home"]) .xmas-snow { position: absolute; inset: 0; width: 100%; height: 100%; }
html.reduce-motion :where([data-styles~="home"]) .xmas-snow { display: none; }

/* Faded, like the letters furthest away. home/christmas.js flies him across (translate); he bobs on his own. */
:where([data-styles~="home"]) .xmas-santa {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(200px, 22vw, 300px);
  opacity: 0.42;
  filter: blur(0.5px);
  will-change: transform;
}
:where([data-styles~="home"]) .xmas-santa svg { display: block; width: 100%; height: auto; overflow: visible; }
:where([data-styles~="home"]) .xmas-santa-bob { animation: xmasBob 1.3s ease-in-out infinite alternate; }
@keyframes xmasBob {
  from { transform: translateY(-11px) rotate(-2.6deg); }
  to { transform: translateY(11px) rotate(2.2deg); }
}

/* ---------- Wreaths drifting up with the letters (fillDrift in home/script.js) ---------- */

:where([data-styles~="home"]) .drift .wreath {
  position: absolute;
  bottom: -90px;
  width: var(--s);
  height: var(--s);
  opacity: var(--o);
  filter: blur(var(--b));
  animation: rise var(--d) linear var(--delay) infinite;
}
:where([data-styles~="home"]) .drift .wreath svg { display: block; width: 100%; height: 100%; }

/* ---------- Snow on the title, and a Santa hat on its first A ---------- */

/* A lumpy cap of snow over each tile's top edge, with a blue-gray shadow under it so it shows on a white tile too */
html.xmas :where([data-styles~="home"]) .title-tiles .tile::before {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: -5px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 14' preserveAspectRatio='none'%3E%3Cpath fill='white' d='M3 9C2 4 6 2 10 3C12 0 18 0 21 2C24 0 31 0 33 3C37 2 42 4 41 9C41 11 39 11.5 38 10C37.5 13 35 13.5 34 11L27 11C26.5 14 23 14 22.5 11L13 11C12.5 13 9.5 13.5 9 11C6 12 3 11.5 3 9Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  filter: drop-shadow(0 1.5px 0 rgba(122, 150, 190, 0.6));
  pointer-events: none;
}
html.xmas :where([data-styles~="home"]) .title-tiles .tile:nth-child(even)::before { transform: scaleX(-1); }
/* It rides along on its tile as the title scrambles */
:where([data-styles~="home"]) .title-tiles .xmas-hat {
  position: absolute;
  left: -27%;
  top: -55%;
  width: 87%;
  rotate: -16deg;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}
html:not(.xmas) :where([data-styles~="home"]) .title-tiles .xmas-hat { display: none; }
