/* Christmas: a deep pine-green night, bright red and green, a red top
   bar strung with twinkling lights, fairy-light glows and stars in the
   sky, snowy hills and pines along the bottom, snow on top of every card
   and LCD, and snow falling (the lights and snow by pistar.js; still for
   reduced motion). The colours meet 4.5:1 like every theme. */
:root[data-theme="christmas-dark"] {
  --ps-bg-primary: #0d2117;
  --ps-bg-secondary: #12301f;
  --ps-bg-tertiary: #1a3d29;
  --ps-border: #2c5b40;
  --ps-text-primary: #f7faf8;
  --ps-text-secondary: #c4dbcc;
  --ps-text-inverse: #ffffff;
  --ps-accent: #e3263c;
  --ps-accent-hover: #c41a2f;
  --ps-accent-subtle: #3a1520;
  --ps-success: #46d872;
  --ps-warning: #ffd34d;
  --ps-danger: #ff5a68;
  --ps-info: #79d8ff;
  --ps-nav-bg: #b3121f;
  --ps-nav-text: #ffffff;
  --ps-input-bg: #0b1c13;
  --ps-input-border: #2c5b40;
  --ps-table-header-bg: #1a3d29;
  /* A frosted LCD, pine-green segments */
  --lcd-bg: #d7ecdc;
  --lcd-ink: #0a3a1e;
  /* The accent and state colours as text, and the buttons: readable
     (4.5:1) on this theme */
  --ps-accent-text: #ec818d;
  --ps-info-text: #79d8ff;
  --ps-success-text: #46d872;
  --ps-warning-text: #ffd34d;
  --ps-danger-text: #fe7580;
  --ps-on-accent: #ffffff;
  --ps-accent-btn: #e1263b;
  --ps-accent-btn-hover: #c41a2f;
}

/* Lights strung along the bottom of the red top bar */
:root[data-theme="christmas-dark"] header[role="banner"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 18px;
  background: url(../../../static/img/themes/lights.svg) repeat-x;
  background-size: 120px 18px;
  pointer-events: none;
  animation: ps-twinkle 2.4s ease-in-out infinite alternate;
}
@keyframes ps-twinkle {
  from { filter: brightness(0.85) saturate(0.9); }
  to { filter: brightness(1.25) saturate(1.2) drop-shadow(0 0 3px rgba(255, 255, 255, 0.5)); }
}

/* Lights pistar.js strings along the top bar: each bulb glows on its
   own, and the string changes between a random twinkle, a chase and
   flashing by colour (data-mode). The strip above stays for reduced
   motion, lit and still. */
:root[data-theme="christmas-dark"] header.ps-lit::after {
  display: none;
}
#ps-lights {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 18px;
  background: url(../../../static/img/themes/wire.svg) repeat-x;
  background-size: 30px 18px;
  pointer-events: none;
  z-index: 1;
}
#ps-lights .ps-bulb {
  position: absolute;
  top: 7px;
  width: 8px;
  height: 11px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  /* Unlit: the bulb's colour, dimmed */
  background: color-mix(in srgb, var(--c) 35%, #0d2117);
}
#ps-lights .ps-bulb::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 2px;
  width: 4px;
  height: 2px;
  background: #2d4a35;
}
/* Lit: the bulb and its glow, drawn once, faded in and out. Only the
   opacity changes, which the graphics card does without repainting, so
   the lights cost next to nothing and the sleigh and snow keep moving
   smoothly. */
