/* =====================================================================
   STARForce theme — the one place the site's look is defined.
   Colors, fonts, the logo, shapes and motion all come from the tokens
   below; every page loads this file AFTER its own styles, so changing a
   token here restyles the whole site. Admin HQ > Branding publishes new
   values for these same tokens: js/brand.js (loaded right after this file)
   puts them in <style id="sf-brand"> and sets the effect switches on <html>.
   With nothing published the values below are what everyone sees.

   Brand colours are only ever written as tokens: var(--sf-cyan), or with
   see-through as rgba(var(--sf-cyan-rgb), .25) (the *-rgb tokens are the
   same colours as "r, g, b" numbers). Never type #4fd1ff / rgba(79,209,255,…)
   in a page: a new palette could not reach it.

   Fonts are our own copies, loaded in each page's <head> from vendor/fonts/fonts.css:
   Russo One (display), Share Tech Mono (HUD labels), Nunito (reading).
   ===================================================================== */

:root {
  /* ---- Brand tokens (the Branding panel's 10 colours, and what brand.js works out from them) ---- */
  --sf-void: #050a1a;          /* page background            (panel: "Page background") */
  --sf-deep: #0a1433;          /* background glow            (from void + panel) */
  --sf-glow-top: #13235a;      /* top of the background glow (from panel + glow) */
  --sf-panel: #0c183e;         /* cards and panels           (panel: "Cards & panels") */
  --sf-panel-2: #12214f;       /* raised / hover panels      (from panel + line) */
  --sf-line: #24366e;          /* borders and dividers       (panel: "Lines") */
  --sf-line-hi: #3a4f86;       /* stronger lines             (from line + muted) */
  --sf-line-soft: #c8d6f0;     /* pale lines and dots        (from muted + text) */
  --sf-chip-line: #3a5694;     /* chip outlines              (from line + muted) */
  --sf-cover: #0b1a44;         /* empty picture boxes        (from panel + line) */
  --sf-cyan: #4fd1ff;          /* primary glow: active, links, focus (panel: "Glow") */
  --sf-cyan-soft: rgba(79, 209, 255, .18);
  --sf-cyan-hi: #9be6ff;       /* link hover                 (glow, lighter) */
  --sf-cyan-hi-2: #8fe3ff;     /* glow button hover          (glow, lighter) */
  --sf-cyan-pale: #b8efff;     /* (glow, much lighter) */
  --sf-cyan-dark: #2fb8ea;     /* (glow, darker) */
  --sf-cyan-deep: #2aa8d8;     /* (glow, darker still) */
  --sf-gold: #ffc627;          /* STAR Points, earned, main buttons (panel: "Gold") */
  --sf-gold-soft: rgba(255, 198, 39, .18);
  --sf-gold-hi: #ffd65c;       /* gold button hover          (gold, lighter) */
  --sf-warn: #ffd76e;          /* warnings                   (gold, lighter) */
  --sf-warn-text: #ffe39a;     /* warning text               (gold, much lighter) */
  --sf-text: #eaf4ff;          /* main text                  (panel: "Text") */
  --sf-text-2: #c2d2ef;        /* secondary text             (from text + muted) */
  --sf-muted: #a9bbdd;         /* quiet labels               (panel: "Quiet text") */
  --sf-good: #3ccf7f;          /* complete, correct          (panel: "Success") */
  --sf-good-deep: #062b16;     /* dark green                 (from good + void) */
  --sf-bad: #ff5a6e;           /* locked and errors ONLY     (panel: "Errors & locked") */
  --sf-bad-text: #ff8a99;      /* error text                 (bad, lighter) */
  --sf-bad-hi: #ff7a8a;        /* red button hover           (bad, lighter) */
  --sf-purple: #7b4a96;        /* teacher accents            (panel: "Teacher accent") */
  --sf-ink: #0b1440;           /* dark text on gold/cyan     (from void + panel) */
  /* The same colours as "r, g, b" for see-through use: rgba(var(--sf-cyan-rgb), .25) */
  --sf-void-rgb: 5, 10, 26;
  --sf-deep-rgb: 10, 20, 51;
  --sf-panel-rgb: 12, 24, 62;
  --sf-panel-2-rgb: 18, 33, 79;
  --sf-line-rgb: 36, 54, 110;
  --sf-line-hi-rgb: 58, 79, 134;
  --sf-cyan-rgb: 79, 209, 255;
  --sf-sweep-hi-rgb: 170, 236, 255;
  --sf-gold-rgb: 255, 198, 39;
  --sf-text-rgb: 234, 244, 255;
  --sf-muted-rgb: 169, 187, 221;
  --sf-good-rgb: 60, 207, 127;
  --sf-bad-rgb: 255, 90, 110;
  --sf-purple-rgb: 123, 74, 150;
  --sf-ink-rgb: 11, 20, 64;

  --sf-font-display: "Russo One", "Arial Black", system-ui, sans-serif;
  --sf-font-hud: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  /* Agent and family codes: every letter and number looks different (S/5, B/8, Z/2, O/0). */
  --sf-font-code: "Atkinson Hyperlegible Mono", ui-monospace, Menlo, Consolas, monospace;
  --sf-font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sf-logo: url("../assets/logo.webp");
  --sf-cut: 14px;              /* clipped-corner size on panels (Branding "corners": cut 14 / soft 6 / square 0) */
  --sf-cut-btn: 10px;          /* clipped-corner size on buttons (cut 10 / soft 4 / square 0) */
  --sf-cut-k: 1;               /* other clipped corners in pages: calc(18px * var(--sf-cut-k, 1)) (cut 1 / soft .4 / square 0) */
  --sf-grid: 40px;             /* background grid spacing */

  /* ---- Older names the pages already use, mapped onto the tokens ---- */
  --navy: var(--sf-void);
  --navy-2: var(--sf-panel-2);
  --gold: var(--sf-gold);
  --purple: var(--sf-cyan);
  --purple-dark: var(--sf-cyan-dark);
  --bg: var(--sf-void);
  --card: var(--sf-panel);
  --text: var(--sf-text);
  --muted: var(--sf-muted);
  --line: var(--sf-line);
  --good: var(--sf-good);
  --bad: var(--sf-bad);
  --warn: var(--sf-warn);
  color-scheme: dark;
}

