/* ==========================================================================
   The seasons (lib/Season.php)

   Only on a page that has a look: Season::prepare() asks for this file and
   marks the <body> with the look and its season (zb-look-christmas
   zb-season-winter), which is what every rule below hangs from.

    1. Colours
    2. The sprig beside the logo
    3. The garland under the header
    4. The view above the footer
    5. Things falling, and the button that stops them
    6. The preview bar
    7. Less motion, and print

   Nothing here moves for somebody whose device asks for less motion, or
   once anybody on this device has pressed the stop button (the zb-still
   class on <html>, shared with the moving sky on the home page).

   The pictures are drawn for every header the site has (light, dark, and
   forest over the home photograph), because a picture used as a background
   cannot see the theme. tools/build-seasons.php stamps their versions.
   ========================================================================== */


/* -- 1. Colours ------------------------------------------------------------
   What a season turns the ridge to, in each theme. Dark ones are deeper, so
   the view keeps its night. */

:root {
  --zb-season-gold:   #D69A26;   /* aspens in the fall */
  --zb-season-green:  #7DBB4F;   /* new grass in spring */
  --zb-season-hay:    #A9B44C;   /* summer grass */
  --zb-season-bat:    #2E2536;
  --zb-season-ink:    #3F5A73;   /* the outline that lets snow show on a pale page */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-bs-theme="light"]) {
    --zb-season-gold:   #8C6B22;
    --zb-season-green:  #4E7D33;
    --zb-season-hay:    #6E7A2E;
    --zb-season-bat:    #6E5E82;
    --zb-season-ink:    #0F1A12;
  }
}

:root[data-bs-theme="dark"] {
  --zb-season-gold:   #8C6B22;
  --zb-season-green:  #4E7D33;
  --zb-season-hay:    #6E7A2E;
  --zb-season-bat:    #6E5E82;
  --zb-season-ink:    #0F1A12;
}


/* -- 2. The sprig beside the logo -----------------------------------------
   The logo itself is never changed; a small sprig sits at its shoulder. */

.zb-header__logo { position: relative; }

.zb-header__logo::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -24px;
  width: 28px;
  height: 28px;
  background: center / contain no-repeat;
  pointer-events: none;
  transition: width var(--zb-mid) var(--zb-ease), height var(--zb-mid) var(--zb-ease),
              right var(--zb-mid) var(--zb-ease);
}

.zb-header.is-stuck .zb-header__logo::after { width: 22px; height: 22px; right: -19px; }

.zb-look-winter .zb-header__logo::after { background-image: url("../seasons/sprig-winter.svg?v=ef9a7698"); }
.zb-look-christmas .zb-header__logo::after { background-image: url("../seasons/sprig-christmas.svg?v=c3b3011b"); }
.zb-look-valentines .zb-header__logo::after { background-image: url("../seasons/sprig-valentines.svg?v=6a7505f2"); }
.zb-look-spring .zb-header__logo::after { background-image: url("../seasons/sprig-spring.svg?v=8c3e6d96"); }
.zb-look-easter .zb-header__logo::after { background-image: url("../seasons/sprig-easter.svg?v=a167e80e"); }
.zb-look-summer .zb-header__logo::after { background-image: url("../seasons/sprig-summer.svg?v=3a18c216"); }
.zb-look-july4 .zb-header__logo::after { background-image: url("../seasons/sprig-july4.svg?v=757501db"); }
.zb-look-fall .zb-header__logo::after { background-image: url("../seasons/sprig-fall.svg?v=240c2b91"); }
.zb-look-halloween .zb-header__logo::after { background-image: url("../seasons/sprig-halloween.svg?v=e5e16bc3"); }
.zb-look-thanksgiving .zb-header__logo::after { background-image: url("../seasons/sprig-thanksgiving.svg?v=7e6ed897"); }


/* -- 3. The garland under the header --------------------------------------
   For the big holidays only: a pine garland with lights at Christmas,
   bunting at Halloween, Easter and the Fourth. It hangs from the header's
   lower edge, so it travels with it as the page scrolls, and nothing can
   be clicked through it by mistake. Not over the home page's photograph:
   there it waits until the header has turned solid. */

.zb-look-christmas .zb-header::after,
.zb-look-halloween .zb-header::after,
.zb-look-easter .zb-header::after,
.zb-look-july4 .zb-header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 100%;
  height: 22px;
  margin-top: -3px;
  background: center top / auto 100% repeat-x;
  pointer-events: none;
}

