/* Onyx design tokens — docs/DESIGN.md §5, §6.
   Plain CSS with no Tailwind dependency: the Tailwind build and the Blazor-free
   player both read this file. It is the ONLY file in the repo allowed to hold a
   raw hex value. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  /* The onyx ramp — the palette, not the semantics. Components never use these
     directly; they use the semantic tokens below. */
  --onyx-0:   #FFFFFF;
  --onyx-25:  #FAFAFA;
  --onyx-50:  #F4F4F5;
  --onyx-100: #E9E9EB;
  --onyx-200: #E4E4E7;
  --onyx-300: #D4D4D8;
  --onyx-400: #A1A1AA;
  --onyx-500: #71717A;
  --onyx-600: #52525B;
  --onyx-700: #3F3F46;
  --onyx-800: #27272A;
  --onyx-900: #18181B;
  --onyx-950: #09090B;

  /* Surfaces — three levels, never four. */
  --surface-page:   var(--onyx-25);
  --surface-panel:  var(--onyx-0);
  --surface-raised: var(--onyx-0);
  --surface-sunken: var(--onyx-100);
  /* A header strip over a card (collection category heads): grey like a table head; a step up from the card in dark. */
  --surface-header: var(--surface-sunken);
  /* A hovered row under such a strip: a step lighter than it in light, so the two never read as one block. */
  --surface-row-hover: var(--onyx-50);

  /* Ink */
  --ink:         var(--onyx-900);
  --ink-muted:   var(--onyx-500);
  --ink-subtle:  var(--onyx-400);   /* placeholders and disabled only */
  --ink-inverse: var(--onyx-0);

  /* Edges */
  --edge:        var(--onyx-200);
  --edge-strong: var(--onyx-300);

  /* Action — onyx, not accent. Primary buttons are grey on purpose. */
  --action:       var(--onyx-700);
  --action-hover: var(--onyx-800);
  --action-ink:   var(--onyx-0);

  /* Accent — a pointer, never a fill. Selection, focus, links. */
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-tint:  #EFF6FF;

  /* Status — always paired with an icon or text, never hue alone. */
  --danger:  #DC2626;
  --warn:    #B45309;
  --success: #15803D;
  --on-danger: #FFFFFF;   /* white on a danger fill, in either theme */
  /* Lead statuses: the Leads tab dots, the status menu, the demo card bar. */
  --lead-new: var(--ink-subtle);
  --lead-contacted: var(--accent);
  --lead-followup: var(--warn);
  --lead-interested: var(--ws-violet);
  --lead-won: var(--success);
  --lead-lost: color-mix(in srgb, var(--danger) 55%, var(--surface-panel));
  /* The leads drawer sits above the sticky table header (z 2) and below modals (80). */
  --z-drawer-scrim: 40;
  --z-drawer: 41;
  /* Notifications: severity accents. Aliases, so the dark blocks' --danger/--warn/--accent carry them. */
  --ntf-action:  var(--danger);
  --ntf-warning: var(--warn);
  --ntf-info:    var(--accent);

  /* Fixed, theme-independent: these sit on or beside captured content, so they
     must read the same in both themes. Do not override them below. */
  --canvas-surround: var(--onyx-400);
  --ann-blue:   #2563EB;
  --ann-green:  #16A34A;
  --ann-orange: #EA580C;
  --ann-red:    #DC2626;
  --ann-purple: #7C3AED;
  --ann-grey:   #4B5563;
  /* The ring round a custom-colour swatch: reads as "any colour" (editor .swatch-custom, workspace .cp-custom-face). */
  --swatch-wheel: conic-gradient(var(--ann-red), var(--ann-orange), var(--ws-amber), var(--ann-green), var(--ws-teal), var(--ann-blue), var(--ann-purple), var(--ws-pink), var(--ann-red));

  /* Workspace tile presets (WorkspaceColor.Presets mirrors these; DESIGN.md "Workspace colours"). A custom hex
     reaches a tile only as its --ws property. The rings outline a tile too close to the rail's panel colour. */
  --ws-blue:   #2563EB;
  --ws-indigo: #4F46E5;
  --ws-violet: #7C3AED;
  --ws-pink:   #DB2777;
  --ws-orange: #EA580C;
  --ws-amber:  #B45309;
  --ws-green:  #16A34A;
  --ws-teal:   #0D9488;
  --ws-ink:    #FFFFFF;
  --ws-ink-dark: var(--onyx-900);   /* on a light custom colour (WorkspaceColor picks it) */
  --ws-ring-light: rgb(24 24 27 / 0.35);
  --ws-ring-dark:  rgb(255 255 255 / 0.40);
  /* Co-editing presence (avatars, rail dots, canvas outlines, held fields). Fixed: an outline sits on captured
     content, and one person keeps one colour in both themes. PresenceEntry.Color picks 1–8. */
  --presence-1: #2563EB;
  --presence-2: #DB2777;
  --presence-3: #059669;
  --presence-4: #D97706;
  --presence-5: #7C3AED;
  --presence-6: #0891B2;
  --presence-7: #DC2626;
  --presence-8: #4D7C0F;
  --presence-ink: #FFFFFF;
  /* The two panel colours whatever the theme: the colour picker previews a tile on both at once. */
  --panel-light: var(--onyx-0);
  --panel-dark:  var(--onyx-900);

  /* Storage usage bar (Settings → Data & storage). */
  --usage-screenshots: var(--accent);
  --usage-snapshots: var(--ann-green);
  --usage-originals: var(--ann-orange);
  --usage-versions: var(--ann-purple);

  /* Overlay chrome that sits on top of captured content (thumbnail badges,
     halos around annotations): fixed for the same reason the palette above is. */
  --scrim:     rgb(9 9 11 / .75);
  --on-scrim:  #FFFFFF;
  --halo:      rgb(255 255 255 / .6);

  /* The player's chapter/text page, drawn in the editor (rail cards, canvas). It copies
     player.css .dt-text-step/.dt-chapter-step with the default player accent (#2563EB in
     player.css), and is dark in both editor themes because the player page is. */
  --page-card-bg:     var(--onyx-950);
  --page-card-ink:    var(--on-scrim);
  --page-card-accent: #2563EB;
  --page-card-bg-light:  var(--onyx-0);
  --page-card-ink-light: var(--onyx-900);

  /* The public collection page's brand band (library.css .pub-band): the owner's --brand darkened toward
     black, in either theme, with white on it. The hero title is the one size above --text-2xl outside marketing. */
  --pub-band-ink:   #FFFFFF;
  --pub-band-shade: #05070D;
  --pub-title: 32px;
  --pub-title--line-height: 38px;
  --pub-title-sm: 24px;
  --pub-title-sm--line-height: 30px;

  /* The player's white card (player.css --card/--card-ink), drawn over the screenshot on the
     editor canvas: callouts read the same in the editor as in the player, in either theme. */
  --stage-card:     var(--onyx-0);
  --stage-card-ink: var(--onyx-900);

  /* Skipped steps in the rail: a hatch over the thumbnail. */
  --rail-hatch: color-mix(in srgb, var(--ink-subtle) 22%, transparent);

  /* Scrollbars: one soft grey thumb everywhere, lighter at rest, normal while the
     pointer is over the scroll container. Follows --ink-subtle, so both themes. */
  --scrollbar-thumb:       color-mix(in oklab, var(--ink-subtle) 30%, transparent);
  --scrollbar-thumb-hover: color-mix(in oklab, var(--ink-subtle) 65%, transparent);
  --scrollbar-thumb-drag:  var(--ink-muted);

  /* Elevation — four, plus the tooltip stem's dot; no others. */
  --shadow-rest:  0 1px 2px rgb(0 0 0 / .06);
  --shadow-toast: 0 4px 12px rgb(0 0 0 / .08);
  --shadow-pop:   0 8px 24px rgb(0 0 0 / .18);
  --shadow-modal: 0 20px 50px rgb(0 0 0 / .24);
  --shadow-dot:   0 1px 3px rgb(0 0 0 / .18);   /* the tooltip stem's dot (player.css mirrors it) */

  /* Radius — four steps, full and the tooltip card; no others. */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 999px;   /* pills, dots, round avatars */
  --radius-card-callout: 16px;   /* the canvas tooltip card, as the player's */

  /* Motion */
  --t-colour:  120ms;
  --t-move:    180ms;
  --t-overlay: 240ms;
  --motion-fast:  150ms;   /* rail drag shuffle, removal collapse */
  --motion-flash: 600ms;   /* a new step's arrival tint */
  --ease: cubic-bezier(.2, 0, 0, 1);

  --font-sans: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* The dark values are spelled out twice — once for the explicit choice, once for
   the OS preference. A custom property cannot be aliased across an attribute
   selector and a media query without a third indirection layer that reads worse
   than the repetition; DesignTokenTests keeps the two blocks in step. */

