/* Site chrome (PLAN.md §3.5, §9 WP6): the sticky header, its Appearance switch and its menu sheet, the minimal wordmark bar, the
   footer, the shared live dot, and the admin Dev page. Loaded on every page (Layout BASE_STYLES), so it stays small.
   Colours are tokens.css's semantic ones, so the chrome follows the light or dark scheme.
   Prefix: site-. Motion: transform and opacity only (§3.6); reduced motion and Calm mode at the end. */

/* ── Live dot (header, landing chip, mini-stage) ───────────────────────────────────────────────────────────── */
.site-live__dot {
  position: relative;
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--party);
}
.site-live__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--party);
  animation: site-ping 2.2s var(--ease-out) infinite;
}
@keyframes site-ping {
  from { transform: scale(1); opacity: .75; }
  to { transform: scale(3); opacity: 0; }
}

/* ── Header (64 px, sticky) ────────────────────────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sheet) - 1);
  height: var(--header-h);
  isolation: isolate;
}
/* backdrop and hairline are separate layers so scrolling only fades opacity (§3.6) */
.site-header::before,
.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.site-header::before {
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  backdrop-filter: saturate(150%) blur(8px);
}
.site-header::after {
  inset: auto 0 0;
  height: 1px;
  background: var(--line);
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out);
}
.site-header[data-scrolled]::after { opacity: 1; }

.site-header__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
  /* viewport-fit=cover: keep clear of a landscape phone's notch */
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.site-header__nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
}
.site-header__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: .9375rem;
  font-weight: 600;
  text-decoration: none;
}
.site-header__link:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
.site-header__link[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--text) 11%, transparent); }
.site-header__cta { margin-inline-start: auto; white-space: nowrap; }
.site-header__cta-more { display: none; }
.site-header__menu {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
}
.site-header__menu:hover { border-color: var(--text-3); }
.site-burger { position: relative; display: block; width: 18px; height: 12px; }
.site-burger::before, .site-burger::after, .site-burger > span {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.site-burger::before { top: 0; }
.site-burger > span { top: 5px; }
.site-burger::after { bottom: 0; }

@media (min-width: 380px) {
  .site-header__cta-more { display: inline; }
}
@media (min-width: 860px) {
  .site-header__nav { display: flex; }
  .site-header__cta { margin-inline-start: var(--space-2); }
  .site-header__menu { display: none; }
}

/* ── Appearance switch (SiteHeader.tsx AppearanceSwitch; client/site/chrome.ts): System / Light / Dark ───── */
/* Shown once JavaScript runs (theme-boot.js sets html[data-js] before the first paint, so it never pushes the header about). The
   selected option is html[data-theme]'s (absent = System), the same moment the colours change; the radios follow it for assistive
   technology. The header's copy is icons only, from 860 px; the menu sheet's has words. */
.site-appearance { display: none; }
:root[data-js] .site-appearance--menu { display: grid; }
.site-appearance__opts {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
.site-appearance__opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.site-appearance__opt > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.site-appearance__opt:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.site-appearance__opt:has(> input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.site-appearance__icon { flex: none; pointer-events: none; }
:root:not([data-theme]) .site-appearance__opt[data-choice="system"],
:root[data-theme="light"] .site-appearance__opt[data-choice="light"],
:root[data-theme="dark"] .site-appearance__opt[data-choice="dark"] { background: var(--text); color: var(--bg); }
.site-appearance--menu {
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}
.site-appearance__k { color: var(--text-3); font: 600 .75rem/1.2 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; }
.site-appearance--menu .site-appearance__opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; }
.site-appearance--menu .site-appearance__opt { height: 44px; padding: 0 var(--space-2); font: 600 .9375rem/1 var(--font-ui); }
@media (min-width: 860px) {
  :root[data-js] .site-appearance--bar { display: block; flex: none; margin-inline-start: var(--space-2); }
}

/* ── Menu sheet (Popover API; data-open is the fallback set by site.js) ──────────────────────────────────── */
.site-menu {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 400px);
  height: 100%;
  max-height: none;
  margin: 0;
  padding: var(--space-3) var(--gutter) var(--space-6);
  border: 0;
  border-inline-start: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  display: none;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: var(--z-sheet);
}
.site-menu:popover-open { display: flex; }
.site-menu[data-open] { display: flex; }
.site-menu:popover-open {
  transform: none;
  opacity: 1;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-3) var(--ease-out);
}
@starting-style {
  .site-menu:popover-open { transform: translateX(32px); opacity: 0; }
}
.site-menu::backdrop { background: rgb(7 6 26 / calc(.64 * var(--scrim-a, 1))); }   /* an old ::backdrop inherits nothing: 1 */
html:has(.site-menu:popover-open), html:has(.site-menu[data-open]) { overflow: hidden; }       /* the page behind the open sheet does not scroll */
.site-menu__top { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.site-menu__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
}
.site-menu__nav { display: grid; }
.site-menu__nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-1);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: 800 1.875rem/1.05 var(--font-display);
  font-stretch: 75%;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.site-menu__nav a[aria-current="page"] { color: var(--accent-ink); }
