/* theme.css - Knack's one palette and its dark mode, for every page of knackly.si (the homepage, /start, /app,
   /app/save, the legal pages, status, 404). Link it last: it holds the :root block the kit's files read.

   Light: ground #f4f6f7, surface #e7e9ea, ink #0c1114, muted #616568. Dark: ground #0c1114, surface #161b1f,
   ink #f2f4f5, muted #9ba1a5, band #05080a. Cyan #0891b2 is the brand mark and UI state (#22d3ee for the mark on a
   dark ground); orange #f2581b is only the main action and the focus ring.

   One rule everywhere: the page follows the system setting; the switch ([data-theme-toggle]) overrides it and the
   choice is remembered under one key, knack.theme (theme.js), on the homepage, /start and /app alike. */

:root {
  --p-bg: #f4f6f7; --p-surface: #e7e9ea; --p-ink: #0c1114; --p-muted: #616568;
  --p-accent: #0891b2; --p-accent-ink: #0c1114; --p-action: #f2581b; --p-action-ink: #0c1114;
  --p-inv-bg: #0c1114; --p-inv-surface: #191e21; --p-inv-ink: #f4f6f7; --p-inv-muted: #9ba1a5;
  --p-inv-accent: #0891b2; --p-inv-accent-ink: #0c1114; --p-inv-action: #f2581b; --p-inv-action-ink: #0c1114;
  --font-display: "Host Grotesk", system-ui, sans-serif;
  --font-text: "Host Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display-weight: 500;
  --display-tracking: -0.035em;
  --display-tracking-xl: -0.04em;
  --kp-mark: #0891b2;             /* Knack's cyan (the mascot's ball): on light */
  --kp-elev: #ffffff; --kp-elev-ink: #0c1114;
  --kp-bad: #a3341b;              /* an error line: never the orange, which is the main action's */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --p-bg: #0c1114; --p-surface: #161b1f; --p-ink: #f2f4f5; --p-muted: #9ba1a5;
    --p-inv-bg: #05080a; --p-inv-surface: #121719; --p-inv-ink: #f2f4f5; --p-inv-muted: #9ba1a5;
    --kp-mark: #22d3ee; --kp-elev: #161b1f; --kp-elev-ink: #f2f4f5; --kp-bad: #ff8a6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --p-bg: #0c1114; --p-surface: #161b1f; --p-ink: #f2f4f5; --p-muted: #9ba1a5;
  --p-inv-bg: #05080a; --p-inv-surface: #121719; --p-inv-ink: #f2f4f5; --p-inv-muted: #9ba1a5;
  --kp-mark: #22d3ee; --kp-elev: #161b1f; --kp-elev-ink: #f2f4f5; --kp-bad: #ff8a6b;
}
/* the system.css ground blocks read --p-*; a page without system.css (Workstation) gets the same names here */
body { background: var(--bg, var(--p-bg)); color: var(--ink, var(--p-ink)); }

/* the logo (mascot lockup): kp-logo--dark = the file for a light ground (knack-turn-lockup.svg), kp-logo--light = the
   file for a dark ground (knack-turn-lockup-dark.svg: light rim, #22d3ee ball, light word) */
.kp-logo--light { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kp-logo--dark { display: none; } :root:not([data-theme="light"]) .kp-logo--light { display: inline; } }
:root[data-theme="dark"] .kp-logo--dark { display: none; }
:root[data-theme="dark"] .kp-logo--light { display: inline; }
:root[data-theme="light"] .kp-logo--dark { display: inline; }
:root[data-theme="light"] .kp-logo--light { display: none; }
.nav--tone .kp-logo--dark { display: none !important; }
.nav--tone .kp-logo--light { display: inline !important; }

/* the hero window in dark: the dark UI on the lit painted frame */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.kw, .kv, .ui) { --fx-bg: #161b1f; --fx-surface: #0c1114; --fx-ink: #f2f4f5; --fx-muted: #a3a9ad; } }
:root[data-theme="dark"] :is(.kw, .kv, .ui) { --fx-bg: #161b1f; --fx-surface: #0c1114; --fx-ink: #f2f4f5; --fx-muted: #a3a9ad; }

/* the switch: one 44px square, the menu button's look (40px in Workstation's side panel) */
.kp-theme { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border-radius: var(--r-btn, 8px);
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink); cursor: pointer; }
.kp-theme:hover { border-color: color-mix(in oklab, var(--ink) 48%, transparent); }
.kp-theme svg { width: 18px; height: 18px; }
.kp-theme .kp-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kp-theme .kp-sun { display: block; } :root:not([data-theme="light"]) .kp-theme .kp-moon { display: none; } }
:root[data-theme="dark"] .kp-theme .kp-sun { display: block; }
:root[data-theme="dark"] .kp-theme .kp-moon { display: none; }
:root[data-theme="light"] .kp-theme .kp-sun { display: none; }
:root[data-theme="light"] .kp-theme .kp-moon { display: block; }
.nav--tone .kp-theme { color: var(--p-inv-ink); border-color: color-mix(in oklab, var(--p-inv-ink) 26%, transparent); }

