/* site.css: the tokens, base rules, shared components and top bar of the six pages
   (website redesign phase 1, 2026-11-15; paper/WEB_REDESIGN_BRIEF.md).
   Every page links it right after the soft password gate, before its own <style>, which holds the page's
   layout and anything page-specific. Base element rules use :where() (zero specificity), so a page rule
   always wins over them.
   Colour means data: hue is reserved for the components (--cmb, --tsz, --cib, --ksz, --tot). Selection,
   links, slider fills and meters are neutral; the focus ring is gold. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;
  /* surfaces */
  --bg: #0a0e1a;
  --bg-deep: #04060c;            /* map and 3D viewports only, not the chrome */
  --surface-1: #11162a;
  --surface-2: #161c34;
  --surface-3: #1e2542;
  --border: #2a3356;             /* panel edges and separators (decoration) */
  --border-strong: #5b6796;      /* control boundaries: >= 3:1 on bg, surface-1 and surface-2 (WCAG 1.4.11) */
  /* text: contrast on bg / surface-1 / surface-2 / surface-3 */
  --text: #eef1f8;               /* headings, values, current page: 17.0 / 15.9 / 14.9 / 13.3 */
  --text-2: #c3c9dc;             /* body text and controls: 11.7 / 10.8 / 10.2 / 9.1 */
  --muted: #8a93b4;              /* notes, caps labels, axis ticks: 6.3 / 5.9 / 5.5 / 4.9 (AA for small text) */
  --faint: #4a5580;              /* non-text decoration only */
  /* state */
  --select-bg: #e8ecf4;          /* a selected segment, toggle or band: 16.3:1 with --select-fg */
  --select-fg: #0a0e1a;
  --focus: #ffd58a;              /* 2px ring, 2px offset */
  --danger: #ff5c5c;
  --warn: #ffc857;
  --artistic: #ffc58a;           /* the 'artistic' / 'decorative' labels */
  --artistic-line: #8f6233;
  /* data: the component colours (the same in the plots, the chips, the sky views and How it works) */
  --cmb: #4a9eff;
  --tsz: #ff9f43;
  --cib: #2ed573;
  --ksz: #ff6fb7;
  --tot: #c9ced9;                /* dashed in plots */
  /* type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-12: 12px;                 /* the smallest anywhere: badges, caps labels */
  --fs-13: 13px;                 /* controls, notes */
  --fs-14: 14px;                 /* readouts, card text */
  --fs-16: 16px;                 /* prose */
  --fs-20: 20px;                 /* section heads */
  --fs-24: 24px;                 /* app page titles */
  --fs-40: 40px;                 /* hub hero */
  --lh-prose: 1.5;
  --lh-ui: 1.35;
  /* space and shape */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --topbar-h: 48px;
  --content-max: 1200px;         /* the centred pages (the hub, the Sonifier): one container width, so titles line up */
  --halo: #ffd58a;               /* the cluster markers (rings, dots, glows) and the cluster readout */
  accent-color: var(--select-bg);   /* range sliders and checkboxes: neutral */
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text-2);
  font-family: var(--font-sans); font-size: var(--fs-16); line-height: var(--lh-ui);
}
button, input, select, textarea { font: inherit; color: inherit; }
:where(button) { cursor: pointer; }
:where(h1, h2, h3, h4) { color: var(--text); font-weight: 600; line-height: 1.25; }
:where(a) {
  color: var(--text); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 2px; text-decoration-color: rgba(238, 241, 248, 0.45);
}
:where(a):hover { text-decoration-color: currentColor; }
:where(select, input[type="number"], input[type="text"], textarea) {
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 3px 6px;
}
:where(code, pre, kbd) { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.tnum, .readout { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ components */
/* .btn: a plain button. Selected (a toggle or one of a set): aria-pressed="true" (or .active, which the
   page scripts keep in step with aria-pressed). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  padding: 3px 10px; min-height: 26px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); font-size: var(--fs-13); line-height: var(--lh-ui);
  white-space: nowrap; transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn.active, .btn[aria-pressed="true"] { background: var(--select-bg); color: var(--select-fg); border-color: var(--select-bg); }
.btn.active:hover, .btn[aria-pressed="true"]:hover { background: #fff; border-color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
/* the one primary action of a page or panel (e.g. Play) */
.btn--primary { background: var(--select-bg); color: var(--select-fg); border-color: var(--select-bg); font-weight: 600; }
.btn--primary:hover { background: #fff; border-color: #fff; color: var(--select-fg); }

/* .seg: a segmented group of .btn (one choice of several); the selected one has aria-pressed="true" */
.seg { display: inline-flex; isolation: isolate; }
.seg > .btn { border-radius: 0; }
.seg > .btn + .btn { margin-left: -1px; }
.seg > .btn:first-child { border-top-left-radius: var(--r-sm); border-bottom-left-radius: var(--r-sm); }
.seg > .btn:last-child { border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm); }
.seg > .btn.active, .seg > .btn[aria-pressed="true"], .seg > .btn:focus-visible { z-index: 1; }

/* .chip[data-comp]: a component toggle, outlined in its data colour; on = filled in it */
.chip {
  --chip-c: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  padding: 2px 12px; min-height: 26px; border: 2px solid var(--chip-c); border-radius: var(--r-pill);
  background: transparent; color: var(--text-2); font-size: var(--fs-13); font-weight: 500; line-height: var(--lh-ui);
  white-space: nowrap; transition: background-color .15s, color .15s;
}
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip[data-comp="dT_cmblens"] { --chip-c: var(--cmb); }
.chip[data-comp="dT_tsz"] { --chip-c: var(--tsz); }
.chip[data-comp="dT_cib"] { --chip-c: var(--cib); }
.chip[data-comp="dT_ksz"] { --chip-c: var(--ksz); }
.chip[data-comp="T_tot"] { --chip-c: var(--tot); }
.chip.active, .chip[aria-pressed="true"] { background: var(--chip-c); color: var(--select-fg); }
.chip.active:hover, .chip[aria-pressed="true"]:hover { background: var(--chip-c); filter: brightness(1.08); }

/* .badge: a short label beside a control; .badge--artistic marks decorative (artistic) features */
.badge {
  display: inline-block; font-size: var(--fs-12); font-weight: 500; line-height: var(--lh-ui);
  padding: 0 6px; border: 1px solid var(--border-strong); border-radius: var(--r-pill); color: var(--text-2);
  text-transform: none; letter-spacing: 0; white-space: nowrap; vertical-align: 1px;
}
.badge--artistic { color: var(--artistic); border-color: var(--artistic-line); }

/* .panel: a surface holding a group of controls or a plot; .group: a labelled set of controls inside one */
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); min-width: 0; }
.group { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.group-label { font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* .note: secondary text under a control */
.note { font-size: var(--fs-13); line-height: var(--lh-prose); color: var(--muted); }

/* .page-title: the h1 of an app page (Power Spectrum Sonifier, the three sky views, How it works): one size and weight
   on every page, 24 px, and 20 px on phones; the hub's hero title is the one larger heading (40 px) */
.page-title { font-size: var(--fs-24); font-weight: 600; line-height: 1.25; color: var(--text); letter-spacing: 0; }
@media (max-width: 720px) { .page-title { font-size: var(--fs-20); } }

/* .cue-ring: the control a deep link asks the visitor to press next (the hub's demo links open a page ready, never
   playing, since browsers allow sound only after a gesture). A light ring outside a dark gap with a soft pulse, so it
   reads on a white (primary) or an outlined button and is never mistaken for the gold focus ring; still under reduced
   motion; an outline in forced colours (which drop box shadows). The page removes the class once it is pressed. */
.cue-ring { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); animation: cue-pulse 1.8s ease-in-out infinite; }
@keyframes cue-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text), 0 0 0 4px rgba(238, 241, 248, .5); }
  60% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text), 0 0 0 11px rgba(238, 241, 248, 0); }
}

