/* ══════════════════════════════════════════════════════════════════
   seasonal.css — winter decorations, December 1 to January 6

   Isolated on purpose. Every selector either targets an id that only
   js/seasonal.js creates, or is scoped under .cg-season-on on <html>, the
   class that script adds while the decorations are on. One single rule
   reaches an existing element, the .cg-topbar positioning context below,
   and it is scoped by that class. Removing the season means deleting the
   two files and their two include lines: nothing in style.css depends on
   this, and nothing here overrides style.css.

   No external image or font, no filter, no box-shadow animation.
   Animated properties are transform and opacity only.
   ══════════════════════════════════════════════════════════════════ */

/* ── Palette ──
   Soft tones that sit next to the site accent without fighting it.
   Snow and thread need their own value per theme to stay readable on
   both backgrounds. */
:root {
  --cgs-red:   #e0645c;
  --cgs-gold:  #e8c97c;
  --cgs-green: #5f9e6b;
  --cgs-snow:  rgba(242, 245, 248, .80);
  --cgs-cream: #f2f5f8;
  --cgs-brown: #b98a5a;
  --cgs-thread: rgba(242, 245, 248, .28);
}
:root[data-theme="light"] {
  --cgs-red:   #c9534c;
  --cgs-gold:  #c79a3c;
  --cgs-green: #4a8456;
  --cgs-snow:  rgba(91, 103, 118, .48);
  --cgs-cream: #ffffff;
  --cgs-brown: #a4733f;
  --cgs-thread: rgba(15, 23, 32, .22);
}

/* ══════════════════════════════════════════════════════════════════
   SNOW
   Fixed overlay at z-index 0: above the page background, below every
   content wrapper (.wrap and friends sit at z-index 1) and far below
   the header (50), the modals (200) and the toasts (300). So snow can
   never land on a word or swallow a click.
   ══════════════════════════════════════════════════════════════════ */

#cg-snow {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  contain: layout paint;
}

.cgs-flake {
  position: absolute; top: 0; left: var(--x);
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--cgs-snow);
  opacity: 0;
  will-change: transform, opacity;
  animation: cgs-fall var(--t) linear var(--delay) infinite;
}

@keyframes cgs-fall {
  0%   { transform: translate3d(0, -12vh, 0); opacity: 0; }
  12%  { opacity: var(--o); }
  88%  { opacity: var(--o); }
  100% { transform: translate3d(var(--dx), 112vh, 0); opacity: 0; }
}

/* Tab in the background: stop the animation instead of burning frames */
#cg-snow.is-paused .cgs-flake { animation-play-state: paused; }

/* No falling snow when motion is not wanted: six faint flakes, placed
   with the same per flake variables, nothing moving. */
@media (prefers-reduced-motion: reduce) {
  .cgs-flake {
    animation: none;
    transform: translate3d(0, var(--y), 0);
    opacity: calc(var(--o) * .65);
    will-change: auto;
  }
  .cgs-flake:nth-child(n+7) { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   GARLAND under the header bar
   Absolutely positioned, hanging just below the bottom border of the
   topbar, so it takes no space in the flow and shifts nothing. 9px
   tall, the bulbs live in an SVG pattern that repeats at any viewport
   width without stretching.

   The anchor has to be .cg-topbar, not #cg-header: layout.js appends the
   announcement bar inside #cg-header too, so top:100% of the host would
   drop the garland under the announcement instead of under the header
   bar. .cg-topbar is static in style.css, hence this one rule. No
   z-index, so paint order inside the header does not change.
   ══════════════════════════════════════════════════════════════════ */

/* While the decorations are on, the announcement bar steps aside so the
   garland reads as part of the header instead of cutting the bar in two.
   layout.js appends it as .cg-announce inside #cg-header; it is only
   hidden, never removed, so its rotation and its dismiss key are
   untouched and the bar is back the moment the toggle goes off (the
   .cg-season-on class is what disappears). */
.cg-season-on #cg-header .cg-announce { display: none; }

.cg-season-on .cg-topbar { position: relative; }

#cg-season-garland {
  position: absolute; left: 0; right: 0; top: 100%;
  height: 9px; pointer-events: none;
  line-height: 0;
}
#cg-season-garland svg { display: block; width: 100%; height: 9px; }

/* ══════════════════════════════════════════════════════════════════
   BAUBLES next to the logo
   In flow, 15px wide, hidden once the header gets tight. The header is
   tuned for a connected wallet button with the longest chain name, so
   nothing decorative is allowed to compete for width on small screens.
   ══════════════════════════════════════════════════════════════════ */

#cg-season-baubles {
  display: flex; align-items: flex-start;
  width: 15px; margin-left: -2px;
  line-height: 0; pointer-events: none;
}
@media (max-width: 1050px) {
  #cg-season-baubles { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   TOGGLE BUTTON
   Same size and shape as #theme-btn so the header keeps its rhythm.
   ══════════════════════════════════════════════════════════════════ */

#cg-season-toggle {
  flex: none;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted); cursor: pointer;
  transition: color .2s, border-color .2s;
}
#cg-season-toggle:hover { border-color: var(--cg-accent); color: var(--text); }
#cg-season-toggle:focus-visible { outline: 2px solid var(--cg-accent); outline-offset: 2px; }
/* Decorations off: the icon stays, dimmed, so the way back is obvious */
#cg-season-toggle[aria-pressed="false"] { color: var(--text-muted); opacity: .55; }
#cg-season-toggle[aria-pressed="true"]  { color: var(--cg-accent); opacity: 1; }