/* ---------- Page ---------- */
html { background: var(--sf-void); }
body {
  background:
    linear-gradient(rgba(var(--sf-cyan-rgb), .05) 1px, transparent 1px) 0 0 / var(--sf-grid) var(--sf-grid),
    linear-gradient(90deg, rgba(var(--sf-cyan-rgb), .05) 1px, transparent 1px) 0 0 / var(--sf-grid) var(--sf-grid),
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--sf-glow-top) 0%, var(--sf-deep) 45%, var(--sf-void) 100%) fixed;
  background-color: var(--sf-void);
  color: var(--sf-text);
  font-family: var(--sf-font-body);
}
/* Scan lines over everything (drawn by the page itself, never blocks clicks). */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0, rgba(255, 255, 255, .025) 1px, transparent 1px, transparent 4px);
}
a { color: var(--sf-cyan); }
a:hover { color: var(--sf-cyan-hi); }
h1, h2, h3 { font-family: var(--sf-font-display); font-weight: 400; letter-spacing: 1px; color: var(--sf-text); }
::selection { background: var(--sf-cyan); color: var(--sf-ink); }

/* ---------- Header ---------- */
header {
  background: rgba(var(--sf-void-rgb), .82) !important;
  border-bottom: 1px solid rgba(var(--sf-cyan-rgb), .25);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sf-logo { display: block; height: 52px; width: auto; }
.sf-logo.big { height: auto; width: min(440px, 80vw); margin: 0 auto; filter: drop-shadow(0 0 24px rgba(var(--sf-cyan-rgb), .25)); }
.sf-hud {
  font-family: var(--sf-font-hud); font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--sf-cyan);
}
.sf-hud.gold { color: var(--sf-gold); }
.sf-hud.cyan { color: var(--sf-cyan); }
.sf-hud.quiet { color: var(--sf-muted); }

/* ---------- Panels ---------- */
.card, .sf-panel {
  background: rgba(var(--sf-panel-rgb), .86) !important;
  border: 1px solid rgba(var(--sf-cyan-rgb), .22) !important;
  border-radius: 0 !important;
  clip-path: polygon(var(--sf-cut) 0, 100% 0, 100% calc(100% - var(--sf-cut)), calc(100% - var(--sf-cut)) 100%, 0 100%, 0 var(--sf-cut));
  color: var(--sf-text);
}
.sf-brackets {
  --c: var(--sf-cyan);
  background:
    linear-gradient(var(--c), var(--c)) top left / 18px 2px no-repeat, linear-gradient(var(--c), var(--c)) top left / 2px 18px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 18px 2px no-repeat, linear-gradient(var(--c), var(--c)) top right / 2px 18px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 18px 2px no-repeat, linear-gradient(var(--c), var(--c)) bottom left / 2px 18px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 18px 2px no-repeat, linear-gradient(var(--c), var(--c)) bottom right / 2px 18px no-repeat;
}
.sf-section-title {
  display: flex; align-items: center; gap: 14px; margin: 22px 0 12px;
  font-family: var(--sf-font-hud); font-size: 15px; letter-spacing: 4px; text-transform: uppercase; color: var(--sf-gold);
}
.sf-section-title::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .35; }
.sf-section-title.cyan { color: var(--sf-cyan); }