:root[data-theme="dark"] {
  --surface-page:   var(--onyx-950);
  --surface-panel:  var(--onyx-900);
  --surface-raised: var(--onyx-800);
  --surface-sunken: var(--onyx-950);
  --surface-header: var(--onyx-800);
  --surface-row-hover: var(--onyx-950);

  --ink:         var(--onyx-25);
  --ink-muted:   var(--onyx-400);
  --ink-subtle:  var(--onyx-500);
  --ink-inverse: var(--onyx-950);

  --edge:        var(--onyx-700);
  --edge-strong: var(--onyx-600);

  --action:       var(--onyx-50);
  --action-hover: var(--onyx-0);
  --action-ink:   var(--onyx-900);

  --accent:       #60A5FA;
  --accent-hover: #93C5FD;
  --accent-tint:  rgb(96 165 250 / .14);

  --danger:  #F87171;
  --warn:    #FBBF24;
  --success: #4ADE80;
  --lead-interested: #A78BFA;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-page:   var(--onyx-950);
    --surface-panel:  var(--onyx-900);
    --surface-raised: var(--onyx-800);
    --surface-sunken: var(--onyx-950);
    --surface-header: var(--onyx-800);
    --surface-row-hover: var(--onyx-950);

    --ink:         var(--onyx-25);
    --ink-muted:   var(--onyx-400);
    --ink-subtle:  var(--onyx-500);
    --ink-inverse: var(--onyx-950);

    --edge:        var(--onyx-700);
    --edge-strong: var(--onyx-600);

    --action:       var(--onyx-50);
    --action-hover: var(--onyx-0);
    --action-ink:   var(--onyx-900);

    --accent:       #60A5FA;
    --accent-hover: #93C5FD;
    --accent-tint:  rgb(96 165 250 / .14);

    --danger:  #F87171;
    --warn:    #FBBF24;
    --success: #4ADE80;
    --lead-interested: #A78BFA;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-colour: 0ms; --t-move: 0ms; --t-overlay: 0ms; --motion-fast: 0ms; --motion-flash: 0ms; }
}
