/* Christmas theme. All of it only applies while the Christmas switch in the header is on, which adds
   the xmas class to <html>. To retire it after the holidays, set christmas: false in js/config.js. */

:root { --xmas-hat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 10' shape-rendering='crispEdges'%3E%3Crect x='8' y='0' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='9' y='0' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='10' y='0' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='7' y='1' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='8' y='1' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='9' y='1' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='10' y='1' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='6' y='2' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='2' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='9' y='2' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='3' width='1' height='1' fill='%23a3182a'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='6' y='4' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='4' width='1' height='1' fill='%23a3182a'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%23a3182a'/%3E%3Crect x='2' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='3' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='4' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%23a3182a'/%3E%3Crect x='1' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='2' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='3' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='4' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='5' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23e8323f'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23a3182a'/%3E%3Crect x='0' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='1' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='2' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='3' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='4' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='5' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='0' y='9' width='1' height='1' fill='%23c4b8f0'/%3E%3Crect x='1' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='2' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='3' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='4' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='7' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%23f4f2ff'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%23c4b8f0'/%3E%3C/svg%3E"); }

:root.xmas {
  --xmas-red: #ff4d5e;
  --xmas-green: #3ddc84;
  --xmas-gold: #ffd15c;
  --xmas-blue: #6fd3ff;
  --snow: #f4f2ff;
  --snow-shade: #c4b8f0;
  /* a pixel snow cap, drawn as three rows of uneven blocks */
  --snowcap:
    linear-gradient(var(--snow-shade) 0 0) 0 100% / 100% 2px no-repeat,
    linear-gradient(var(--snow) 0 0) 0 100% / 100% 7px no-repeat,
    repeating-linear-gradient(90deg, var(--snow) 0 24px, transparent 0 32px, var(--snow) 0 44px, transparent 0 60px) 0 4px / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 8px, var(--snow) 0 20px, transparent 0 36px, var(--snow) 0 44px, transparent 0 60px) 0 0 / 100% 4px no-repeat;
}

/* ---------- header: candy-cane edge with a string of blinking lights ---------- */
.xmas .top { border-image: repeating-linear-gradient(90deg, var(--xmas-red) 0 14px, var(--snow) 0 28px) 0 0 3 0; }
.xmas .top::before, .xmas .top::after {
  content: ""; position: absolute; left: 0; right: 0; top: calc(100% + 3px); height: 18px; pointer-events: none;
}
.xmas .top::before {
  background:
    linear-gradient(90deg, var(--xmas-red) 0 8px, transparent 0) 12px 7px / 96px 10px repeat-x,
    linear-gradient(90deg, var(--xmas-gold) 0 8px, transparent 0) 60px 7px / 96px 10px repeat-x,
    linear-gradient(90deg, #3d7a52 0 6px, transparent 0) 13px 3px / 24px 4px repeat-x,
    linear-gradient(#27553a 0 0) 0 2px / 100% 2px repeat-x;
  animation: xmas-blink 1.8s steps(1, end) infinite;
}
.xmas .top::after {
  background:
    linear-gradient(90deg, var(--xmas-green) 0 8px, transparent 0) 36px 7px / 96px 10px repeat-x,
    linear-gradient(90deg, var(--xmas-blue) 0 8px, transparent 0) 84px 7px / 96px 10px repeat-x;
  animation: xmas-blink 1.8s steps(1, end) -0.9s infinite;
}
@keyframes xmas-blink {
  0%, 100% { filter: brightness(1.1) drop-shadow(0 0 4px rgb(255 236 190 / 0.6)); }
  50% { filter: brightness(0.5); }
}

/* a Santa hat on the header logo */
.xmas .brand { position: relative; }
.xmas .brand::before {
  content: ""; position: absolute; left: -10px; top: -13px; width: 33px; height: 30px; pointer-events: none;
  background: var(--xmas-hat) 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated; transform: rotate(-14deg);
}

/* ---------- snow on top of the panels ---------- */
.xmas .window-bar, .xmas .band, .xmas .mode, .xmas .key { position: relative; }
.xmas .window-bar::before, .xmas .band::before, .xmas .mode::before, .xmas .pick::before, .xmas .key::before {
  content: ""; position: absolute; left: -5px; right: -5px; top: -14px; height: 15px; pointer-events: none;
  background: var(--snowcap); filter: drop-shadow(0 2px 0 rgb(13 0 23 / 0.45));
}
.xmas .window .window-bar::before { top: -16px; }
.xmas .band::before, .xmas .mode::before, .xmas .pick::before, .xmas .key::before { left: -3px; right: -3px; top: -16px; }
/* scrolling boxes would cut the snow off */
.xmas dialog .window-bar::before { display: none; }

/* the three window squares go red, white and green */
.xmas .window-bar::after { background: var(--xmas-red); box-shadow: 20px 0 0 var(--snow), 40px 0 0 var(--xmas-green); }

/* ---------- small festive touches ---------- */
.xmas .spotlight li:nth-child(odd)::before, .xmas .perk-list li:nth-child(odd)::before { background: var(--xmas-red); }
.xmas .spotlight li:nth-child(even)::before, .xmas .perk-list li:nth-child(even)::before { background: var(--xmas-green); }
.xmas .fx-progress { background: repeating-linear-gradient(90deg, var(--xmas-red) 0 14px, var(--snow) 0 28px); }
.xmas .toggle.xmas-switch[aria-pressed="true"] { border-color: var(--xmas-red); box-shadow: inset 0 -3px 0 var(--xmas-green); }
/* the switch itself is a Santa hat icon, greyed out while the theme is off */
.toggle.xmas-switch { width: 44px; padding: 0; background: var(--xmas-hat) 50% 55% / 26px 24px no-repeat; image-rendering: pixelated; }
.toggle.xmas-switch:hover { border-color: var(--second); }
.toggle.xmas-switch[aria-pressed="false"] { filter: grayscale(1); opacity: 0.55; }
@media (max-width: 560px) {
  .toggle.xmas-switch { width: 38px; background-size: 22px 20px; }
}

/* falling snow (js/christmas.js) */
.xmas-snow { position: fixed; inset: 0; z-index: 70; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
:root:not(.xmas) .xmas-snow, .no-fx .xmas-snow { display: none; }

/* the lights stay lit but stop blinking when effects are off or motion is reduced */
.no-fx .top::before, .no-fx .top::after { animation: none; filter: drop-shadow(0 0 4px rgb(255 236 190 / 0.6)); }
@media (prefers-reduced-motion: reduce) {
  .xmas .top::before, .xmas .top::after { animation: none; }
  .xmas-snow { display: none; }
}
/* on small screens the header stops sticking, so it needs this to hold the lights */
@media (max-width: 900px) {
  .xmas .top { position: relative; }
}
