/* ===========================================================================
   Christmas theme — loaded only while the season is on (themes/xmas/; dates in config.py).

   Everything here hangs off classes on <html>:
     .xmas            the season is on (this file is loaded at all)
     .xl1 … .xl5      the visitor's decoration level, cumulative: level 3
                      has xl1 + xl2 + xl3. Set before first paint by the
                      inline script in themes/xmas/slots/head.html and
                      live by xmas.js when the slider moves.
   Levels:  0 Без · 1 Семпла: winter hero (colours, tree, sleigh), the
            countdown pad, the crows' hats, Christmas fact cards — static ·
            2 Бляскава: + logo hat, holly, string lights, snowdrifts,
            front-page ornaments and unlit candles — static ·
            3 Светлини: + blinking lights, lit candles, falling presents ·
            4 Сняг: + snowfall (front page) · 5 Пълна: + heavy snow piling up.
   Nothing here shows at level 0 except the dock (to turn it back on) and
   the holiday days-off note (information, not decoration).
   =========================================================================== */

html.xmas {
  --xm-red: #c62828;
  --xm-red-2: #e53935;
  --xm-green: #1b5e20;
  --xm-pine: #2e7d32;
  --xm-gold: #f5c842;
  --xm-gold-dark: #a87b00;
  --xm-snow: #ffffff;
  --xm-ice: #e3eef8;
  --xm-paper: #fffdf6;
  --xm-ink: #2d2a22;
  --xm-hand: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
  --xm-fancy: 'Marck Script', 'Caveat', cursive;
  /* Holly sprig: two leaves, three berries. */
  --xm-holly: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cpath d='M32 22C26 12 14 8 3 10c4 3 3 7 7 8-3 3-1 7 3 8 1-4 6-3 8-6 2 4 7 3 11 2z' fill='%232e7d32' stroke='%23174d1c' stroke-width='1.2' stroke-linejoin='round'/%3E%3Cpath d='M32 22c6-10 18-14 29-12-4 3-3 7-7 8 3 3 1 7-3 8-1-4-6-3-8-6-2 4-7 3-11 2z' fill='%23388e3c' stroke='%23174d1c' stroke-width='1.2' stroke-linejoin='round'/%3E%3Cpath d='M30 20C24 15 16 12 9 12M34 20c6-5 14-8 21-8' fill='none' stroke='%23174d1c' stroke-width='0.8' opacity='0.6'/%3E%3Ccircle cx='28' cy='24' r='4.2' fill='%23d32f2f'/%3E%3Ccircle cx='36' cy='24' r='4.2' fill='%23c62828'/%3E%3Ccircle cx='32' cy='29.5' r='4.2' fill='%23e53935'/%3E%3Ccircle cx='26.8' cy='22.8' r='1.2' fill='%23fff' opacity='0.7'/%3E%3Ccircle cx='34.8' cy='22.8' r='1.2' fill='%23fff' opacity='0.7'/%3E%3Ccircle cx='30.8' cy='28.3' r='1.2' fill='%23fff' opacity='0.7'/%3E%3C/svg%3E");
  /* Snowdrift: soft white mounds along a bottom edge, tiles every 480px. */
  --xm-drift: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 34' preserveAspectRatio='none'%3E%3Cpath d='M0 34V20C30 8 62 6 96 16S160 30 196 18 262 2 300 12s56 22 92 12 64-18 88-8v18z' fill='%23f4f6f3'/%3E%3Cpath d='M0 20C30 8 62 6 96 16S160 30 196 18 262 2 300 12s56 22 92 12 64-18 88-8' fill='none' stroke='%23c9d8e8' stroke-width='2'/%3E%3C/svg%3E");
}

.xmas-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------
   Decoration dock — bottom drawer with the level slider
   --------------------------------------------------------------------------- */