/* the lit band (#questions, bg-band) in dark: the dark surface across the screen, never a pale inset slab */
html[data-mode="dark"] #questions.bg-band {
  --bg: var(--p-surface); --surface: var(--p-bg); --ink: var(--p-ink); --muted: var(--p-muted); --line: color-mix(in oklab, var(--p-ink) 11%, transparent);
  background: var(--p-surface); background-image: none; width: auto; margin: 0; border-radius: 0;
}

/* ---------------------------------------------------------------- Knack's mascot (brand/BRAND.md, locked 2026-11-06)
   Static everywhere (assets/brand/knack-turn-*.svg as <img>, the avatar tiles in knack.css / wepanel.css); it moves
   ONLY where something is in progress: the #boot loader (start, app, save) and "Knack is on it…" in a Workstation task
   chat. Those are inline SVGs (class km km--hop) so they follow the theme switch, not just the system setting.
   Colours are the drawing's own --k-* custom properties; on a dark ground the rim, ball and word change. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .km { --k-rim: #e3e8ef; --k-ball: #22d3ee; --k-word: #f2f4f5; } }
:root[data-theme="dark"] .km { --k-rim: #e3e8ef; --k-ball: #22d3ee; --k-word: #f2f4f5; }
/* Hop (1.3 s): a small hop with a squash on landing, flippers pumping, the head a beat behind, one cyan ping from the
   ball at the top. Transform and opacity only; reduced motion shows the still pose. */
.km .k-all, .km .k-head, .km .k-armL, .km .k-armR, .km .k-eyes { will-change: transform; }
.km .k-ping { transform-box: fill-box; transform-origin: center; opacity: 0; }
.km .k-eyes { transform-box: fill-box; transform-origin: center; }
.km .k-all { transform-origin: 100px 231px; }
.km .k-head { transform-origin: 100px 146px; }
.km .k-armL { transform-origin: 54px 164px; }
.km .k-armR { transform-origin: 146px 164px; }
.km--hop .k-all { animation: km-hop 1.3s cubic-bezier(.45,0,.55,1) infinite; }
.km--hop .k-head { animation: km-hop-head 1.3s cubic-bezier(.45,0,.55,1) infinite; }
.km--hop .k-armL { animation: km-hop-l 1.3s cubic-bezier(.45,0,.55,1) infinite; }
.km--hop .k-armR { animation: km-hop-r 1.3s cubic-bezier(.45,0,.55,1) infinite; }
.km--hop .k-ping { animation: km-ping 1.3s cubic-bezier(.2,.8,.2,1) infinite; }
@keyframes km-hop { 0% { transform: translateY(0) scale(1,1); } 10% { transform: translateY(0) scale(1.03,.96); }
  42% { transform: translateY(-16px) scale(.99,1.02); } 70% { transform: translateY(0) scale(1,1); }
  78% { transform: translateY(0) scale(1.025,.97); } 90%, 100% { transform: translateY(0) scale(1,1); } }
@keyframes km-hop-head { 0%, 12% { transform: rotate(0); } 46% { transform: rotate(-3deg); } 74% { transform: rotate(2deg); } 92%, 100% { transform: rotate(0); } }
@keyframes km-hop-l { 0%, 8% { transform: rotate(0); } 40% { transform: rotate(26deg); } 72%, 100% { transform: rotate(0); } }
@keyframes km-hop-r { 0%, 8% { transform: rotate(0); } 40% { transform: rotate(-26deg); } 72%, 100% { transform: rotate(0); } }
@keyframes km-ping { 0%, 32% { transform: scale(.7); opacity: 0; } 40% { transform: scale(.9); opacity: 1; } 82%, 100% { transform: scale(2.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .km * { animation: none !important; } }
.km.km--still * { animation: none !important; }