.zb-look-christmas .zb-header::after { height: 24px; background-image: url("../seasons/garland-christmas.svg?v=75a013ad"); }
.zb-look-halloween .zb-header::after { background-image: url("../seasons/bunting-halloween.svg?v=9fb3ca50"); }
.zb-look-easter .zb-header::after { background-image: url("../seasons/bunting-easter.svg?v=52144e9b"); }
.zb-look-july4 .zb-header::after { background-image: url("../seasons/bunting-july4.svg?v=3e2ebdda"); }

.zb-header--over-hero:not(.is-stuck)::after { display: none; }


/* -- 4. The view above the footer ------------------------------------------
   Two kinds of change. The season's colour on the mountain and the ridge,
   made by mixing the time of day's own colours (zoiboyz.css, section 3)
   with the season's, so it works at dawn, day, dusk and night in either
   theme. And the touches drawn on top (Season::skyline()).

   The view's colours are read on the <svg> and changed on the <use>s inside
   it: a colour cannot be mixed from itself on one element. */

.zb-skyline {
  --zb-base-far:   var(--zb-skyline-far);
  --zb-base-snow:  var(--zb-skyline-snow);
  --zb-base-ridge: var(--zb-skyline-ridge);
}

/* Only where color-mix() is understood. A browser that can't read it
   (Safari before 16.2, still on older iPhones and iPads) would take the
   mixed colour as invalid when it came to draw, and paint the ridge black
   and lose the moon; without these rules it shows the usual view. */