.xmas-dock {
  position: fixed; left: 50%; bottom: 0; z-index: 9500;
  width: 100%;
  transform: translate(-50%, 0);
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Alegreya', Georgia, serif;
}
/* Collapsed: only the tab (30px) peeks above the bottom edge. */
.xmas-dock.is-collapsed { transform: translate(-50%, calc(100% - 30px)); }
.xmas-dock-tab {
  display: flex; align-items: center; gap: 7px;
  height: 30px; margin: 0 auto; padding: 0 16px;
  border: 0; border-radius: 12px 12px 0 0; cursor: pointer;
  background: var(--xm-red); color: #fff; font: inherit; font-size: 15px; line-height: 1;
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.14);
}
.xmas-dock-tab:hover { background: var(--xm-red-2); }
.xmas-dock-tab:focus-visible { outline: 3px solid var(--xm-gold); outline-offset: 2px; }
.xmas-dock-tab-arrow {
  width: 8px; height: 8px; margin-top: -4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform 0.4s ease, margin 0.4s ease;
}
.xmas-dock.is-collapsed .xmas-dock-tab-arrow { transform: rotate(-135deg); margin-top: 4px; }
.xmas-dock-panel {
  position: relative;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.15rem 1.1rem;
  /* Full-width bar; the controls stay in a readable column in the middle. */
  padding: 0.95rem max(1.3rem, calc((100% - 820px) / 2)) 0.8rem;
  background: var(--xm-paper); color: var(--xm-ink);
  box-shadow: 0 -8px 30px rgba(20, 30, 20, 0.18);
  overflow: hidden;
}
/* Candy-cane stripe along the top edge. */
.xmas-dock-panel::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: repeating-linear-gradient(-45deg, var(--xm-red) 0 9px, #fff 9px 18px);
}
.xmas-dock.is-collapsed .xmas-dock-panel { visibility: hidden; transition: visibility 0s 0.7s; }
.xmas-dock-title { font-weight: 800; font-size: 1rem; white-space: nowrap; cursor: default; }
.xmas-dock-slider input[type="range"] {
  width: 100%; margin: 0.35rem 0 0; accent-color: var(--xm-red); cursor: pointer;
}
.xmas-dock-ticks {
  display: flex; justify-content: space-between; margin: 0 -2px;
  font-size: 0.74rem; font-weight: 600; color: #8a8478;
}
.xmas-dock-ticks span { width: calc(100% / 6); text-align: center; cursor: pointer; transition: color 0.2s ease; }
.xmas-dock-ticks span:first-child { text-align: left; }
.xmas-dock-ticks span:last-child { text-align: right; }
.xmas-dock-ticks span.is-active { color: var(--xm-red); font-weight: 800; }
.xmas-dock-desc {
  grid-column: 1 / -1; margin: 0.35rem 0 0; min-height: 1.3em;
  font-size: 0.84rem; color: #6b6760; line-height: 1.35;
  display: grid;
}
/* All level texts share one cell: the cell takes the tallest one's height
   (xmas.js). Only the last child, the current text, is visible. */
.xmas-dock-desc > span { grid-area: 1 / 1; }
.xmas-dock-desc-sizer { visibility: hidden; }
@media (max-width: 560px) {
  .xmas-dock-panel { grid-template-columns: 1fr; padding: 0.85rem 1rem 0.7rem; }
}
@media print { .xmas-dock { display: none; } }

/* ---------------------------------------------------------------------------
   Holly sprigs (level 1+)
   --------------------------------------------------------------------------- */
.xmas-holly {
  display: none; position: absolute; pointer-events: none;
  background: var(--xm-holly) center / contain no-repeat;
}
html.xl2 .xmas-holly { display: block; }
.xmas-holly--pad { width: 46px; height: 29px; top: -14px; right: -18px; transform: rotate(16deg); z-index: 3; }
.xmas-holly--note { width: 50px; height: 31px; top: -15px; right: 14px; transform: rotate(-8deg); }
.xmas-holly--card { width: 44px; height: 28px; top: 12px; right: 12px; transform: rotate(10deg); opacity: 0.95; }

/* ---------------------------------------------------------------------------
   Front page: countdown pad + holiday days off
   --------------------------------------------------------------------------- */