.site-menu__cta { width: 100%; }
.site-menu__note { color: var(--text-3); font-size: var(--step-small); text-align: center; }

/* ── Minimal chrome (Layout chrome="minimal") ──────────────────────────────────────────────────────────────── */
.site-minimal {
  display: flex;
  align-items: center;
  height: 56px;
  padding-inline: max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}

/* ── Footer ────────────────────────────────────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--text-2);
}
.site-footer__inner {
  display: grid;
  gap: var(--space-7);
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--space-8) var(--gutter) var(--space-6);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}
.site-footer__brand { display: grid; justify-items: start; align-content: start; gap: var(--space-4); }
.site-footer__tagline {
  max-width: 13ch;
  color: var(--text);
  font: 800 clamp(1.875rem, 1.3rem + 1.8vw, 2.75rem)/.95 var(--font-display);
  font-stretch: 75%;
  letter-spacing: -0.025em;
}
.site-footer__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.site-footer__cta svg { transition: transform var(--dur-2) var(--ease-out); }
.site-footer__cta:hover svg { transform: translateX(3px); }
.site-footer__nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: var(--space-6); }
.site-footer__heading {
  margin-bottom: var(--space-3);
  color: var(--text-3);
  font: 600 .75rem/1.2 var(--font-ui);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.site-footer__col ul { display: grid; gap: var(--space-2); padding: 0; list-style: none; }
.site-footer__col a { color: var(--text-2); text-decoration: none; }
.site-footer__col a:hover { color: var(--text); text-decoration: underline; }
.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--step-small);
}
.site-footer__controls { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.site-footer__button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font-size: var(--step-small);
  font-weight: 600;
}
.site-footer__button:hover { border-color: var(--text-3); color: var(--text); }
.site-calm__track {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}
.site-calm__track > span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--dur-2) var(--ease-out);
}
.site-calm[aria-pressed="true"] .site-calm__track { background: var(--success); }
.site-calm[aria-pressed="true"] .site-calm__track > span { transform: translateX(12px); background: var(--bg); }
.site-calm[aria-pressed="true"] { color: var(--text); }

@media (min-width: 860px) {
  .site-footer__inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .site-footer__base { grid-column: 1 / -1; }
}

/* ── Admin Dev page (/admin/dev; test ids use adm-, §8.10) ─────────────────────────────────────────────────── */
.site-dev__note { max-width: 72ch; color: var(--text-2); }
.adm-grid.site-dev { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.site-dev > section { display: grid; align-content: start; gap: var(--space-4); }
.site-dev__h { font-size: var(--step-h3); }
.site-dev__h--danger { margin-top: var(--space-4); color: var(--danger); }
.adm-form .site-dev__check,
.site-dev__check { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; color: var(--text); }
.site-dev__placements { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: var(--space-1) var(--space-3); }
.site-dev__totals { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }

/* ── Reduced motion, Calm mode, forced colours (§3.6) ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .site-live__dot::after { animation: none; opacity: 0; }
  .site-menu:popover-open, .site-header::after, .site-calm__track > span, .site-footer__cta svg { transition: none; }
}
:root[data-calm] .site-live__dot::after { animation: none; opacity: 0; }
:root[data-calm] .site-menu:popover-open, :root[data-calm] .site-calm__track > span { transition: none; }
@media (forced-colors: active) {
  .site-live__dot, .site-live__dot::after { background: CanvasText; }
  .site-header::before { background: Canvas; }
  .site-appearance__opts { border-color: CanvasText; }
  :root:not([data-theme]) .site-appearance__opt[data-choice="system"],
  :root[data-theme="light"] .site-appearance__opt[data-choice="light"],
  :root[data-theme="dark"] .site-appearance__opt[data-choice="dark"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
