/* ==== The seasonal layer (src/lib/seasons.ts) ===============================
   Linked only while a season is on, after styles.css and before that one
   season's tokens (<slug>.css): a page with no season carries none of this.

   A season is a layer, never a fourth palette. While the Forever palette is
   chosen it re-points the seventeen theme tokens at the season's own (--sz-*),
   so the whole site shifts hue at once and every pair the contrast gate holds
   still holds (test/seasons.test.ts checks each look against the same pairs
   as test/contrast.test.ts). On Alliance or Horde the visitor's faction
   colours stay; the season adds only its ornaments and particles.

   Every rule starts at :root[data-season]:not([data-season-off]). data-season
   is the server's (the season this request wears); data-season-off is the
   visitor's own "not for me" (the fw_season cookie, rendered by the server so
   nothing flashes, flipped in place by season.js). The extra attribute
   selectors also lift these rules above their styles.css counterparts. */

:root[data-season]:not([data-season-off])[data-theme="forever"] {
  --navy: var(--sz-navy);
  --page: var(--sz-page);
  --card: var(--sz-card);
  --border: var(--sz-border);
  --input-bg: var(--sz-input-bg);
  --input-border: var(--sz-input-border);
  --gold: var(--sz-gold);
  --ice: var(--sz-ice);
  --link: var(--sz-link);
  --teal: var(--sz-teal);
  --teal-hover: var(--sz-teal-hover);
  --text: var(--sz-text);
  --muted: var(--sz-muted);
  --parchment: var(--sz-parchment);
  --parchment-card: var(--sz-parchment-card);
  --parchment-border: var(--sz-parchment-border);
  --parchment-muted: var(--sz-parchment-muted);
}

/* The ground: a soft glow of the season's ice and gold at the top of the page.
   Under a wallpaper the picture (body::before) covers it. */
:root[data-season]:not([data-season-off])[data-theme="forever"] body {
  background: var(--sz-ground);
}

/* ---- ornaments ------------------------------------------------------------
   A strip along the header's foot (every palette), and one piece in the
   gutter left of the wordmark on a screen wide enough to hold it clear. Both
   are pseudo-elements at z-index -1 inside the header's own stacking context:
   over its background, under everything in it. The header's ::before is the
   wallpaper's glass, so the strip is ::after and the gutter piece hangs from
   .header-inner. */
:root[data-season]:not([data-season-off]) .site-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  height: var(--szo-strip-h);
  background: var(--szo-strip) 0 100% / auto 100% repeat-x;
  pointer-events: none;
}

@media (max-width: 767px) {
  :root[data-season]:not([data-season-off]) .site-header::after {
    height: 8px;
  }
}

@media (min-width: 1024px) {
  :root[data-season]:not([data-season-off]) .header-inner::before {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(var(--gutter) - var(--szo-corner-w) - 10px);
    width: var(--szo-corner-w);
    height: var(--szo-corner-w);
    transform: translateY(-50%) rotate(-6deg);
    background: var(--szo-corner) center / contain no-repeat;
    pointer-events: none;
  }
}

/* ---- the particles (public/season.js) ------------------------------------
   One canvas behind the page: over the page background and the wallpaper,
   under every card, word and control. season.js makes it only with motion
   allowed and the season on; these rules hide it at once if either changes
   with the page open. */
.season-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

:root[data-season-off] .season-fx {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .season-fx {
    display: none;
  }
}

/* ---- the visitor's switch (SeasonSwitch in src/views/layout.tsx) ---------
   Beside the theme control wherever that one is (header, drawer, footer).
   The icon is the season's own (--szo-icon, a mask, so it takes the colour):
   gold while the season shows, muted and struck through while this visitor
   has seasonal themes off. aria-pressed is the state; season.js keeps every
   copy in step. */
.season-switch {
  display: inline-flex;
  margin: 0;
}

.seasw {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--gold);
}

.seasw:hover {
  border-color: var(--gold);
}

.seasw:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 2px;
}

.seasw-ic {
  display: block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--szo-icon) center / contain no-repeat;
  mask: var(--szo-icon) center / contain no-repeat;
}

:root[data-season-off] .seasw {
  color: var(--muted);
}

:root[data-season-off] .seasw-ic {
  opacity: 0.6;
}

:root[data-season-off] .seasw::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(-42deg);
}

/* Forced colours repaint author backgrounds and leave a mask alone: the icon
   would vanish into the button. It keeps a system colour instead. */
@media (forced-colors: active) {
  .seasw-ic {
    forced-color-adjust: none;
    background: ButtonText;
  }

  :root[data-season-off] .seasw-ic {
    background: GrayText;
    opacity: 1;
  }

  :root[data-season-off] .seasw::after {
    forced-color-adjust: none;
    background: ButtonText;
  }
}

/* Paper gets the page, not the party. */
@media print {
  :root[data-season] .site-header::after,
  :root[data-season] .header-inner::before,
  .season-fx,
  .season-switch {
    display: none;
  }
}
