/*
 * Q1 brand tokens — the single source for every Q1 app (root ADR 0006).
 *
 * Put both attributes on <html>, never lower down:
 *   <html data-app="go" data-theme="…">
 * The semantic tokens on :root are resolved from the app's accent at the
 * element they are declared on, so data-app on <body> would not reach them.
 *
 * data-theme: omit it to follow the device (light or dark); "light" or
 * "dark" to force one; "backstage" for the dimmed theme used at the prompt
 * desk and in the wings (darker ground, lower-glare text).
 *
 * The brief, which is what to defend if anyone wants to "clean this up":
 *   1. The black is WARM. Blue-black reads as tech and kills it.
 *   2. The paper is cream, never white.
 *   3. Anything read off a sheet (times, cue numbers, list positions, codes)
 *      is monospace.
 *   4. Red means "act now" and nothing else. Amber means "live / current".
 *      Green means "confirmed". None of them is ever decoration.
 *
 * Every text/surface pair here meets WCAG 2.2 AA (4.5:1) in every theme;
 * the table is in README.md (NF-5).
 */

@font-face { font-family: 'Public Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('./fonts/public-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('./fonts/public-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('./fonts/public-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('./fonts/public-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('./fonts/public-sans-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('./fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('./fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 400; font-display: swap; src: url('./fonts/source-serif-4-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: italic; font-weight: 400; font-display: swap; src: url('./fonts/source-serif-4-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 600; font-display: swap; src: url('./fonts/source-serif-4-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-style: normal; font-weight: 500; font-display: swap; src: url('./fonts/oswald-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-style: normal; font-weight: 600; font-display: swap; src: url('./fonts/oswald-latin-600-normal.woff2') format('woff2'); }

:root {
  /* ---- Palette: raw values. Components use the semantic tokens below. ---- */

  /* The deck: stage floor, masking, road case. */
  --q1-deck: #131110;
  --q1-deck-raise: #1f1b18;
  --q1-deck-rule: #332c27;
  --q1-deck-dust: #b8ae9e;
  /* Backstage: the deck with the work lights down. */
  --q1-wings: #0c0a09;
  --q1-wings-text: #d8d0c2;
  --q1-wings-muted: #a39a8b;
  --q1-wings-rule: #2a2420;
  /* Posted paper, and what is typed on it. */
  --q1-paper: #f2eee6;
  --q1-sheet: #fbf8f2;
  --q1-ink: #16130f;
  --q1-slate: #5e5649;
  --q1-rule: #d9d1c2;
  /* Signals. The *-fill values are for dots, pills and bars (3:1 non-text);
     never set text in them. Amber is the exception: --signal-live is only a
     background behind ink words; shapes use --signal-live-edge. Text uses the semantic --signal-*-text tokens. */
  --q1-amber: #ffb340;
  /* Amber deepened for shapes on light paper, where #ffb340 is only 1.5:1. */
  --q1-amber-edge: #b06a00;
  --q1-red-fill: #cc3b2e;
  --q1-green-fill: #3e7c59;

  /* App accents, light and dark. Keyed by the app's folder under apps/,
     never by its display name, so a rename does not touch this file. */
  --q1-go-light: #1f45c2;          /* blue pencil */
  --q1-go-dark: #9db5ff;
  --q1-callboard-light: #9a3412;   /* on paper */
  --q1-callboard-dark: #ffb340;    /* marquee amber */
  --q1-greenroom-light: #2f6b4f;
  --q1-greenroom-dark: #8fd1ae;
  --q1-house-light: #16130f;       /* Q1 itself: ink, no colour */
  --q1-house-dark: #f2eee6;

  /* ---- Type ---- */
  --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-poster: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  /* The app's display face; each [data-app] block sets it. */
  --font-display: var(--font-body);

  /* Phone-first scale. Body never goes below 16px: people read this at
     5am, backstage, on a cracked phone. */
  --text-xs: 0.75rem;    /* 12: mono labels only, uppercase, tracked */
  --text-sm: 0.875rem;   /* 14: secondary lines */
  --text-md: 1rem;       /* 16: body, inputs */
  --text-lg: 1.125rem;   /* 18: script text, list titles */
  --text-xl: 1.5rem;     /* 24: page titles */
  --text-2xl: 2rem;      /* 32: landing headlines on phones */
  --text-3xl: 2.5rem;    /* 40: landing headlines on wide screens */
  --leading-tight: 1.1;
  --leading-body: 1.5;
  --leading-script: 1.8;
  --tracking-label: 0.08em;

  /* ---- Space, shape, touch ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --radius: 6px;          /* buttons, inputs, cards */
  --radius-sheet: 4px;    /* posted paper: notices, script pages */
  --radius-pill: 999px;   /* state pills and counts only */
  --border-input: 2px;
  --border-hair: 1px;
  --target-min: 48px;     /* NF-5; 44px is the floor for icon buttons in dense bars */
  --gutter: 16px;

  /* ---- Semantic tokens: light (the default) ---- */
  --bg: var(--q1-paper);
  --surface: var(--q1-sheet);
  --chrome: var(--q1-deck);           /* the top bar is always deck */
  --chrome-text: var(--q1-paper);
  --chrome-muted: var(--q1-deck-dust);
  --chrome-rule: var(--q1-deck-rule);
  /* The bar is deck in every theme, so it always takes the app's dark accent. */
  --chrome-accent: var(--app-accent-dark);
  --on-chrome-accent: var(--app-on-dark);
  /* Focus inside the bar: --focus is the light accent on light pages, which
     is under 3:1 on deck (Q1 Go 2.4, Callboard 2.6, Q1 ink 1.0). */
  --chrome-focus: var(--app-accent-dark);
  --text: var(--q1-ink);
  --text-muted: var(--q1-slate);
  --border: var(--q1-rule);
  --border-strong: var(--q1-ink);
  --signal-act-text: #b0301f;
  --signal-act-fill: var(--q1-red-fill);
  --signal-act-bg: #fbe3de;
  --signal-live: var(--q1-amber);
  --signal-live-text: var(--q1-ink);  /* text set ON amber */
  --signal-live-edge: var(--q1-amber-edge); /* rings, dots, bars on light */
  --signal-ok-text: #326a4a;
  --signal-ok-fill: var(--q1-green-fill);
  --signal-ok-bg: #ddebe1;
  --accent: var(--app-accent-light);
  --on-accent: var(--q1-sheet);
  --focus: var(--app-accent-light);

  color-scheme: light;
}

/* Dark: follows the device unless the page forces a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: var(--q1-deck);
    --surface: var(--q1-deck-raise);
    --chrome: #0c0a09;
    --chrome-rule: var(--q1-wings-rule);
    --text: var(--q1-paper);
    --text-muted: var(--q1-deck-dust);
    --border: var(--q1-deck-rule);
    --border-strong: var(--q1-deck-dust);
    --signal-act-text: #ff8a7a;
    --signal-act-bg: #2a1210;
    --signal-live-edge: var(--q1-amber);
    --signal-ok-text: #8fd1ae;
    --signal-ok-bg: #12261b;
    --accent: var(--app-accent-dark);
    --on-accent: var(--app-on-dark);
    --focus: var(--app-accent-dark);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: var(--q1-deck);
  --surface: var(--q1-deck-raise);
  --chrome: #0c0a09;
  --chrome-rule: var(--q1-wings-rule);
  --text: var(--q1-paper);
  --text-muted: var(--q1-deck-dust);
  --border: var(--q1-deck-rule);
  --border-strong: var(--q1-deck-dust);
  --signal-act-text: #ff8a7a;
  --signal-act-bg: #2a1210;
  --signal-live-edge: var(--q1-amber);
  --signal-ok-text: #8fd1ae;
  --signal-ok-bg: #12261b;
  --accent: var(--app-accent-dark);
  --on-accent: var(--app-on-dark);
  --focus: var(--app-accent-dark);
  color-scheme: dark;
}
/* Backstage: lower glare for the prompt desk and the wings. Opt-in only;
   never chosen from the device setting. */
:root[data-theme='backstage'] {
  --bg: var(--q1-wings);
  --surface: var(--q1-deck);
  --chrome: var(--q1-deck);
  --chrome-text: var(--q1-wings-text);
  --chrome-muted: var(--q1-wings-muted);
  --chrome-rule: var(--q1-wings-rule);
  --text: var(--q1-wings-text);
  --text-muted: var(--q1-wings-muted);
  --border: var(--q1-wings-rule);
  --border-strong: var(--q1-wings-muted);
  --signal-act-text: #ff8a7a;
  --signal-act-bg: #2a1210;
  --signal-live-edge: var(--q1-amber);
  --signal-live-text: var(--q1-ink);
  --signal-ok-text: #8fd1ae;
  --signal-ok-bg: #12261b;
  --accent: var(--app-accent-dark);
  --on-accent: var(--app-on-dark);
  --focus: var(--app-accent-dark);
  color-scheme: dark;
}

/* ---- Apps ---- */
:root,
:root[data-app='q1'] {
  --app-accent-light: var(--q1-house-light);
  --app-accent-dark: var(--q1-house-dark);
  --app-on-dark: var(--q1-deck);
  --font-display: var(--font-body);
}
:root[data-app='go'] {
  --app-accent-light: var(--q1-go-light);
  --app-accent-dark: var(--q1-go-dark);
  --app-on-dark: var(--q1-deck);
  --font-display: var(--font-serif);
}
:root[data-app='callboard'] {
  --app-accent-light: var(--q1-callboard-light);
  --app-accent-dark: var(--q1-callboard-dark);
  --app-on-dark: var(--q1-ink);
  --font-display: var(--font-poster);
}
:root[data-app='greenroom'] {
  --app-accent-light: var(--q1-greenroom-light);
  --app-accent-dark: var(--q1-greenroom-dark);
  --app-on-dark: var(--q1-deck);
  --font-display: var(--font-body); /* chosen when Greenroom is built */
}
