/**
 * tokens-b.css
 * Curtana — Direction B ("Ledger") design tokens.
 *
 * Scope: every token here applies ONLY under [data-ui="b"]. Nothing in the
 * current app carries that attribute, so loading this file changes nothing
 * the app shows today. Direction B surfaces opt in by rendering inside an
 * element with data-ui="b" (or by setting it on <body>).
 *
 * Theme: dark is the default. Light mirrors the app's existing mechanism —
 * toggleTheme() in netdoc.html toggles `light` on <body> — so the light set
 * applies under body.light. Exactly like netdoc's own tokens, --ub-focus-ring
 * is declared next to every --ub-accent declaration (a custom property whose
 * value is var(...) resolves in the scope it is DECLARED in).
 *
 * Density: per user, [data-density="comfortable"] (default) or "compact" on
 * the same element as data-ui="b" or any descendant, affecting tables only. Coarse pointers
 * (tablet / field) get 44px targets regardless of density.
 *
 * Values: DESIGN.proposed.md "ledger-dark" / "ledger-light" (approved
 * 2026-10-30). Deviations, all for contrast (>= 4.5:1 text, >= 3:1 UI vs
 * --ub-surface AND --ub-surface-raised):
 *   dark  border-strong #52657A -> #60748A   (2.82:1 -> 3.52:1 on raised)
 *   light border-strong #9AA8B8 -> #7A889A   (2.42:1 -> 3.61:1 on surface)
 *   light text-muted   #5B6B80 -> #56667B
 *   light success      #0F8F63 -> #0B7A55   (4.09:1 -> 5.34:1)
 *   light warning      #A16207 -> #8A5A0B
 *   light evidence-recorded #9A6B1F -> #865C17
 *   light evidence-unknown  #6B7685 -> #5F6979
 * Discipline colours are new (not in the spec): text >= 4.5:1 on surface
 * and surface-raised in both modes.
 *
 * Fonts: IBM Plex Sans + Mono are already loaded by netdoc.html (Google
 * Fonts <link>). IBM Plex Sans Condensed is NOT loaded anywhere; the
 * condensed token falls back to Plex Sans until that load is approved.
 */

/* ── Ledger dark (default) ──────────────────────────────────────────────── */
[data-ui="b"] {
  color-scheme: dark;

  /* surfaces */
  --ub-bg: #0A0D13;
  --ub-surface: #0F141C;
  --ub-surface-raised: #161D28;
  --ub-surface-hover: #1E2835;
  /* Menu/dropdown item hover: a text-tinted wash that reads on surface AND
     surface-raised (--ub-surface-hover is ~1.05:1 on raised, i.e. invisible). */
  --ub-menu-hover: color-mix(in srgb, var(--ub-text) 11%, transparent);
  --ub-surface-selected: #16333C;
  --ub-shadow-floating: 0 8px 24px rgb(0 0 0 / .4);
  --ub-shadow-overlay: 8px 0 24px rgb(0 0 0 / .4);
  --ub-scrim: rgb(255 255 255 / .06);

  /* borders */
  --ub-border: #2A3645;
  --ub-border-strong: #60748A;

  /* text: three in use, one for disabled only */
  --ub-text: #EEF2F7;
  --ub-text-secondary: #C3CDDA;
  --ub-text-muted: #98A7B9;
  --ub-text-disabled: #6B7889;

  /* interaction */
  --ub-primary: #22D3EE;
  --ub-on-primary: #071116;
  --ub-accent: #22D3EE;
  --ub-focus-ring: var(--ub-accent);

  /* semantic */
  --ub-success: #43D6A0;
  --ub-warning: #F4BA55;
  --ub-error: #FF7B83;
  --ub-info: #22D3EE;
  --ub-unknown: #ABB5C3;
  --ub-on-danger: #1A0608;

  /* evidence (its own dimension, never device health) */
  --ub-evidence-documented: #AEC4DE;
  --ub-evidence-recorded: #E5C18A;
  --ub-evidence-unknown: #ABB5C3;

  /* disciplines / systems (type badges) */
  --ub-sys-video: #7EB6FF;
  --ub-sys-access: #C5A3FF;
  --ub-sys-network: #8FD46E;
  --ub-sys-power: #E9C75B;
  --ub-sys-fire: #FF8C6B;
  --ub-sys-other: #C3CDDA;

  --ub-brand-brass: #CD9A34;
  --ub-data-tint: 8%;
}

