/* ═══════════════════════════════════════════════════════════════════════════
   Box & Found — Seasonal themes
   js/features/festive.js decides which one applies and when; see its header.
   Every selector here is under [data-festive], which that file sets on
   <html>, so with the attribute absent this stylesheet matches nothing and
   costs nothing.

   The file is in two halves. First the structure, which is the same for all
   three: five parts, each drawn entirely from custom properties.

     --festive-topper      something worn on the top-right of each logo:
                           a santa hat, a witch hat, a pair of bunny ears
     --festive-ridge       a tiling strip that settles on a top edge: snow,
                           dripping slime, grass
     --festive-bulb-a…d    the four colours of the garland under the header
     --festive-p1…p4       what drifts across the page — read by festive.js,
                           not used by any rule here, so the canvas follows
                           light and dark like everything else
     --festive-ink,-2,-3   the switch's own icon: body, highlight, base

   Then the three palettes, one block each, which is all a season is.

   Light mode is the awkward one for christmas: white snow on a #faf8f4 page
   is invisible. The ridge keeps a faint shadow under it and the falling
   flakes turn a cool grey; in dark mode both go white. Halloween has the
   opposite problem — a black bat on a near-black page — so its ink lightens
   in the dark.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ════════════════════════════ STRUCTURE ═══════════════════════════════════ */

/* ── The drift ─────────────────────────────────────────────────────────────
   z-index 90: under the sticky header (100) and every modal (1000+), over the
   page itself. Never in the way of a pointer. */
#festive-drift {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

/* ── Toppers ───────────────────────────────────────────────────────────────
   Pseudo-elements, so no markup changes and nothing to undo. Each theme sets
   the artwork and nudges the size, offset and tilt to suit it: a hat sits on
   the corner of the logo, ears stand up behind it. */
[data-festive] {
  --festive-topper-size:  62px;
  --festive-topper-x:     6px;
  --festive-topper-y:    -6px;
  --festive-topper-tilt:  14deg;
  --festive-topper-mini-size: 19px;
  --festive-topper-mini-x:    13px;
  --festive-topper-mini-y:     0px;
  --festive-ridge-shadow: 0 1px 1px rgba(90,70,40,0.10);
  --festive-wire: rgba(120,110,95,0.45);
  --festive-blink: 1.9s;
}

[data-festive] .ob-logo { position: relative; }
[data-festive] .ob-logo::after {
  content: '';
  position: absolute;
  width: var(--festive-topper-size); height: var(--festive-topper-size);
  top: var(--festive-topper-y); left: 50%;
  margin-left: var(--festive-topper-x);   /* out from the logo's centre line */
  background: var(--festive-topper) center / contain no-repeat;
  transform: rotate(var(--festive-topper-tilt));
  filter: drop-shadow(0 3px 6px rgba(40,20,10,0.26));
  pointer-events: none;
}

/* The app header's 32px logo wears a small one. .header-logo is the flex row
   holding the image and the wordmark, and the image is its first child at the
   left edge, so the topper can be placed from that corner. */
[data-festive] .header-logo { position: relative; }
[data-festive] .header-logo::before {
  content: '';
  position: absolute;
  width: var(--festive-topper-mini-size); height: var(--festive-topper-mini-size);
  top: var(--festive-topper-mini-y); left: var(--festive-topper-mini-x);
  background: var(--festive-topper) center / contain no-repeat;
  transform: rotate(var(--festive-topper-tilt));
  pointer-events: none;
  z-index: 1;
}

/* ── Something settling on a top edge ──────────────────────────────────────
   One shared ridge. Each user sets its own offsets; it always overlaps the
   element's top edge by a few pixels so it reads as settled, not floating.

   Three places, chosen because each has a top edge worth settling on. The
   landing page's round theme toggle was a fourth and is not any more: a cap
   that narrow came out as a sliver, and giving it `position: relative` so the
   cap could hang off it took the button out of the corner it is fixed to. */
[data-festive] .btn-ob-primary,
[data-festive] .app-footer-link,
[data-festive] .app-footer { position: relative; }

[data-festive] .btn-ob-primary::before,
[data-festive] .app-footer-link::before,
[data-festive] .app-footer::before {
  content: '';
  position: absolute;
  background-image: var(--festive-ridge);
  background-repeat: repeat-x;
  filter: drop-shadow(var(--festive-ridge-shadow));
  pointer-events: none;
}

/* The big CTA: a full ridge across the top, inset so it doesn't overhang the
   22px corners. */