@supports (color: color-mix(in oklab, red, red)) {
  /* Winter: snow on the mountain's shoulders and on the meadow. */
  .zb-season-winter .zb-skyline > use {
    --zb-skyline-far:   color-mix(in oklab, var(--zb-base-far) 62%, var(--zb-base-snow));
    --zb-skyline-ridge: color-mix(in oklab, var(--zb-base-ridge) 48%, var(--zb-base-snow));
  }

  /* Spring: new grass. Summer: the grass going to hay. Fall: aspen gold. */
  .zb-season-spring .zb-skyline > use {
    --zb-skyline-ridge: color-mix(in oklab, var(--zb-base-ridge) 55%, var(--zb-season-green));
  }

  .zb-season-summer .zb-skyline > use {
    --zb-skyline-ridge: color-mix(in oklab, var(--zb-base-ridge) 65%, var(--zb-season-hay));
  }

  .zb-season-fall .zb-skyline > use {
    --zb-skyline-ridge: color-mix(in oklab, var(--zb-base-ridge) 42%, var(--zb-season-gold));
  }

  /* A harvest moon, all fall. */
  .zb-season-fall .zb-skyline[data-zb-time="night"] {
    --zb-skyline-moon: color-mix(in oklab, var(--zb-skyline-night-moon) 35%, #F2A541);
  }
}

/* Christmas lights, in three groups that twinkle out of step: each group's
   brightness is a variable the lights read (tools/build-seasons.php). */
@property --zb-tw-a { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --zb-tw-b { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --zb-tw-c { syntax: "<number>"; inherits: true; initial-value: 1; }

.zb-sv--lights {
  animation: zb-tw-a 1.9s ease-in-out infinite alternate,
             zb-tw-b 2.6s ease-in-out -0.8s infinite alternate,
             zb-tw-c 2.2s ease-in-out -1.5s infinite alternate;
}

@keyframes zb-tw-a { to { --zb-tw-a: 0.3; } }
@keyframes zb-tw-b { to { --zb-tw-b: 0.3; } }
@keyframes zb-tw-c { to { --zb-tw-c: 0.3; } }

/* Fireflies: dusk and night only, glowing and going out. */
@property --zb-ff-a { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --zb-ff-b { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --zb-ff-c { syntax: "<number>"; inherits: true; initial-value: 1; }

.zb-sv--fireflies {
  display: none;
  animation: zb-ff-a 2.8s ease-in-out infinite alternate,
             zb-ff-b 3.5s ease-in-out -1.2s infinite alternate,
             zb-ff-c 2.4s ease-in-out -2s infinite alternate;
}

.zb-skyline[data-zb-time="dusk"] .zb-sv--fireflies,
.zb-skyline[data-zb-time="night"] .zb-sv--fireflies { display: inline; }

@keyframes zb-ff-a { to { --zb-ff-a: 0.08; } }
@keyframes zb-ff-b { to { --zb-ff-b: 0.08; } }
@keyframes zb-ff-c { to { --zb-ff-c: 0.08; } }

/* Jack-o'-lanterns light up at dusk. */
.zb-look-halloween .zb-skyline[data-zb-time="dusk"],
.zb-look-halloween .zb-skyline[data-zb-time="night"] {
  --zb-lantern-face: #FFD35A;
  --zb-lantern-glow: #FFB347;
}

/* Bats about the moon, at dusk and night. */
.zb-sv-bats { display: none; }

.zb-skyline[data-zb-time="dusk"] .zb-sv-bats,
.zb-skyline[data-zb-time="night"] .zb-sv-bats { display: inline; }

.zb-sv-bat path {
  fill: var(--zb-season-bat);
  transform-box: fill-box;
  transform-origin: center;
  animation: zb-bat-flap 0.3s ease-in-out infinite alternate;
}

.zb-sv-bat { animation: zb-bat-flit 7s ease-in-out infinite; }
.zb-sv-bat--2 { animation-duration: 9s; animation-direction: reverse; }
.zb-sv-bat--2 path { animation-duration: 0.26s; }
.zb-sv-bat--3 { animation-duration: 11s; animation-delay: -4s; }
.zb-sv-bat--3 path { animation-duration: 0.34s; }

@keyframes zb-bat-flap { to { transform: scaleY(0.35); } }

@keyframes zb-bat-flit {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(16px, -7px); }
  50%      { transform: translate(28px, 3px); }
  75%      { transform: translate(11px, 11px); }
}

/* Valentine's: a heart for a moon. */
.zb-look-valentines .zb-skyline[data-zb-time="night"] { --zb-skyline-moon: transparent; }

.zb-sv-heart { display: none; }
.zb-skyline[data-zb-time="night"] .zb-sv-heart { display: inline; }
/* The plain pink, unless color-mix() is understood. (Not as two lines one
   after the other: a line with var() in it is taken on trust when the
   stylesheet is read, so it would win, and only fail when drawn.) */
.zb-sv-heart__moon { fill: #F5B3C3; }

@supports (color: color-mix(in oklab, red, red)) {
  .zb-sv-heart__moon { fill: color-mix(in oklab, var(--zb-skyline-night-moon) 40%, #F07A98); }
}
.zb-sv-heart__glow { fill: #F07A98; opacity: 0.12; }   /* two, one inside the other: a soft edge */

/* The Fourth: fireworks at dusk and night, three bursts in turn. Gold
   rather than white for the middle one, which would vanish against the
   pale night sky of the light theme. */
.zb-sv-fireworks { display: none; }

.zb-skyline[data-zb-time="dusk"] .zb-sv-fireworks,
.zb-skyline[data-zb-time="night"] .zb-sv-fireworks { display: inline; }

.zb-sv-burst { animation: zb-burst 3s ease-out infinite; }
.zb-sv-burst--red { stroke: #E5484D; }
.zb-sv-burst--white { stroke: #F2C14E; animation-delay: -1s; }

/* The middle burst is high, 13% down, and at its fullest reaches about 21px
   from its middle. The view is 3600:430 and never under 110px tall
   (zoiboyz.css), so on one shorter than about 170px (phones, tablets, small
   laptops) its top edge would cut the burst off: lowered there by just
   enough, and not at all on a wider screen. */
.zb-sv-burst--white { translate: 0 max(0px, 22px - 0.13 * max(110px, 100vw * 430 / 3600)); }
.zb-sv-burst--blue { stroke: #5B8DEF; animation-delay: -2s; }

@keyframes zb-burst {
  0%   { transform: scale(0.2); opacity: 0; }
  10%  { opacity: 1; }
  55%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}


/* -- 5. Things falling, and the button that stops them --------------------
   One canvas over the page (assets/js/seasons.js), under the header and the
   corner buttons, never in the way of a click. It fades in once the page
   has settled, and out when stopped. */

.zb-fall {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.zb-fall.is-on { opacity: 1; }

/* Bottom-left, the corner the other two buttons leave free, and matching
   them. Only once something is falling, or once it has been stopped on this
   device, so there is always a way to start it again. */
.zb-season-stop {
  position: fixed;
  left: clamp(0.75rem, 3vw, 1.5rem);
  bottom: clamp(0.75rem, 3vw, 1.5rem);
  z-index: 40;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--zb-forest);
  color: var(--zb-cream);
  border: 2px solid var(--zb-sage);   /* softened below where color-mix() is understood */
  border-radius: 50%;
  box-shadow: var(--zb-shadow-2);
  cursor: pointer;
}

@supports (color: color-mix(in oklab, red, red)) {
  .zb-season-stop { border-color: color-mix(in srgb, var(--zb-sage) 55%, transparent); }
}

.zb-season-stop[hidden] { display: none; }
.zb-season-stop:hover { background: var(--zb-meadow); }

.zb-season-stop:focus-visible {
  outline: 3px solid var(--zb-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--zb-cream), var(--zb-shadow-2);
}

.zb-season-stop svg { width: 18px; height: 18px; fill: currentColor; }
.zb-season-stop__play { display: none; }
.zb-still .zb-season-stop__play { display: block; }
.zb-still .zb-season-stop__pause { display: none; }


/* -- 6. The preview bar -----------------------------------------------------
   Only while somebody is previewing a look (Season::previewBar()): Tom, KC
   or Brian, often on a phone, so the admin screens' sizes, 16px and up and
   48px to tap. Closed, it sits between the corner buttons; open, it may
   cover them, and closes again with the same tap. */

.zb-season-preview {
  position: fixed;
  left: 50%;
  bottom: clamp(0.75rem, 3vw, 1.5rem);
  translate: -50% 0;
  z-index: 41;
  max-width: calc(100vw - 9.5rem);
  padding: 0 1rem;
  background: var(--zb-surface-raised);
  color: var(--zb-text);
  border: 1.5px solid var(--zb-rule-strong);
  border-radius: 1.25rem;
  box-shadow: var(--zb-shadow-2);
  font-size: 1rem;
  line-height: 1.5;
}

/* Open, it is in front of everything, the sticky header too (z-index 50),
   and never taller than the screen: a phone on its side has about 330px to
   show, and the header's height changes as the page scrolls, so it can't
   promise to fit beneath it. */
.zb-season-preview[open] {
  z-index: 51;
  width: max-content;
  max-width: calc(100vw - 2rem);
}

/* So the looks scroll in a box of their own, below the heading, which is
   the way to close it again and so never scrolls away. The box is held to
   the screen less 7.5rem for the bar's place and 3rem for its heading.
   Every edge leaves room for a focus ring (5px outside what it circles:
   zoiboyz.css), so none is cut off where the box ends: the box reaches
   halfway out over the bar's sides, and the list and the last line leave a
   little room top and bottom. A link the keyboard brings into view stops
   that same little way in. It stops short of the bar's rounded lower
   corners, 8px in from each side and 4px up, because a scrollbar that
   takes room (a computer's, rather than a phone's) is square, and browsers
   don't round it off to match. */
.zb-season-preview__looks {
  max-height: calc(100vh - 10.5rem);
  max-height: calc(100dvh - 10.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -0.5rem 0.25rem;
  padding: 0 0.5rem;
  scroll-padding-block: 0.375rem;
}

/* Above "Change this hound" (zoiboyz.css), which is bottom-right for the
   same people, rather than over half of it. */
body:has(.zb-editthis) .zb-season-preview {
  bottom: calc(clamp(0.75rem, 3vw, 1.5rem) + 48px + 0.75rem);
}

.zb-season-preview summary {
  padding: 0.75rem 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zb-season-preview ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.25rem;
  margin: 0;
  padding: 0.375rem 0 0;
  list-style: none;
}

.zb-season-preview a {
  display: flex;
  align-items: center;
  min-height: 48px;
  color: var(--zb-link);
}

.zb-season-preview a[aria-current] { font-weight: 700; color: var(--zb-text); }
.zb-season-preview__end {
  margin: 0;
  padding-bottom: 0.375rem;
  border-top: 1px solid var(--zb-rule);
}


/* -- 7. Less motion, and print --------------------------------------------- */

/* Stopped on this device: everything holds where it is. */
.zb-still .zb-sv,
.zb-still .zb-sv-bat,
.zb-still .zb-sv-bat path,
.zb-still .zb-sv-burst { animation-play-state: paused; }

/* Less motion asked for: the touches stand still, lights all lit, bats and
   fireworks drawn as they are at rest. (zoiboyz.css shortens every
   animation already; this stops them outright.) */
@media (prefers-reduced-motion: reduce) {
  .zb-sv,
  .zb-sv-bat,
  .zb-sv-bat path,
  .zb-sv-burst { animation: none !important; }
}

/* JavaScript off: there is no button to stop them, so they don't start.
   (site.js marks <html> with .js as it runs.) */
:root:not(.js) .zb-sv,
:root:not(.js) .zb-sv-bat,
:root:not(.js) .zb-sv-bat path,
:root:not(.js) .zb-sv-burst { animation: none; }

@media print {
  .zb-fall,
  .zb-season-stop,
  .zb-season-preview,
  .zb-header::after,
  .zb-header__logo::after { display: none !important; }
}