/* .skip-link: the first Tab stop of a page, shown while focused ('Skip to Play', 'Skip to content', 'Skip to the map') */
.skip-link {
  position: absolute; left: 16px; top: 0; z-index: 60; transform: translateY(-140%);
  padding: 6px 12px; border-radius: var(--r-sm); background: var(--select-bg); color: var(--select-fg);
  font-size: var(--fs-14); font-weight: 600; text-decoration: none;
}
.skip-link:focus { transform: translateY(8px); }

/* The observing band: one component on the Sonifier, the Sky Explorer and the Globe. The label 'Band (GHz)' ('GHz' on
   phones, where the group keeps its full name for screen readers), then one segmented pair per survey with its name
   ('SO MF', 'Planck', 'SO HF': sonify_core.js BAND_GROUPS) before it, as a caption under it on phones. The selected band
   is a secondary selection (surface-3 with a light outline): solid white stays for the primary action and the selected
   segment of a setting. .freq-btn is a JS hook (data-freq on the Sonifier, data-band on the sky views). */
.band-label { font-size: var(--fs-13); color: var(--muted); white-space: nowrap; }
.band-unit { display: none; font-size: var(--fs-13); color: var(--muted); white-space: nowrap; }
.freq-group { display: inline-flex; align-items: center; isolation: isolate; }
.freq-group-label { margin-right: 5px; font-size: var(--fs-12); font-weight: 600; color: var(--muted); white-space: nowrap; }
.freq-group .freq-btn { min-width: 40px; padding: 3px 8px; border-radius: 0; }
.freq-group .freq-btn + .freq-btn { margin-left: -1px; }
.freq-group .freq-btn:first-of-type { border-top-left-radius: var(--r-sm); border-bottom-left-radius: var(--r-sm); }
.freq-group .freq-btn:last-child { border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm); }
.freq-btn.active, .freq-btn[aria-pressed="true"], .freq-btn.active:hover, .freq-btn[aria-pressed="true"]:hover {
  background: var(--surface-3); color: var(--text); border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text);
}
.freq-group .freq-btn.active, .freq-group .freq-btn[aria-pressed="true"], .freq-group .freq-btn:focus-visible,
.freq-group .freq-btn.cue-ring { z-index: 1; }
@media (max-width: 720px) {
  .band-label { display: none; }
  .band-unit { display: inline; }
  .freq-group { display: inline-grid; grid-auto-flow: column; grid-template-rows: auto auto; align-items: start; }
  .freq-group-label { grid-row: 2; grid-column: 1 / span 2; margin: 2px 0 0; text-align: center; letter-spacing: .02em; }
}