[data-festive] .btn-ob-primary::before {
  left: 12px; right: 12px; top: -6px; height: 11px;
  background-size: 128px 11px;
}
/* The footer's two text buttons get a smaller one. The tile stays wide: the
   ridge has nine bumps in it, and squeezing all nine into the width of a
   40-pixel word turns snow into a saw blade. */
[data-festive] .app-footer-link::before {
  left: -3px; right: -3px; top: -6px; height: 8px;
  background-size: 112px 8px;
}
/* And a drift along the whole top edge of the app footer. */
[data-festive] .app-footer::before {
  left: 0; right: 0; top: -9px; height: 14px;
  background-size: 150px 14px;
}

/* ── A garland under the app header ────────────────────────────────────────
   Bulbs in two layers so they can twinkle out of phase; the wire rides along
   with the first one. Every bulb is a radial-gradient — no extra requests, no
   SVG animation (which browsers decline to run inside a background image). */
[data-festive] .app-header { position: relative; }
[data-festive] .app-header::before,
[data-festive] .app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -13px;
  height: 14px;
  pointer-events: none;
  background-repeat: repeat-x;
  background-size: 104px 14px;
  z-index: 2;
}
[data-festive] .app-header::before {
  background-image:
    radial-gradient(circle 3.5px at 14px 9px, var(--festive-bulb-a) 98%, transparent 100%),
    radial-gradient(circle 3.5px at 66px 9px, var(--festive-bulb-c) 98%, transparent 100%),
    linear-gradient(to bottom, transparent 4px, var(--festive-wire) 4px 6px, transparent 6px);
  animation: festive-twinkle-a 2.6s ease-in-out infinite;
}
[data-festive] .app-header::after {
  background-image:
    radial-gradient(circle 3.5px at 40px 9px, var(--festive-bulb-b) 98%, transparent 100%),
    radial-gradient(circle 3.5px at 92px 9px, var(--festive-bulb-d) 98%, transparent 100%);
  animation: festive-twinkle-b 2.6s ease-in-out infinite;
}
@keyframes festive-twinkle-a {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@keyframes festive-twinkle-b {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* ── The switch, which is also a decoration ────────────────────────────────
   Built by festive.js into both footers: a tree, a pumpkin or an egg. Off, it
   keeps its shape and loses its colour, so it reads as "the decorations are
   off" rather than vanishing. */
.festive-switch {
  background: none;
  border: none;
  padding: 2px;
  margin: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 8px;
  color: inherit;
  transition: transform 0.15s, background 0.15s;
}
.festive-switch:hover { background: var(--surface-2); transform: translateY(-1px); }
.festive-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.festive-ink    { fill: var(--festive-ink,   #2d8c26); }
.festive-ink-2  { fill: var(--festive-ink-2, #e8a020); }
.festive-ink-3  { fill: var(--festive-ink-3, #7a5230); }
.festive-light  { fill: var(--festive-glow,  #fff); animation: festive-blink var(--festive-blink) ease-in-out infinite; }
/* Four or five lights, each a beat behind the one before. */
.festive-light:nth-of-type(1) { animation-delay: 0s; }
.festive-light:nth-of-type(2) { animation-delay: 0.38s; }
.festive-light:nth-of-type(3) { animation-delay: 0.76s; }
.festive-light:nth-of-type(4) { animation-delay: 1.14s; }
.festive-light:nth-of-type(5) { animation-delay: 1.52s; }
@keyframes festive-blink {
  0%, 100% { opacity: 1; }
  45%      { opacity: 0.25; }
}

/* On the landing page the switch takes a line of its own under the legal
   links, centred, the way the social icons take the line above them. */
.ob-legal-footer .festive-switch { flex-basis: 100%; display: flex; justify-content: center; margin-top: 2px; }

/* Lights out: the switch stays clickable, the theme is off. */
html:not([data-festive]) .festive-switch { opacity: 0.55; }
html:not([data-festive]) .festive-switch:hover { opacity: 1; }
html:not([data-festive]) .festive-ink,
html:not([data-festive]) .festive-ink-2,
html:not([data-festive]) .festive-ink-3 { fill: var(--text-faint); }
html:not([data-festive]) .festive-light { fill: var(--text-faint); animation: none; opacity: 0.7; }

/* ── Reduced motion ───────────────────────────────────────────────────────
   festive.js skips the drift canvas entirely under this preference. The rest
   of the decorations stay — they just hold still. */
@media (prefers-reduced-motion: reduce) {
  [data-festive] .app-header::before,
  [data-festive] .app-header::after,
  .festive-light {
    animation: none;
  }
  [data-festive] .app-header::before { opacity: 1; }
  [data-festive] .app-header::after  { opacity: 1; }
  .festive-switch:hover { transform: none; }
}

/* ── Small screens ────────────────────────────────────────────────────────
   The landing logo shrinks, so its topper shrinks with it, and the footer's
   two text buttons sit close enough together that a ridge on each is more
   clutter than cheer. */
@media (max-width: 560px) {
  [data-festive] { --festive-topper-size: 48px; --festive-topper-x: 2px; --festive-topper-y: -4px; }
  [data-festive] .app-footer-link::before { display: none; }
}

/* ═══════════════════════════════ CHRISTMAS ════════════════════════════════
   1 December – 6 January. Snow, santa hats, a tree. */
[data-festive="christmas"] {
  --festive-p1: rgba(125,160,195,0.72);        /* flakes, cool grey on light */
  --festive-bulb-a: #c62828;
  --festive-bulb-b: #e8a020;
  --festive-bulb-c: #2d8c26;
  --festive-bulb-d: #4a90d9;
  --festive-ink:   #2d8c26;                    /* tree */
  --festive-ink-2: #e8a020;                    /* star */
  --festive-ink-3: #7a5230;                    /* trunk */
  --festive-glow:  #ffd166;

  /* A tiling snow ridge, 120×14, flat along the bottom so it can overlap
     whatever it is resting on. Starts and ends at the same height, so it
     repeats seamlessly. */
  --festive-ridge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M0 14 V8 C4 3 9 3 13 7 C17 11 22 11 26 6 C30 1 36 1 40 6 C44 11 50 11 54 7 C58 3 64 2 68 7 C72 12 78 12 82 7 C86 2 92 2 96 7 C100 12 106 12 110 7 C114 2 118 4 120 8 V14 Z'/%3E%3C/svg%3E");

  /* A santa hat: bent cone in red with a white brim and a pom at the tip.
     No commas in the path data — a comma inside a url() in a custom property
     is a minefield across engines. */
  --festive-topper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%23c62828' d='M7 48 C6 24 23 8 43 10 C51 11 55 15 52 19 C44 24 37 34 35 48 Z'/%3E%3Cpath fill='%23e04b4b' d='M7 48 C6 26 22 10 41 11 C45 11 48 12 50 14 C36 14 20 28 14 48 Z' opacity='0.45'/%3E%3Crect x='2' y='42' width='42' height='15' rx='7.5' fill='%23ffffff'/%3E%3Ccircle cx='53' cy='17' r='8' fill='%23ffffff'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════ HALLOWEEN ════════════════════════════════
   24 October – 1 November. Bats, witch hats, a jack-o'-lantern, and slime
   where the snow was. */
[data-festive="halloween"] {
  --festive-p1: rgba(32,26,40,0.82);           /* bats, near-black on light */
  --festive-p2: rgba(60,40,78,0.78);
  --festive-bulb-a: #e8731a;
  --festive-bulb-b: #7b4ea8;
  --festive-bulb-c: #e8a020;
  --festive-bulb-d: #4caf50;
  --festive-ink:   #e8731a;                    /* pumpkin */
  --festive-ink-2: #e8731a;
  --festive-ink-3: #4e7c3a;                    /* stem, grass */
  --festive-glow:  #ffd166;                    /* the candle inside it */
  --festive-wire:  rgba(123,78,168,0.55);
  --festive-blink: 1.1s;                       /* a candle flickers faster */
  --festive-ridge-shadow: 0 1px 2px rgba(60,20,80,0.25);

  /* Slime: the same 120×14 tile, but the bumps hang down as drips instead of
     rising as drifts, and it is flipped so the flat edge is on top. */
  --festive-ridge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath fill='%237b4ea8' d='M0 0 H120 V5 L112 5 C112 12 105 12 105 5 L95 5 C95 9 89 9 89 5 L78 5 C78 14 70 14 70 5 L58 5 C58 10 52 10 52 5 L40 5 C40 12 33 12 33 5 L22 5 C22 8 17 8 17 5 L8 5 C8 11 3 11 3 5 L0 5 Z'/%3E%3C/svg%3E");

  /* A witch hat: wide brim, bent cone, a band across it. */
  --festive-topper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%231e1726' d='M30 8 C34 8 37 11 38 16 L44 44 L14 46 L24 18 C25 12 27 8 30 8 Z'/%3E%3Cpath fill='%237b4ea8' d='M19 36 L43 34 L45 43 L17 45 Z'/%3E%3Cpath fill='%23e8a020' d='M28 36 L34 35 L35 42 L29 43 Z'/%3E%3Cellipse cx='30' cy='48' rx='27' ry='8' fill='%231e1726'/%3E%3Cellipse cx='30' cy='46.5' rx='15' ry='4' fill='%232c2235'/%3E%3C/svg%3E");
}

/* ════════════════════════════════ EASTER ══════════════════════════════════
   Palm Sunday – Easter Monday. Petals, bunny ears, an egg, and grass where
   the snow was. */
[data-festive="easter"] {
  --festive-p1: #f2a8c4;                       /* petals, four pastels */
  --festive-p2: #c4a8ea;
  --festive-p3: #a8dcc0;
  --festive-p4: #f6d87a;
  --festive-bulb-a: #f2a8c4;
  --festive-bulb-b: #f6d87a;
  --festive-bulb-c: #a8dcc0;
  --festive-bulb-d: #c4a8ea;
  --festive-ink:   #7ec8a9;                    /* the egg */
  --festive-ink-2: #f2a8c4;
  --festive-ink-3: #5aa05f;                    /* grass */
  --festive-glow:  #ffffff;
  --festive-wire:  rgba(140,180,150,0.6);
  --festive-blink: 2.8s;                       /* a slow pulse, not a blink */
  --festive-ridge-shadow: 0 1px 2px rgba(40,90,50,0.22);

  /* Grass: blades along the top edge rather than a drift. */
  --festive-ridge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath fill='%235aa05f' d='M0 14 V12 Q2 5 5 2 Q11 5 17 12 Q22 9 28 6 Q31 9 34 12 Q37 6 40 3 Q46 6 51 12 Q56 8 63 5 Q66 8 68 12 Q71 4 74 1 Q80 4 85 12 Q90 7 95 4 Q98 7 102 12 Q105 9 109 6 Q114 9 119 12 H120 V14 Z'/%3E%3C/svg%3E");

  /* Bunny ears: two of them, the near one tilted, with pink inners. */
  --festive-topper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%23f3eee6' d='M22 58 C16 46 12 30 15 16 C16 9 21 5 25 6 C29 7 31 13 30 21 C29 33 27 47 28 58 Z'/%3E%3Cpath fill='%23f2a8c4' d='M22 50 C19 40 18 28 20 18 C21 13 23 11 25 11 C27 12 27 16 26 23 C25 32 24 42 24 50 Z'/%3E%3Cpath fill='%23f3eee6' d='M36 58 C38 46 40 30 45 18 C48 11 53 9 56 11 C59 14 58 20 54 27 C48 37 42 48 41 58 Z'/%3E%3Cpath fill='%23f2a8c4' d='M39 51 C41 41 44 30 48 22 C50 18 52 17 53 18 C54 20 53 23 50 29 C46 37 42 44 41 51 Z'/%3E%3C/svg%3E");
  --festive-topper-size: 58px;
  --festive-topper-x: -22px;                   /* ears stand up behind it */
  --festive-topper-y: -32px;
  --festive-topper-tilt: -4deg;
  --festive-topper-mini-size: 18px;
  --festive-topper-mini-x: 6px;
  --festive-topper-mini-y: -7px;
}
@media (max-width: 560px) {
  [data-festive="easter"] { --festive-topper-size: 46px; --festive-topper-x: -18px; --festive-topper-y: -25px; }
}

/* ══════════════════════════════ DARK MODE ════════════════════════════════
   What the three palettes change when the page is dark: the shadow under
   every ridge, white snow instead of grey, bats light enough to see against
   a near-black page. Halloween keeps its purple wire and easter its green —
   both read fine either way.

   Two copies of the block, as everywhere else in this project: one for a
   theme the visitor chose, one for the one their browser asked for. */
[data-theme="dark"][data-festive]             { --festive-ridge-shadow: 0 1px 2px rgba(0,0,0,0.35); }
[data-theme="dark"][data-festive="christmas"] { --festive-p1: rgba(255,255,255,0.88); --festive-wire: rgba(255,255,255,0.28); }
[data-theme="dark"][data-festive="halloween"] { --festive-p1: rgba(176,160,200,0.62); --festive-p2: rgba(210,150,90,0.55); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-festive]             { --festive-ridge-shadow: 0 1px 2px rgba(0,0,0,0.35); }
  :root:not([data-theme="light"])[data-festive="christmas"] { --festive-p1: rgba(255,255,255,0.88); --festive-wire: rgba(255,255,255,0.28); }
  :root:not([data-theme="light"])[data-festive="halloween"] { --festive-p1: rgba(176,160,200,0.62); --festive-p2: rgba(210,150,90,0.55); }
}