@media (max-width: 600px) {
  #cg-season-toggle { width: 30px; height: 30px; }
}
@media (max-width: 380px) {
  #cg-season-toggle { width: 28px; height: 28px; }
}

/* ══════════════════════════════════════════════════════════════════
   SCATTERED DRAWINGS
   One drawing per anchor, absolutely positioned in space that is empty
   at every width. Each anchor needs to be a positioning context, which
   is the only reason these existing selectors appear here, all scoped
   under .cg-season-on so they vanish with the season.

   Every offset is zero or positive and every anchor sits inside a padded
   wrapper, so a drawing can never reach past the viewport and never adds
   horizontal scroll, down to 320px.
   ══════════════════════════════════════════════════════════════════ */

.cg-season-on .tp-hero,
.cg-season-on .tp-section-label,
.cg-season-on .ch-card h2,
.cg-season-on .doc-main h2,
.cg-season-on .cl-section-title,
.cg-season-on .cp-section-title,
.cg-season-on #cg-footer .cg-footer { position: relative; }

.cgs-art {
  position: absolute;
  line-height: 0; pointer-events: none;
  transform: rotate(var(--cgs-tilt, 0deg));
  transform-origin: 50% 100%;
}
.cgs-art svg { display: block; height: 26px; width: auto; }

/* Below the hero, inside its 48px bottom margin (26px drawing + 8px
   offset), at the opposite end from a label drawing in the same band. */
.cgs-s-herogap { left: 2px; top: 100%; margin-top: 8px; }

/* Beside the centred hero title, in the page margin. The home title is
   short, so even at 320px there is about 55px of clear space each side. */
.cgs-s-heroside { left: 0; bottom: 2px; }
.cgs-s-heroside svg { height: 24px; }

/* In the gap above a section label or a card heading, right hand end.
   On a .ch-card h2 the drawing uses the 18px card padding and peeks a
   few px over the card border, which is the intended corner look. */
.cgs-s-label,
.cgs-s-label2 { right: 0; bottom: calc(100% + 2px); }
.cgs-s-label svg,
.cgs-s-label2 svg { height: 24px; }

/* Peeking over the top right corner of the December Challenge banner.
   right:44px clears the close button (right:10px, 26px wide), and the
   12px that reach inside stay in the card's 16px top padding, so the
   drawing stops above the text. The 14px above the card sit in the
   action bar's 16px bottom margin. */
.cgs-s-banner { right: 44px; bottom: calc(100% - 12px); }
.cgs-s-banner svg { height: 26px; }

/* Bottom left of the footer, inside its 20px padding, next to the links
   rather than in a row of its own. Desktop only. */
.cgs-s-footer { left: 16px; bottom: 18px; }

/* Responsive budget: rank 1 survives every width, rank 2 down to 380px,
   ranks 3 and 4 are desktop only. So a page shows at most 2 drawings at
   720px and at most 1 at 380px.

   The footer and the banner are pinned to desktop on top of that, by
   slot rather than by rank: the footer links wrap into several centred
   lines on a phone and the banner card loses its padding, so neither
   keeps a reliably empty corner. A page can therefore end up showing
   fewer than the budget allows, never more. */
@media (max-width: 720px) {
  .cgs-art[data-cgs-prio="3"],
  .cgs-s-footer,
  .cgs-s-banner { display: none; }
}
@media (max-width: 380px) {
  .cgs-art[data-cgs-prio="2"] { display: none; }
}

/* Shared SVG part colors, so a drawing never hardcodes a theme value */
.cgs-snow-fill  { fill: var(--cgs-cream); }
.cgs-red-fill   { fill: var(--cgs-red); }
.cgs-gold-fill  { fill: var(--cgs-gold); }
.cgs-green-fill { fill: var(--cgs-green); }
.cgs-brown-fill { fill: var(--cgs-brown); }
.cgs-lime-fill  { fill: var(--cg-accent); }
.cgs-thread     { stroke: var(--cgs-thread); }
.cgs-line       { stroke: var(--text-muted); }