/* details.help: an info toggle holding a formula or a longer explanation */
details.help { font-size: var(--fs-13); line-height: var(--lh-prose); color: var(--muted); }
details.help > summary { cursor: pointer; color: var(--text-2); width: fit-content; }
details.help > summary:hover { color: var(--text); }
details.help[open] > summary { margin-bottom: var(--sp-1); }

/* ------------------------------------------------------------------ top bar
   The same markup on all six pages; aria-current="page" marks the current page (the wordmark on the hub).
   Desktop: one 48px row (wordmark, page links, page actions). Phones: the wordmark and actions on one row,
   the links on a second row that scrolls sideways if it must; the page itself never scrolls sideways. */
.topbar {
  flex: none; position: relative; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2) var(--sp-4);
  min-height: var(--topbar-h); padding: 0 var(--sp-4);
  background: var(--bg); border-bottom: 1px solid var(--border);
  line-height: var(--lh-ui);
}
.topbar__brand {
  flex: none; font-size: var(--fs-14); font-weight: 600; color: var(--text); text-decoration: none;
  white-space: nowrap; letter-spacing: .01em; padding-block: 3px;   /* a 24 px target (WCAG 2.5.8) */
}
.topbar__brand:hover { color: #fff; }
.topbar__nav {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: thin; padding: 4px; margin: 0 -4px;
}
.topbar__nav a {
  flex: none; font-size: var(--fs-14); font-weight: 500; color: var(--text-2); text-decoration: none;
  padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap;
}
.topbar__nav a:hover { color: var(--text); background: var(--surface-2); }
.topbar__nav a[aria-current="page"] {
  color: var(--text); text-decoration: underline; text-decoration-color: var(--text);
  text-decoration-thickness: 2px; text-underline-offset: 6px;
}
.topbar__actions { flex: none; display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.topbar__actions:empty { display: none; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; min-height: 0; padding: 6px var(--sp-4) 2px; row-gap: 0; }
  .topbar__brand { line-height: 30px; }
  .topbar__nav {
    order: 3; flex: 0 0 calc(100% + 8px); gap: 0;
    /* scroll hints (no script): a soft edge shows on the side that has more links */
    background:
      linear-gradient(90deg, var(--bg) 40%, rgba(10, 14, 26, 0)) left center / 20px 100% no-repeat local,
      linear-gradient(270deg, var(--bg) 40%, rgba(10, 14, 26, 0)) right center / 20px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(195, 201, 220, .35), rgba(195, 201, 220, 0)) left center / 8px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(195, 201, 220, .35), rgba(195, 201, 220, 0)) right center / 8px 100% no-repeat scroll;
  }
  .topbar__nav a { font-size: var(--fs-13); padding: 5px; }
}
@media (max-width: 420px) {
  .topbar__brand-pre { display: none; }   /* 'Multi-Probe Sky' */
}
@media (max-width: 360px) {
  /* the smallest phones: the links wrap, so the current page is never scrolled out of sight */
  .topbar__nav { flex-wrap: wrap; overflow-x: visible; background: none; }
}

/* ------------------------------------------------------------------ preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
@media (forced-colors: active) {
  /* backgrounds are dropped in forced colours: keep the pressed and current states visible */
  button.active, button[aria-pressed="true"], [role="tab"][aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .cue-ring { outline: 3px solid Highlight; outline-offset: 3px; }
}
@media print {
  .topbar { display: none; }
}