/* ---------- Buttons ---------- */
button {
  font-family: var(--sf-font-display); letter-spacing: 1px;
  background: var(--sf-gold); color: var(--sf-ink); border: 0 !important; border-radius: 0 !important;
  clip-path: polygon(var(--sf-cut-btn) 0, 100% 0, 100% calc(100% - var(--sf-cut-btn)), calc(100% - var(--sf-cut-btn)) 100%, 0 100%, 0 var(--sf-cut-btn));
}
button:hover { background: var(--sf-gold-hi); color: var(--sf-ink); }
button:focus-visible { outline: 3px solid var(--sf-cyan); outline-offset: 2px; }
button.ghost {
  background: transparent; color: var(--sf-cyan); clip-path: none;
  box-shadow: inset 0 0 0 1px rgba(var(--sf-cyan-rgb), .6);
}
button.ghost:hover { background: var(--sf-cyan-soft); color: var(--sf-text); }
button.link {
  background: none; color: var(--sf-cyan); clip-path: none; font-family: var(--sf-font-body); font-weight: 800; letter-spacing: 0;
}
button.link:hover { background: none; color: var(--sf-cyan-hi); text-decoration: underline; }
button.danger, button.link.danger { color: var(--sf-bad); }
button.chip {
  background: transparent; color: var(--sf-gold); clip-path: none; box-shadow: inset 0 0 0 1px var(--sf-gold); font-family: var(--sf-font-hud);
}
button.chip:hover { background: var(--sf-gold-soft); }
button.chip.on { background: var(--sf-gold); color: var(--sf-ink); }
button.cyan { background: var(--sf-cyan); color: var(--sf-void); box-shadow: 0 0 20px rgba(var(--sf-cyan-rgb), .45); }
button.cyan:hover { background: var(--sf-cyan-hi-2); }
button:disabled { opacity: .45; cursor: default; }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
  background: rgba(var(--sf-void-rgb), .75) !important; color: var(--sf-text) !important;
  border: 1px solid rgba(var(--sf-cyan-rgb), .45) !important; border-radius: 0 !important;
  font-family: var(--sf-font-body);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sf-cyan) !important; box-shadow: 0 0 0 2px rgba(var(--sf-cyan-rgb), .6), 0 0 18px rgba(var(--sf-cyan-rgb), .25); }
input::placeholder, textarea::placeholder { color: rgba(var(--sf-muted-rgb), .6); }
label { color: var(--sf-text-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--sf-cyan); }
input[type=range] { accent-color: var(--sf-gold); }

/* ---------- Text helpers ---------- */
.muted { color: var(--sf-muted) !important; }
.error { color: var(--sf-bad-text) !important; }
.ok-msg, .bp-ok { color: var(--sf-good) !important; }

/* ---------- Tables ---------- */
table th { font-family: var(--sf-font-hud); font-weight: 400; letter-spacing: 2px; color: var(--sf-cyan) !important; border-bottom-color: rgba(var(--sf-cyan-rgb), .3) !important; }
table td { border-bottom-color: rgba(var(--sf-cyan-rgb), .14) !important; }
tr.sel { background: rgba(var(--sf-cyan-rgb), .1) !important; }
td.code { font-family: var(--sf-font-hud); color: var(--sf-gold); }

/* ---------- Tags ---------- */
.tag { font-family: var(--sf-font-hud); letter-spacing: 1px; border-radius: 0 !important; }
.tag.on { background: rgba(var(--sf-good-rgb), .16) !important; color: var(--sf-good) !important; }
.tag.off { background: rgba(var(--sf-muted-rgb), .12) !important; color: var(--sf-muted) !important; }
.tag.inv { background: var(--sf-gold-soft) !important; color: var(--sf-gold) !important; }
.tag.dis { background: rgba(var(--sf-bad-rgb), .15) !important; color: var(--sf-bad-text) !important; }
.tag.adm { background: var(--sf-cyan-soft) !important; color: var(--sf-cyan) !important; }