/* ── Ledger light (body.light — the existing theme toggle) ──────────────── */
body.light[data-ui="b"],
body.light [data-ui="b"] {
  color-scheme: light;

  --ub-bg: #F3F5F8;
  --ub-surface: #FFFFFF;
  --ub-surface-raised: #EEF2F6;
  --ub-surface-hover: #E4E9EF;
  --ub-menu-hover: color-mix(in srgb, var(--ub-text) 9%, transparent);
  --ub-surface-selected: #DCF2F6;
  --ub-shadow-floating: 0 8px 24px rgb(0 0 0 / .15);
  --ub-shadow-overlay: 8px 0 24px rgb(0 0 0 / .15);
  --ub-scrim: rgb(0 0 0 / .04);

  --ub-border: #D3DAE3;
  --ub-border-strong: #7A889A;

  --ub-text: #0B1220;
  --ub-text-secondary: #334155;
  --ub-text-muted: #56667B;
  --ub-text-disabled: #8593A5;

  --ub-primary: #0E7490;
  --ub-on-primary: #FFFFFF;
  --ub-accent: #0E7490;
  --ub-focus-ring: var(--ub-accent);

  --ub-success: #0B7A55;
  --ub-warning: #8A5A0B;
  --ub-error: #C2303F;
  --ub-info: #0E7490;
  --ub-unknown: #5F6979;
  --ub-on-danger: #FFFFFF;

  --ub-evidence-documented: #4A6A8C;
  --ub-evidence-recorded: #865C17;
  --ub-evidence-unknown: #5F6979;

  --ub-sys-video: #2458B5;
  --ub-sys-access: #7442C2;
  --ub-sys-network: #3A721C;
  --ub-sys-power: #7D5900;
  --ub-sys-fire: #AB3B1C;
  --ub-sys-other: #334155;

  --ub-brand-brass: #CD9A34;
  --ub-data-tint: 3%;
}

/* ── Mode-independent tokens ────────────────────────────────────────────── */
[data-ui="b"] {
  /* type */
  --ub-font-sans: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --ub-font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --ub-font-condensed: 'IBM Plex Sans Condensed', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --ub-fs-label: 12px;
  --ub-fs-table: 13px;
  --ub-fs-body-l: 14px;
  --ub-fs-heading: 16px;
  --ub-fs-title: 20px;
  --ub-fw-regular: 400;
  --ub-fw-medium: 500;
  --ub-fw-semibold: 600;

  /* radii: 4 controls · 6 inputs/menus · 8 panels */
  --ub-radius-sm: 4px;
  --ub-radius-md: 6px;
  --ub-radius-lg: 8px;
  --ub-radius-full: 9999px;

  /* One list-page frame: 180px rail + 18px gutter = x198 at 1440px. */
  --ub-page-pad: 18px;
  --ub-page-title-top: 18px; /* = --ub-page-pad; literal so it is not read as a colour alias */
  --ub-page-subtitle-gap: 4px;
  --ub-page-gap: 16px;

  /* spacing: 4px grid */
  --ub-space-1: 4px;
  --ub-space-2: 8px;
  --ub-space-3: 12px;
  --ub-space-4: 16px;
  --ub-space-6: 24px;
  --ub-space-8: 32px;

  /* focus */
  --ub-focus-ring-w: 2px;
  --ub-focus-ring-offset: 2px;

  /* motion: 100–150ms, ease-out in / ease-in out */
  --ub-motion-fast: 120ms;
  --ub-ease-out: cubic-bezier(.2, .8, .2, 1);

  /* density — comfortable (default) */
  --ub-row-h: 36px;
  --ub-control-h: 32px;
  --ub-cell-pad: 12px;
  --ub-fs-body: 13px;
  --ub-target-min: 24px;

  /* Trailing list columns: fixed tracks so row metadata lines up row to row
     (assignee · site · type · due · progress · actions) on every work list. */
  --ub-col-person: 136px;
  --ub-col-site: 168px;
  --ub-col-type: 120px;
  --ub-col-status: 112px;
  --ub-col-due: 156px;
  --ub-col-progress: 92px;
  --ub-col-actions: 32px;
}

[data-ui="b"][data-density="compact"] table,
[data-ui="b"] [data-density="compact"] table {
  --ub-row-h: 28px;
  --ub-control-h: 28px;
  --ub-cell-pad: 8px;
  --ub-fs-body: 12px;
}

[data-ui="b"][data-density="comfortable"] table,
[data-ui="b"] [data-density="comfortable"] table {
  --ub-row-h: 36px;
  --ub-control-h: 32px;
  --ub-cell-pad: 12px;
  --ub-fs-body: 13px;
}

/* Tablet / field: 44px targets regardless of density. */
@media (pointer: coarse) {
  [data-ui="b"],
  [data-ui="b"][data-density],
  [data-ui="b"] [data-density],
  [data-ui="b"][data-density] table,
  [data-ui="b"] [data-density] table {
    --ub-target-min: 44px;
    --ub-control-h: 44px;
    --ub-row-h: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-ui="b"] { --ub-motion-fast: 0ms; }
}
