/**
 * Seasonal Modes: shared layer
 *
 * Loaded only while a pack is active. Every rule is scoped to body.sm-active
 * so the normal site is untouched. Pack colours, images, cursors and the
 * site adapter's selectors arrive as an inline stylesheet built in PHP
 * (Seasonal_Modes::inline_css), mostly as the custom properties below.
 */

body.sm-active {
  --sm-accent: #c2410c;          /* accents only (rules, outlines), not body text */
  --sm-accent-soft: #fed7aa;
  --sm-ink: #1c1917;
  --sm-web-opacity: 0.32;
  --sm-web-size: clamp(120px, 15vw, 260px);
  --sm-web-filter: none;
  --sm-top-web-opacity: 0.55;
  --sm-top-web-filter: none;
}

/* ---------- Accents (the site's brand colour stays primary) ---------- */

body.sm-active main a:not(.wp-block-button__link):not(.wp-element-button):hover {
  text-decoration-color: var(--sm-accent);
}

body.sm-active :focus-visible {
  outline-color: var(--sm-accent);
}

body.sm-active .wp-block-button__link:hover,
body.sm-active .wp-element-button:hover {
  box-shadow: 0 0 0 2px var(--sm-accent-soft), 0 6px 18px -6px var(--sm-accent);
}

/* ---------- Corner art ----------
 * Painted behind page content (z-index -1 in the root stacking context), so
 * it can never sit on top of navigation, buttons or form controls.
 */
body.sm-active .sm-corners {
  position: fixed;
  top: var(--sm-top, 0px);
  right: 0;
  bottom: var(--sm-bottom, 0px);
  left: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

body.sm-active .sm-corner {
  position: absolute;
  display: block;
  width: var(--sm-web-size);
  max-width: none;
  height: auto;
  opacity: var(--sm-web-opacity);
  filter: var(--sm-web-filter);
  pointer-events: none;
}

body.sm-active .sm-corner--tl { top: 0; left: 0; }
body.sm-active .sm-corner--tr { top: 0; right: 0; transform: scaleX(-1); }
body.sm-active .sm-corner--bl { bottom: 0; left: 0; transform: scaleY(-1); }
body.sm-active .sm-corner--br { bottom: 0; right: 0; transform: scale(-1, -1); }

/* ---------- Top-corner webs ----------
 * Hang from the top of the window, in front of page content but under a
 * sticky header (most use z-index 10+). Never clickable. Sizes, tilt and
 * offsets per side come from the pack (Seasonal_Modes::inline_css).
 */
body.sm-active .sm-top-webs {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 9;
  height: 0;
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

body.sm-active .sm-top-web {
  position: absolute;
  display: block;
  max-width: none;
  height: auto;
  opacity: var(--sm-top-web-opacity);
  filter: var(--sm-top-web-filter);
  pointer-events: none;
}

body.sm-active .sm-top-web--left { transform-origin: top left; }
body.sm-active .sm-top-web--right { transform-origin: top center; } /* mirrored in place */

@media print {
  body.sm-active .sm-top-webs {
    display: none;
  }
}

@media (max-width: 781px) {
  body.sm-active {
    --sm-web-size: 96px;
    --sm-web-opacity: 0.28;
  }

  body.sm-active .sm-corner--tl,
  body.sm-active .sm-corner--br {
    display: none;
  }
}

/* ---------- Attribution line ---------- */
body.sm-active .sm-credit {
  margin: 0;
  padding: 12px 16px calc(12px + var(--sm-bottom, 0px));
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
  color: inherit;
}

body.sm-active .sm-credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--sm-accent);
}

/* ---------- Intro (first visit each season, see core.js) ---------- */
body.sm-active .sm-intro {
  position: fixed;
  inset: 0;
  z-index: 100000;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}

body.sm-active .sm-sprite {
  position: absolute;
  top: 100%;
  left: 0;
  display: block;
  max-width: none;
  height: auto;
  pointer-events: none;
  will-change: transform, opacity;
  /* Light rim keeps dark sprites visible on coloured cards and dark mode */
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

body.sm-active .sm-sprite--fall {
  top: auto;
  bottom: 100%;
}

@media (prefers-reduced-motion: reduce) {
  body.sm-active .sm-intro {
    display: none;
  }
}

@media print {
  body.sm-active .sm-corners,
  body.sm-active .sm-intro,
  body.sm-active .sm-credit {
    display: none;
  }
}