/* ---------- Warnings / notes ---------- */
.warn { background: rgba(var(--sf-gold-rgb), .1) !important; border: 1px solid rgba(var(--sf-gold-rgb), .45) !important; color: var(--sf-warn-text) !important; border-radius: 0 !important; }

/* ---------- Dialogs and toasts ---------- */
dialog {
  background: var(--sf-panel) !important; color: var(--sf-text) !important;
  border: 1px solid rgba(var(--sf-cyan-rgb), .45) !important; border-radius: 0 !important;
  box-shadow: 0 0 0 1px rgba(var(--sf-cyan-rgb), .2), 0 20px 60px rgba(0, 0, 0, .6) !important;
}
dialog::backdrop { background: rgba(var(--sf-void-rgb), .75) !important; }
#toast {
  background: var(--sf-panel-2) !important; color: var(--sf-text) !important; border: 1px solid var(--sf-cyan);
  border-radius: 0 !important; font-weight: 700; box-shadow: 0 0 24px rgba(var(--sf-cyan-rgb), .35) !important;
}

/* ---------- Gauges ---------- */
.sf-ring { display: block; }
.sf-ring .track { stroke: var(--sf-cyan-soft); }
.sf-ring .val { stroke: var(--sf-cyan); transition: stroke-dasharray .9s ease-out; }
.sf-ring.gold .track { stroke: var(--sf-gold-soft); }
.sf-ring.gold .val { stroke: var(--sf-gold); }
.sf-ring.good .val { stroke: var(--sf-good); }