#ps-lights .ps-bulb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--c);
  box-shadow: 0 0 8px 3px var(--c), 0 0 22px 8px color-mix(in srgb, var(--c) 55%, transparent);
  opacity: 0;
  will-change: opacity;
  animation: ps-bulb var(--d, 1.6s) ease-in-out var(--dl, 0s) infinite alternate;
}
@keyframes ps-bulb {
  from { opacity: 0; }
  to { opacity: 1; }
}
/* A chase: a wave of light runs along the string */
#ps-lights[data-mode="chase"] .ps-bulb::after {
  animation: ps-chase 1.4s linear infinite;
  animation-delay: calc(var(--i) * -0.09s);
}
@keyframes ps-chase {
  0%, 55%, 100% { opacity: 0; }
  15%, 35% { opacity: 1; }
}
/* Flashing by colour: each colour in turn */
#ps-lights[data-mode="flash"] .ps-bulb::after {
  animation: ps-chase 1.2s steps(1, end) infinite;
  animation-delay: calc(var(--g) * -0.3s);
}

/* The night sky: soft out-of-focus fairy lights and a few stars, fixed
   behind the page, and snowy hills with pines along the bottom */
:root[data-theme="christmas-dark"] {
  background: #0d2117;
}
:root[data-theme="christmas-dark"] body {
  background-color: #0d2117;
  background-image:
    url(../../../static/img/themes/snowhills.svg),
    radial-gradient(circle 70px at 8% 22%, rgba(227, 38, 60, 0.13), transparent),
    radial-gradient(circle 90px at 88% 30%, rgba(255, 211, 77, 0.10), transparent),
    radial-gradient(circle 60px at 70% 62%, rgba(70, 216, 114, 0.10), transparent),
    radial-gradient(circle 80px at 22% 70%, rgba(121, 216, 255, 0.08), transparent),
    radial-gradient(circle 50px at 48% 14%, rgba(255, 211, 77, 0.09), transparent),
    radial-gradient(circle 65px at 95% 80%, rgba(227, 38, 60, 0.10), transparent),
    radial-gradient(1.5px 1.5px at 15% 9%, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 33% 21%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 61% 7%, rgba(255, 255, 255, 0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 79% 17%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 6%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 4% 38%, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 33%, rgba(255, 255, 255, 0.4) 50%, transparent 51%);
  background-repeat: repeat-x, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat,
    no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-position: center bottom, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
  background-size: auto 170px, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%,
    100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: fixed;
}

/* Gold headings */
:root[data-theme="christmas-dark"] .card h2,
:root[data-theme="christmas-dark"] main h1 {
  color: var(--ps-warning-text, #ffd34d);
}

/* Snow settled on top of every card and LCD */
:root[data-theme="christmas-dark"] .card,
:root[data-theme="christmas-dark"] .lcd-bezel {
  position: relative;
}
:root[data-theme="christmas-dark"] .card::before,
:root[data-theme="christmas-dark"] .lcd-bezel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -2px;
  right: -2px;
  height: 14px;
  background: url(../../../static/img/themes/snowcap.svg) repeat-x;
  background-size: 120px 14px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  z-index: 2;
}

/* Santa, his sleigh and the reindeer cross the sky now and then,
   Rudolph leading */
:root[data-theme="christmas-dark"] body::after {
  content: "";
  position: fixed;
  top: 70px;
  left: -280px;
  width: 260px;
  height: 60px;
  background: url(../../../static/img/themes/sleigh.svg) no-repeat center / contain;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35));
  pointer-events: none;
  z-index: 96;
  animation: ps-sleigh 45s linear infinite;
  /* Its own layer: moved by the graphics card, its glow drawn once */
  will-change: transform;
}
@keyframes ps-sleigh {
  0% { transform: translate(0, 18px) rotate(-4deg); }
  8% { transform: translate(28vw, 0) rotate(-2deg); }
  16% { transform: translate(56vw, -10px) rotate(-3deg); }
  24% { transform: translate(84vw, -24px) rotate(-6deg); }
  30%, 100% { transform: translate(calc(100vw + 300px), -40px) rotate(-8deg); }
}

/* Falling snow (pistar.js draws it) */
#ps-snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 95;
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="christmas-dark"] header[role="banner"]::after {
    animation: none;
    filter: brightness(1.15) drop-shadow(0 0 3px rgba(255, 255, 255, 0.4));
  }
  :root[data-theme="christmas-dark"] body::after { display: none; }
}