.xmas-countdown {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 1.6rem 2.2rem; margin: 2rem auto 0.5rem; max-width: 640px;
}
/* Tear-off desk pad, stuck on slightly crooked. Decoration: gone at level 0. */
.xmas-pad {
  position: relative; display: block; width: 150px; flex-shrink: 0;
  padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer;
  transform: rotate(-3deg); transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.xmas-pad--greeting { cursor: default; }
html:not(.xl1) .xmas-pad { display: none; }
.xmas-pad:hover { transform: rotate(-1deg) translateY(-3px); }
.xmas-pad:focus-visible { outline: 3px solid var(--xm-gold); outline-offset: 6px; border-radius: 12px; }
.xmas-pad-head {
  position: relative; display: block;
  padding: 15px 0 7px; border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, var(--xm-red-2), var(--xm-red));
  color: #fff; font-weight: 800; font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  text-align: center; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
/* Two binder rings. */
.xmas-pad-head i {
  position: absolute; top: -8px; width: 9px; height: 18px; border-radius: 5px;
  background: linear-gradient(90deg, #8d8d8d, #e8e8e8 45%, #9e9e9e);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.xmas-pad-head i:first-child { left: 30%; }
.xmas-pad-head i:nth-child(2) { right: 30%; }
.xmas-pad-sheet {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 112px; padding: 0.4rem 0.5rem 0.75rem;
  background: var(--xm-paper);
  border-radius: 0 0 8px 8px;
  /* The pages still under this one. */
  box-shadow:
    0 3px 0 -1px #f2ead6, 0 6px 0 -2px #e9dfc6, 0 9px 0 -3px #dfd3b6,
    0 16px 24px -6px rgba(45, 42, 34, 0.35);
}
.xmas-pad-num {
  font-family: var(--xm-hand); font-weight: 700; font-size: 4.3rem; line-height: 0.9;
  color: var(--xm-red);
}
.xmas-pad-num--emoji { font-size: 3.2rem; line-height: 1.1; }
.xmas-pad-label {
  font-family: var(--xm-hand); font-weight: 600; font-size: 1.3rem; line-height: 1.05;
  color: var(--xm-ink); text-align: center;
}
/* Yesterday's sheet: sits exactly over today's until xmas.js tears it off. */
.xmas-pad-sheet--old {
  display: none; position: absolute; left: 0; right: 0; top: 34px; z-index: 2;
  box-shadow: 0 2px 4px rgba(45, 42, 34, 0.18);
  transform-origin: 18% 0;
}
/* First visit of the day: yesterday's sheet waits on top for a scroll/click. */
html.xmas-yday.xl3 .xmas-pad-sheet--old { display: flex; }
.xmas-pad.is-tearing .xmas-pad-sheet--old {
  display: flex;
  animation: xmas-tear 1.25s cubic-bezier(0.55, 0, 0.75, 0.4) 0.5s forwards;
}
@keyframes xmas-tear {
  0%   { transform: none; opacity: 1; }
  18%  { transform: rotate(-5deg) translateY(1px); }
  32%  { transform: rotate(-9deg) translate(-4px, 4px); }
  100% { transform: rotate(-48deg) translate(-70px, 210px); opacity: 0; }
}

/* The days-off note: information, so it shows at every level; levels 1+
   dress it up with the fancy script and the holly. */
.xmas-offdays {
  position: relative; flex: 1 1 280px; max-width: 360px; text-align: left;
  padding: 1rem 1.25rem 1.05rem; border-radius: 16px;
  background: var(--surface, #fff); box-shadow: var(--shadow);
}
html.xl1 .xmas-offdays {
  background:
    radial-gradient(circle at 12% 16%, rgba(198, 40, 40, 0.06), transparent 40%),
    radial-gradient(circle at 92% 90%, rgba(46, 125, 50, 0.07), transparent 45%),
    var(--xm-paper);
  border: 1px solid #efdfc2;
}
.xmas-offdays-kicker {
  display: block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--xm-red);
}
.xmas-offdays-date {
  display: block; margin: 0.1rem 0 0.25rem;
  font-weight: 800; font-size: 1.7rem; line-height: 1.15; color: var(--xm-green);
}
html.xl1 .xmas-offdays-date { font-family: var(--xm-fancy); font-weight: 400; font-size: 2.45rem; }
.xmas-offdays-date small { font-size: 0.55em; color: var(--xm-pine); }
.xmas-offdays-text { margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--muted, #6b6760); }
.xmas-offdays-text strong { color: var(--xm-ink); }

/* ---------------------------------------------------------------------------
   Header / footer: elf hat on the logo, string lights
   --------------------------------------------------------------------------- */
.xmas-logo-hat {
  display: none; position: absolute; pointer-events: none;
  width: 16px; height: 14.5px; left: 15px; top: 4.5px;
  transform: rotate(-8deg); transform-origin: 57% 82%;
}
html.xl2 .xmas-logo-hat { display: block; }
.xmas-logo-hat svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.xmas-logo-hat.is-wiggling { animation: xmas-hat-wiggle 0.9s ease-in-out; }
@keyframes xmas-hat-wiggle {
  0%, 100% { transform: rotate(-8deg); }
  20% { transform: rotate(-20deg) translateY(-2px); }
  45% { transform: rotate(4deg); }
  70% { transform: rotate(-12deg); }
}
html.xmas .landing-logo { position: relative; }

/* Lights: built by xmas.js — a sagging wire (SVG) with bulbs hung from the
   low points. Static at level 1, gently twinkling from level 2. */
.xmas-lights {
  display: none; position: absolute; left: 0; right: 0; height: 26px;
  pointer-events: none; z-index: 5;
}
html.xl2 .xmas-lights { display: block; }
.landing-nav > .xmas-lights { top: 100%; margin-top: -7px; }
.landing-footer > .xmas-lights { top: -6px; }
.xmas-garland--section { position: absolute; left: 0; right: 0; top: 0; height: 30px; }
.xmas-garland--section > .xmas-lights { top: 2px; }
.xmas-lights svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.xmas-bulb {
  position: absolute; width: 9px; height: 13px; margin-left: -4.5px;
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85) 0 18%, transparent 30%), var(--c);
  box-shadow: 0 0 5px 1px color-mix(in srgb, var(--c) 55%, transparent);
}
.xmas-bulb::before {
  content: ''; position: absolute; left: 1.5px; right: 1.5px; top: -3px; height: 4px;
  border-radius: 1.5px; background: #5b5b5b;
}
/* Level 2+: each bulb switches on and off on its own random rhythm (--t,
   --d from xmas.js), lit about 40% of the time. The glow is painted once
   on ::after and only its opacity animates, so the browser never repaints
   the bulbs: the work stays on the GPU compositor. */
.xmas-bulb::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: radial-gradient(circle at 35% 30%, #fff 0 22%, transparent 40%), var(--c);
  box-shadow: 0 0 10px 3px color-mix(in srgb, var(--c) 75%, transparent);
}
html.xl3 .xmas-bulb {
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45) 0 18%, transparent 30%), color-mix(in srgb, var(--c) 45%, #5a5a5a);
  box-shadow: none;
}
html.xl3 .xmas-bulb::after {
  will-change: opacity;
  animation: xmas-blink var(--t, 5s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes xmas-blink {
  0%, 52%, 100% { opacity: 0; }
  8%, 44%       { opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Winter colours and snowdrifts (level 1+, static)
   --------------------------------------------------------------------------- */
html.xl1 body.skald-landing .landing-hero {
  background:
    radial-gradient(900px 380px at 50% -8%, rgba(227, 238, 248, 0.95), transparent 70%),
    linear-gradient(160deg, #f6f1ea 0%, #ebeff3 58%, #f2ece5 100%);
}
/* Snow resting along the bottom of every dark section (it reads as the
   snowy hill-top of the light section that follows). */
html.xl2 body.skald-landing .landing-section--dark::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 30px;
  background: var(--xm-drift) repeat-x left bottom / 480px 30px;
  pointer-events: none; z-index: 3;
}
/* Frosting along the top of the green marquee, with little icicles. */
html.xl2 body.skald-landing .landing-marquee { position: relative; }
html.xl2 body.skald-landing .landing-marquee::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px; z-index: 2; pointer-events: none;
  background:
    radial-gradient(7px 6px at 50% 0, #fff 92%, transparent 100%) 0 0 / 22px 9px repeat-x,
    linear-gradient(#fff, #fff) 0 0 / 100% 3px no-repeat;
  filter: drop-shadow(0 1px 0 rgba(160, 185, 210, 0.6));
}

/* ---------------------------------------------------------------------------
   Hero art: a faint, coloured Christmas tree on the left and Santa's sleigh
   with reindeer flying on the upper right (tools/hero_art_gen.py). Static;
   level 1+.
   --------------------------------------------------------------------------- */
.xmas-hero-art { display: none; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
html.xl1 .xmas-hero-art { display: block; }
.xmas-hero-art > span {
  position: absolute; background-repeat: no-repeat; background-size: contain;
  opacity: 0.35;
}
/* Each fades toward the middle so nothing sits hard behind the text. */
.xmas-hero-art-tree {
  left: 0; bottom: 0; width: min(36vw, 560px); aspect-ratio: 640 / 560;
  background-image: url("img/hero/tree.e0b4bf849824.svg"); background-position: left bottom;
  -webkit-mask-image: linear-gradient(90deg, #000 60%, transparent 100%); mask-image: linear-gradient(90deg, #000 60%, transparent 100%);
}
.xmas-hero-art-sleigh {
  right: 1vw; top: 60px; width: min(34vw, 540px); aspect-ratio: 640 / 300;
  background-image: url("img/hero/sleigh.7e78976e37c7.svg");
  -webkit-mask-image: linear-gradient(270deg, #000 60%, transparent 100%); mask-image: linear-gradient(270deg, #000 60%, transparent 100%);
}
/* The geometric hero shapes would clutter the scene: let them recede. */
html.xl1 body.skald-landing .landing-hero .bg-shapes { opacity: 0.35; }
/* Too narrow for art beside the text: hide it rather than put it behind. */
@media (max-width: 760px) { .xmas-hero-art { display: none !important; } }

/* ---------------------------------------------------------------------------
   Facts page: "Интересни Коледни факти"
   --------------------------------------------------------------------------- */
body.skald-landing .xmas-facts-section {
  background:
    radial-gradient(1100px 420px at 50% 0, rgba(76, 140, 90, 0.35), transparent 70%),
    linear-gradient(180deg, #123322 0%, #0d2419 100%);
  color: #e8efe6;
  padding-top: 4.5rem;
}
body.skald-landing .xmas-facts-heading { color: #fff; }
body.skald-landing .xmas-facts-heading-accent { color: #ff8a80; }
body.skald-landing .xmas-facts-heading-mark { display: inline-block; font-size: 0.7em; color: #cfe6ff; }
html.xl3 body.skald-landing .xmas-facts-heading-mark { animation: skald-wiggle 2.6s ease-in-out infinite; }
body.skald-landing .fact-card--xmas { position: relative; }
html.xl1 body.skald-landing .fact-card--xmas {
  border-top: 3px solid var(--fc);
  background:
    radial-gradient(120px 80px at 100% 0, rgba(255, 255, 255, 0.08), transparent 70%),
    rgba(255, 255, 255, 0.06);
}
body.skald-landing .fact-card--xmas .fact-card-title { padding-right: 2.6rem; }

/* ---------------------------------------------------------------------------
   Front page ornaments and candles — built by xmas-decor.js.
   Level 2 (Бляскава): hanging baubles, bells, cones and stars plus unlit
   candles, all still. Level 3+ (Светлини): candles and fairy lights light up, glass glints, the
   ornaments sway. Sits under the content (z-index 1 < containers' 2).
   --------------------------------------------------------------------------- */
.xmas-decor-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.xmas-decor { display: none; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
html.xl2 .xmas-decor { display: block; }
.xmas-decor svg { position: absolute; display: block; height: auto; overflow: visible; }
.xm-string { stroke: #b59a5a; stroke-width: 0.9; fill: none; }
.landing-section--dark .xm-string { stroke: #8f7f5a; }

/* Ornaments hang from the top corners, inside the section's top padding
   on phones and beside the centred heading on wider screens. */
.xmas-hang { top: 0; width: clamp(50px, 9vw, 120px); }
.xmas-hang--l { left: clamp(2px, 2.5vw, 48px); }
.xmas-hang--r { right: clamp(2px, 2.5vw, 48px); }
.xmas-hang--hero { left: 2vw; width: clamp(150px, 13vw, 200px); }
/* Candle scenes stand in the bottom corners (in the snow on dark sections). */
.xmas-candles { bottom: 0; width: clamp(96px, 9vw, 150px); }
.xmas-candles--l { left: clamp(2px, 1vw, 24px); }
.xmas-candles--r { right: clamp(2px, 1vw, 24px); }
.landing-section--dark > .xmas-decor .xmas-candles { bottom: 10px; }
.xmas-candles--hero { right: 1.5vw; width: clamp(170px, 15vw, 250px); }
@media (max-width: 1179px) { .xmas-hang--hero, .xmas-candles--hero { display: none; } }
@media (max-width: 759px) { .xmas-candles { display: none; } }

/* Unlit at level 1: dark wick, no flame, fairy bulbs are plain glass. */
.xm-flame, .xm-glint { opacity: 0; }
.xm-fairy { fill: #d9d3c4; stroke: rgba(0, 0, 0, 0.18); stroke-width: 0.5; }
.xm-tongue, .xm-glint { transform-box: fill-box; }
.xm-sway { transform-box: view-box; }  /* origin = top of its string (inline style) */
.xm-tongue { transform-origin: 50% 100%; }
.xm-glint { transform-origin: 50% 50%; }

/* Lit from level 2. */
html.xl3 .xm-flame { opacity: 1; transition: opacity 0.6s ease; }
html.xl3 .xm-tongue { animation: xm-flicker 1.6s ease-in-out infinite alternate; animation-delay: inherit; }
html.xl3 .xm-halo { animation: xm-halo 2.3s ease-in-out infinite alternate; animation-delay: inherit; }
/* The glow is a soft stroke, not a filter: filters are costly to repaint. */
html.xl3 .xm-fairy {
  fill: var(--c); stroke: var(--c); stroke-width: 3.5; stroke-opacity: 0.35;
  animation: xm-fairy 2.4s ease-in-out infinite alternate;
}
html.xl3 .xm-glint { animation: xm-glint 5.5s ease-in-out infinite; }
html.xl3 .xm-sway { animation: xm-sway 5s ease-in-out infinite alternate; }
.xmas-decor.is-off * { animation-play-state: paused !important; }

@keyframes xm-flicker {
  0%   { transform: scale(1, 1) skewX(0deg); }
  30%  { transform: scale(0.94, 1.08) skewX(2deg); }
  55%  { transform: scale(1.04, 0.95) skewX(-2deg); }
  80%  { transform: scale(0.97, 1.05) skewX(1deg); }
  100% { transform: scale(1, 0.98) skewX(-1deg); }
}
@keyframes xm-halo { from { opacity: 0.7; } to { opacity: 1; } }
@keyframes xm-fairy { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes xm-glint {
  0%, 74%, 100% { opacity: 0; transform: scale(0.3) rotate(0deg); }
  84% { opacity: 1; transform: scale(1) rotate(45deg); }
}
@keyframes xm-sway {
  from { transform: rotate(-2.5deg); }
  to   { transform: rotate(2.5deg); }
}

/* ---------------------------------------------------------------------------
   Snowfall canvas (front page, levels 3–4) — xmas.js
   --------------------------------------------------------------------------- */
.xmas-snow {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 60;
}

/* ---------------------------------------------------------------------------
   Falling present (levels 2+) — a real 3D box, spinning as it falls
   --------------------------------------------------------------------------- */
.xmas-present {
  position: fixed; left: 0; top: 0; z-index: 9000;
  width: 50px; height: 50px; padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 240px; -webkit-tap-highlight-color: transparent;
}
/* Hover glow sits behind the box: a filter on the box itself would flatten
   its 3D (filter forces transform-style: flat). */
.xmas-present::before {
  content: ''; position: absolute; inset: -14px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 120, 0.75), rgba(255, 220, 120, 0) 68%);
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none;
}
.xmas-present:hover::before { opacity: 1; }
.xmas-present:focus-visible { outline: 3px solid var(--xm-gold); outline-offset: 8px; border-radius: 8px; }
.xmas-box {
  --s: 50px; --h: 25px;
  position: absolute; inset: 0; transform-style: preserve-3d;
  animation: xmas-box-spin 5.5s linear infinite;
}
/* Always seen from above and a little off its corner, so the lid and two
   sides show at every moment: it never turns face-on and flat. */
@keyframes xmas-box-spin {
  from { transform: rotateX(-30deg) rotateY(45deg) rotateZ(5deg); }
  50%  { transform: rotateX(-38deg) rotateY(225deg) rotateZ(-5deg); }
  to   { transform: rotateX(-30deg) rotateY(405deg) rotateZ(5deg); }
}
.xmas-face {
  position: absolute; inset: 0; border-radius: 3px;
  background:
    linear-gradient(90deg, transparent 42%, var(--rib) 42% 58%, transparent 58%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.22), transparent 55%, rgba(0, 0, 0, 0.18)),
    var(--box);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  backface-visibility: hidden;
}
.xmas-face--front  { transform: translateZ(var(--h)); }
.xmas-face--back   { transform: rotateY(180deg) translateZ(var(--h)); }
.xmas-face--right  { transform: rotateY(90deg) translateZ(var(--h)); filter: brightness(0.86); }
.xmas-face--left   { transform: rotateY(-90deg) translateZ(var(--h)); filter: brightness(0.86); }
.xmas-face--top    {
  transform: rotateX(90deg) translateZ(var(--h)); filter: brightness(1.12);
  background:
    linear-gradient(90deg, transparent 42%, var(--rib) 42% 58%, transparent 58%),
    linear-gradient(0deg, transparent 42%, var(--rib) 42% 58%, transparent 58%),
    var(--box);
}
.xmas-face--bottom { transform: rotateX(-90deg) translateZ(var(--h)); filter: brightness(0.7); }
/* The bow: two crossed flat bows on the lid, so it reads from any angle. */
.xmas-bow {
  position: absolute; left: 50%; top: 0; width: 34px; height: 22px; margin: -19px 0 0 -17px;
  transform-style: preserve-3d;
}
.xmas-bow svg { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: visible; }
.xmas-bow svg:nth-child(2) { transform: rotateY(90deg); }
.xmas-present.is-opening .xmas-box { animation: xmas-box-pop 0.42s cubic-bezier(0.3, 1.6, 0.6, 1) forwards; }
@keyframes xmas-box-pop {
  0%   { transform: rotateX(-20deg) rotateY(20deg) scale(1); }
  55%  { transform: rotateX(-20deg) rotateY(40deg) scale(1.35); opacity: 1; }
  100% { transform: rotateX(-20deg) rotateY(60deg) scale(0.2); opacity: 0; }
}

/* ---------------------------------------------------------------------------
   The Christmas letter that comes out of the present
   --------------------------------------------------------------------------- */
.xmas-letter-backdrop {
  position: fixed; inset: 0; z-index: 9998;
  background: radial-gradient(circle at 50% 45%, rgba(20, 40, 28, 0.25), rgba(12, 20, 16, 0.5));
  opacity: 0; transition: opacity 0.35s ease;
}
.xmas-letter-backdrop.is-visible { opacity: 1; }
.xmas-letter {
  position: fixed; left: 0; top: 0; z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  padding: 1.5rem 1.45rem 1.15rem;
  /* Air-mail border in Christmas colours: the stripes are a border-box
     background under the paper (border-image can't round its corners). */
  border: 7px solid transparent; border-radius: 20px;
  background:
    radial-gradient(circle at 15% 10%, rgba(245, 200, 66, 0.12), transparent 40%) padding-box,
    radial-gradient(circle at 90% 95%, rgba(46, 125, 50, 0.08), transparent 45%) padding-box,
    linear-gradient(var(--xm-paper), var(--xm-paper)) padding-box,
    repeating-linear-gradient(-45deg, var(--xm-red) 0 11px, #fff 11px 20px, var(--xm-pine) 20px 31px, #fff 31px 40px) border-box;
  color: var(--xm-ink); font-family: 'Alegreya', Georgia, serif; text-align: left;
  box-shadow: 0 26px 60px rgba(10, 20, 14, 0.45);
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}
.xmas-letter:focus { outline: none; }
.xmas-letter-stamp {
  position: absolute; top: 14px; right: 14px; width: 46px; height: 54px;
  display: grid; place-items: center; font-size: 1.55rem;
  background: #fbe9e7; border: 2px solid #fff; outline: 2px dashed #e0b4ae; outline-offset: -6px;
  transform: rotate(6deg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.xmas-letter-kicker {
  display: block; margin: 0 4.1rem 0.3rem 0;
  font-family: var(--xm-hand); font-weight: 700; font-size: 1.35rem; line-height: 1.05; color: var(--xm-red);
}
.xmas-letter-title { margin: 0 4.1rem 0.6rem 0; font-size: 1.2rem; font-weight: 800; line-height: 1.25; }
.xmas-letter-text { margin: 0 0 1rem; font-size: 1rem; line-height: 1.55; }
.xmas-letter-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.xmas-letter-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--xm-pine); color: #fff; font-weight: 800; font-size: 0.92rem; text-decoration: none;
}
.xmas-letter-link:hover { background: var(--xm-green); color: #fff; text-decoration: none; }
.xmas-letter-sign { font-family: var(--xm-hand); font-size: 1.25rem; color: #6b5a3a; }
.xmas-letter-hint { margin: 0.7rem 0 0; font-size: 0.74rem; color: #9a927f; text-align: center; }
.xmas-letter .xmas-holly--letter { display: block; width: 52px; height: 33px; left: -20px; bottom: -18px; transform: rotate(-20deg); }

/* Sparkles and the little puff of magic smoke where the letter vanishes. */
.xmas-spark {
  position: fixed; left: 0; top: 0; z-index: 10000; pointer-events: none;
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, var(--c, #ffe082) 60%, transparent 72%);
}
.xmas-puff {
  position: fixed; left: 0; top: 0; z-index: 10000; pointer-events: none;
  width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 22%, rgba(214, 200, 255, 0.55) 45%, rgba(255, 240, 200, 0) 70%);
  filter: blur(1px);
}

/* People who asked their OS for less motion chose it for a reason: no
   twinkle, no spinning box (the level slider still lets them opt in to
   snow and presents explicitly). */
@media (prefers-reduced-motion: reduce) {
  html.xl3 .xmas-bulb::after { animation: none; opacity: 1; }
  html.xl3 .xm-tongue, html.xl3 .xm-halo, html.xl3 .xm-fairy, html.xl3 .xm-sway { animation: none; }
  html.xl3 .xm-glint { animation: none; opacity: 0; }
  .xmas-box { animation-duration: 14s; }
  .xmas-dock { transition: none; }
}

html.xmas body.skald-landing .landing-footer { position: relative; }

/* ---- The ravens' elf hat ----
   static/js/crow.js puts an empty head-gear box on every raven's crown and
   moves it with the head (see .crow-head-gear in static/css/crow.css);
   the Christmas theme draws the hat into it from level 1. */
html.xl1 .crow-head-gear {
  display: block;
  background-image: url("img/raven-hat.61b0c1c0867b.svg");
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