/* ---------- Motion ---------- */
@keyframes sf-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes sf-pulse { 0%, 100% { box-shadow: 0 0 14px rgba(var(--sf-cyan-rgb), .25); } 50% { box-shadow: 0 0 38px rgba(var(--sf-cyan-rgb), .65); } }
@keyframes sf-sweep { from { transform: translateY(-20vh); } to { transform: translateY(120vh); } }
@keyframes sf-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sf-granted { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
.sf-blink { animation: sf-blink 1.8s ease-in-out infinite; }
.sf-pulse { animation: sf-pulse 2.4s ease-in-out infinite; }
.sf-in { animation: sf-in .45s ease-out both; }
/* The scanning band that glides down the screen. */
.sf-sweep { position: fixed; left: 0; right: 0; top: 0; height: 18vh; pointer-events: none; z-index: 9998;
  background: linear-gradient(180deg, transparent 0%, rgba(var(--sf-cyan-rgb), .04) 70%, rgba(var(--sf-cyan-rgb), .14) 96%, rgba(var(--sf-sweep-hi-rgb), .45) 99.5%, transparent 100%);
  animation: sf-sweep 9s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sf-sweep { display: none; }
}

/* ---------- Effect switches (Admin HQ > Branding; js/brand.js sets these classes on <html>) ----------
   Off by default: with nothing published none of these classes exist. A device's own "reduce motion" always wins. */
html.sf-no-scan body::after { display: none; }
html.sf-no-grid body {
  background: radial-gradient(ellipse 80% 60% at 50% 0%, var(--sf-glow-top) 0%, var(--sf-deep) 45%, var(--sf-void) 100%) fixed;
  background-color: var(--sf-void);
}
html.sf-no-sweep .sf-sweep { display: none; }
html.sf-corners-soft { --sf-cut: 6px; --sf-cut-btn: 4px; --sf-cut-k: .4; }
html.sf-corners-square { --sf-cut: 0px; --sf-cut-btn: 0px; --sf-cut-k: 0; }
/* calm: nothing loops (one-off entrances and transitions stay) */
html.sf-motion-calm *, html.sf-motion-calm *::before, html.sf-motion-calm *::after { animation-iteration-count: 1 !important; }
html.sf-motion-calm .sf-sweep { display: none; }
/* off: like the device's reduce-motion setting */
html.sf-motion-off *, html.sf-motion-off *::before, html.sf-motion-off *::after { animation: none !important; transition: none !important; }
html.sf-motion-off .sf-sweep { display: none; }

/* ---------- Accessibility ----------
   A keyboard focus ring on everything you can Tab to, a "Skip to main content" link (first Tab on the HQ pages:
   <a class="sf-skip" href="#main">), and .sr-only for words only screen readers hear. */
a:focus-visible, summary:focus-visible, [tabindex]:focus-visible, [role="button"]:focus-visible,
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible, input[type=range]:focus-visible { outline: 3px solid var(--sf-cyan); outline-offset: 2px; }
main:focus, [tabindex="-1"]:focus { outline: none; }
.sf-skip { position: absolute; left: 12px; top: -80px; z-index: 10000; padding: 12px 18px; background: var(--sf-gold); color: var(--sf-ink);
  font-family: var(--sf-font-display); letter-spacing: 1px; text-decoration: none; }
.sf-skip:focus { top: 12px; color: var(--sf-ink); outline: 3px solid var(--sf-cyan); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- Print: paper stays white ---------- */
@media print {
  :root { color-scheme: light; }
  html, body { background: #fff !important; color: #000 !important; }
  body::after, .sf-sweep { display: none !important; }
}

/* While a lesson is playing full screen, keep slides clean. */
body:has(.lp)::after, body:has(.lp) .sf-sweep { display: none; }
.lp button { clip-path: none; }

/* ---------- Big section tabs (Teacher HQ, Admin) ----------
   <nav class="hq-tabs" style="--tabs:5"><button class="hq-tab on" data-tab="x"><i>icon</i><b>Name</b><span>What it's for</span></button>... */
.hq-tabs { display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr); gap: 10px; margin: 0 0 16px; }
button.hq-tab { clip-path: none; background: rgba(var(--sf-void-rgb), .55); color: var(--sf-text); box-shadow: inset 0 0 0 1px rgba(var(--sf-cyan-rgb), .35);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; text-align: center; letter-spacing: 0; text-transform: none; border-radius: 6px; }
button.hq-tab:hover { background: rgba(var(--sf-cyan-rgb), .12); color: var(--sf-text); }
button.hq-tab i { font-style: normal; font-size: 26px; line-height: 1.1; }
button.hq-tab b { font-family: var(--sf-font-display); font-weight: 400; font-size: 18px; letter-spacing: 1px; }
button.hq-tab span { font-family: var(--sf-font-body); font-size: 13px; font-weight: 600; opacity: .75; line-height: 1.2; }
button.hq-tab.on { background: var(--sf-gold); color: var(--sf-ink); box-shadow: 0 0 18px rgba(var(--sf-gold-rgb), .35); }
button.hq-tab.on span { opacity: .85; }
.tab-empty { display: none; }
.card.hidden + .tab-empty { display: block; }
@media (max-width: 760px) {
  .hq-tabs { grid-template-columns: repeat(var(--tabs-sm, 3), 1fr); gap: 8px; }
  button.hq-tab { padding: 10px 6px; }
  button.hq-tab span { display: none; }
}

/* ---------- HQ switcher: the header logo + title drop down a menu of HQs (js/hq-switch.js) ---------- */
.hq-switch { position: relative; }
button.hq-btn { display: flex; align-items: center; gap: 12px; background: none; clip-path: none; box-shadow: none; padding: 4px 8px 4px 0; margin: 0;
  color: inherit; text-align: left; letter-spacing: normal; text-transform: none; font: inherit; border-radius: 6px; }
button.hq-btn:hover, .hq-switch.open button.hq-btn { background: rgba(var(--sf-cyan-rgb), .08); color: inherit; }
.hq-caret { display: inline-flex; vertical-align: middle; margin-left: 8px; color: var(--sf-cyan); transition: transform .15s; }
.hq-switch.open .hq-caret { transform: rotate(180deg); }
.hq-menu { display: none; position: absolute; left: 0; top: calc(100% + 8px); z-index: 50; width: min(330px, calc(100vw - 32px)); padding: 6px;
  background: var(--sf-deep); border: 1px solid rgba(var(--sf-cyan-rgb), .45); border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.55), 0 0 24px rgba(var(--sf-cyan-rgb), .12); }
.hq-switch.open .hq-menu { display: block; }
header .hq-menu a.hq-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: var(--sf-text); text-decoration: none;
  font-family: var(--sf-font-body); font-size: 15px; letter-spacing: 0; opacity: 1; }
header .hq-menu a.hq-item:hover, header .hq-menu a.hq-item:focus-visible { background: rgba(var(--sf-cyan-rgb), .14); outline: none; }
.hq-item i { font-style: normal; font-size: 24px; width: 32px; text-align: center; }
.hq-item b { display: block; font-family: var(--sf-font-display); font-weight: 400; font-size: 17px; letter-spacing: 1px; }
.hq-item b small { font-size: 12px; color: var(--sf-cyan); }
.hq-item em { display: block; font-style: normal; font-size: 13px; opacity: .75; }
header .hq-menu a.hq-item.here { background: rgba(var(--sf-gold-rgb), .16); box-shadow: inset 3px 0 0 var(--sf-gold); }
.hq-item.here b, .hq-item.here em { color: var(--sf-gold); opacity: 1; }
