/*
 * TraceWorks design tokens: the only source of visual values for apps/ and packages/ui.
 * Values come from design/prototypes/c2-mierigs/C2 Handoff.dc.html; where design/brief.md
 * ("Chosen direction") differs, the brief wins and the difference is noted next to the token.
 *
 * Themes: light by default; dark follows the device unless <html data-theme="light">, and
 * <html data-theme="dark"> forces it. The dark block is written twice because a media query cannot
 * be combined with an attribute selector; tokens.test.ts keeps both copies identical.
 */

:root {
  color-scheme: light;

  /* Surface and text */
  --tw-color-bg: #f4f6f7;
  --tw-color-surface: #ffffff;
  --tw-color-text: #16222b;
  --tw-color-text-2: #435260;
  --tw-color-line: #d3dbdf;
  --tw-color-track: #e3e8eb;
  --tw-color-disabled: #d5dce0;
  --tw-color-icon-on: #ffffff;

  /* Brand and action. Petrol stays the same in both themes; the primary button lifts in dark. */
  --tw-color-petrol: #0e4a57;
  --tw-color-primary: #0e4a57;
  --tw-color-on-primary: #ffffff;
  --tw-color-on-petrol: #ffffff;
  --tw-color-on-petrol-2: #d4e4e8;
  --tw-color-camera: #0b2229;
  --tw-color-camera-2: #0f2a32;
  --tw-color-camera-label: #c9dce0;
  --tw-color-scan-hit: #6fe0a0;
  --tw-color-viewfinder: rgba(255, 255, 255, 0.9);

  /* Status: always together with an icon and a word (design/brief.md, "Status language"). */
  --tw-color-ok: #1f7a45;
  --tw-color-warning: #a35f00;
  --tw-color-error: #b42318;
  --tw-color-needs-review: #6b46c1;
  --tw-color-waiting: #3e5c9a;
  --tw-color-unknown: #435260;
  --tw-color-ok-ring: rgba(31, 122, 69, 0.35);
  --tw-color-new-row: #e6f1eb;

  /* Overlays */
  --tw-color-scrim-phone: rgba(6, 16, 20, 0.55);
  --tw-color-scrim-portal: rgba(6, 16, 20, 0.5);
  --tw-color-on-petrol-fill: rgba(255, 255, 255, 0.14);

  /*
   * Floating layers (task bar over the camera, result sheet, popups). Solid here; translucent only
   * in the @supports block below. The glass colours are the "-glass" tokens so the tests can check
   * contrast of both.
   */
  --tw-layer-bar: var(--tw-color-petrol);
  --tw-layer-sheet: var(--tw-color-bg);
  --tw-layer-popup: var(--tw-color-surface);
  --tw-layer-filter: none;
  /* A shadow that draws nothing, not `none`, so it can sit in a shadow list next to another shadow. */
  --tw-layer-edge: inset 0 0 0 transparent;
  --tw-layer-edge-sheet: inset 0 0 0 transparent;
  --tw-layer-radius: var(--tw-radius-sheet);
  /* The handoff has .62; .88 is the lowest that keeps white text at 7:1 over a white camera frame. */
  --tw-color-bar-glass: rgba(14, 74, 87, 0.88);
  --tw-color-sheet-glass: rgba(244, 246, 247, 0.86);
  --tw-color-popup-glass: rgba(255, 255, 255, 0.82);
  --tw-glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  --tw-glass-edge-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  /*
   * Type: IBM Plex Sans for words and numbers (design/brief.md, "Chosen direction"). Numbers use
   * tabular figures (Plex's default) and a dotted zero, so 0 and O stay apart in codes.
   * Sizes are rem (16 px = 1rem) so the device's text size setting still applies.
   */
  --tw-font-family: "IBM Plex Sans", system-ui, sans-serif;
  --tw-font-numeric: "tnum" 1, "zero" 1;
  --tw-font-num-hero: 500 6.5rem / 1 var(--tw-font-family);
  --tw-font-num-xl: 500 5rem / 1 var(--tw-font-family);
  --tw-font-num-l: 500 4.5rem / 1 var(--tw-font-family);
  --tw-font-num-m: 500 3.75rem / 1 var(--tw-font-family);
  --tw-font-num-code: 500 2.125rem / 1.2 var(--tw-font-family);
  --tw-font-num-tile: 500 1.75rem / 1.1 var(--tw-font-family);
  --tw-tracking-num-large: -0.04em;
  --tw-tracking-num-m: -0.03em;
  --tw-tracking-num-small: -0.01em;
  --tw-font-title-page: 600 2rem / 1.2 var(--tw-font-family);
  --tw-font-dest: 600 1.75rem / 1.15 var(--tw-font-family);
  --tw-font-title-item: 600 1.625rem / 1.25 var(--tw-font-family);
  --tw-font-title-modal: 600 1.5rem / 1.2 var(--tw-font-family);
  --tw-font-title-popup: 600 1.375rem / 1.2 var(--tw-font-family);
  --tw-font-product: 600 1.3125rem / 1.25 var(--tw-font-family);
  --tw-font-header: 600 1.25rem / 1.2 var(--tw-font-family);
  --tw-font-row: 500 1.1875rem / 1.3 var(--tw-font-family);
  --tw-font-body: 400 1.0625rem / 1.45 var(--tw-font-family);
  --tw-font-label: 400 1rem / 1.4 var(--tw-font-family);
  --tw-font-caption: 400 0.9375rem / 1.4 var(--tw-font-family);
  --tw-font-small: 600 0.875rem / 1.3 var(--tw-font-family);
  --tw-font-chip: 500 0.9375rem / 1.3 var(--tw-font-family);
  --tw-font-chip-selected: 600 0.9375rem / 1.3 var(--tw-font-family);
  --tw-font-label-strong: 600 1rem / 1.4 var(--tw-font-family);
  /* Button labels: the handoff's "tablet primary label" is title-modal and its "portal primary label" is row. */
  --tw-font-button-portal: 600 1.1875rem / 1.3 var(--tw-font-family);
  --tw-font-button-secondary: 500 1.0625rem / 1.45 var(--tw-font-family);

  /* Spacing. The handoff's one-off 6, 10, 14, 18 and 22 px are rounded to this scale in code. */
  --tw-space-1: 0.25rem;
  --tw-space-2: 0.5rem;
  --tw-space-3: 0.75rem;
  --tw-space-4: 1rem;
  --tw-space-5: 1.25rem;
  --tw-space-6: 1.5rem;
  --tw-space-7: 1.75rem;
  --tw-space-8: 2rem;

  /* Sizes of touch targets (design/brief.md, "Environment"). */
  --tw-target-min: 48px;
  --tw-target-primary-phone: 60px;
  --tw-target-primary-tablet: 64px;
  --tw-target-primary-station: 76px;
  --tw-target-stepper: 56px;
  --tw-target-secondary: 52px;
  --tw-target-portal: 52px;
  --tw-target-icon: 48px;
  --tw-target-row: 60px;
  --tw-target-field: 52px;
  --tw-target-stepper-compact: 48px;

  /* Borders and fixed sizes */
  --tw-border-hairline: 1px;
  --tw-border-control: 1.5px;
  --tw-size-status-icon-small: 20px;
  --tw-size-status-icon: 28px;
  --tw-size-status-icon-large: 32px;
  --tw-size-icon: 1.25rem;
  --tw-size-icon-inline: 1.25em;
  --tw-size-status-glyph: 62%;
  --tw-size-row-bar: 3px;
  --tw-size-button-min: 9.375rem;
  --tw-width-readable: 40rem;
  --tw-width-modal: 36.25rem;
  --tw-size-sheet-inset: 12px;
  --tw-size-sheet-rise: 40px;
  --tw-size-modal-rise: 12px;
  --tw-size-tile-min: 148px;
  --tw-size-tile-lift: 2px;
  --tw-size-fill-bar: 6px;
  --tw-size-camera-result: 13.375rem;
  --tw-size-viewfinder-aiming-width: 72%;
  --tw-size-viewfinder-aiming-height: 70%;
  --tw-size-viewfinder-result-width: 56%;
  --tw-size-viewfinder-result-height: 90px;
  --tw-size-viewfinder-line: 2px;
  --tw-size-viewfinder-line-hit: 3px;
  --tw-scale-scan-hit: 0.94;
  --tw-scale-check-from: 0.4;
  --tw-scale-check-over: 1.15;

  /* Radius */
  --tw-radius-full: 999px;
  --tw-radius-circle: 50%;
  --tw-radius-glass: 28px;
  --tw-radius-modal: 24px;
  --tw-radius-sheet: 20px;
  --tw-radius-tile: 16px;
  --tw-radius-field: 14px;
  --tw-radius-card: 12px;
  --tw-radius-small: 10px;
  --tw-radius-bar: 3px;

  /* Shadow */
  --tw-shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.35);
  --tw-shadow-popup: 0 12px 40px rgba(0, 0, 0, 0.35);
  --tw-shadow-hover: 0 6px 18px rgba(8, 30, 38, 0.1);
  --tw-shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.14);

  /*
   * Focus (design/brief.md, "Chosen direction"): 3 px ring with a 1.5 px gap that shows the
   * background. Primary in light; in dark primary is only 2.7:1 on surfaces (WCAG 1.4.11 asks 3:1),
   * so the ring uses the light petrol text colour there. On the petrol band use the -on-petrol ring.
   */
  --tw-focus-width: 3px;
  --tw-focus-gap: 1.5px;
  --tw-focus-color: var(--tw-color-primary);
  --tw-focus-color-on-petrol: var(--tw-color-on-petrol);

  /*
   * Edge of a chosen chip or segment. The same as its fill in light; in dark the primary fill is 2.7:1 on
   * surfaces (WCAG 1.4.11 asks 3:1), so the chosen state also gets a light edge there, as the focus ring does.
   */
  --tw-color-selected-edge: var(--tw-color-primary);

  /*
   * Motion. Only as a response to an action. Every duration is 0 with reduced motion (below and
   * base.css). Durations JavaScript needs are mirrored in index.ts; tokens.test.ts keeps them equal.
   */
  --tw-ease-standard: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tw-ease-out: ease-out;
  --tw-duration-press: 90ms;
  --tw-duration-colour: 160ms;
  --tw-duration-scan-hit: 220ms;
  --tw-duration-camera-shrink: 260ms;
  --tw-duration-result-rise: 240ms;
  --tw-duration-number: 200ms;
  --tw-duration-check-pop: 260ms;
  --tw-duration-sheet-up: 260ms;
  --tw-duration-modal-pop: 220ms;
  --tw-duration-toggle: 220ms;
  --tw-duration-tile-in: 280ms;
  --tw-duration-bar-grow: 520ms;
  --tw-duration-tree-row: 220ms;
  --tw-duration-ring: 700ms;
  --tw-duration-new-row: 1400ms;
  --tw-stagger-result: 50ms;
  --tw-stagger-tile: 35ms;
  --tw-scale-press: 0.97;
  --tw-scale-press-round: 0.9;
  --tw-scale-press-chip: 0.96;
  --tw-scale-press-tile: 0.98;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --tw-color-bg: #0d1a1f;
    --tw-color-surface: #16262c;
    --tw-color-text: #e8eef0;
    --tw-color-text-2: #a9b8bf;
    --tw-color-line: #2a4048;
    --tw-color-track: #24383f;
    --tw-color-disabled: #2a3b42;
    --tw-color-icon-on: #0d1a1f;
    --tw-color-primary: #16707f;
    --tw-focus-color: var(--tw-color-on-petrol-2);
    --tw-color-selected-edge: var(--tw-color-on-petrol-2);
    --tw-color-ok: #5cc98a;
    --tw-color-warning: #f2b04a;
    --tw-color-error: #ff8a7a;
    --tw-color-needs-review: #b69cff;
    --tw-color-waiting: #8fb0f0;
    --tw-color-unknown: #a9b8bf;
    --tw-color-ok-ring: rgba(92, 201, 138, 0.35);
    --tw-color-new-row: #183a2b;
    --tw-color-sheet-glass: rgba(13, 26, 31, 0.84);
    --tw-color-popup-glass: rgba(22, 38, 44, 0.84);
    --tw-glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --tw-glass-edge-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --tw-color-bg: #0d1a1f;
  --tw-color-surface: #16262c;
  --tw-color-text: #e8eef0;
  --tw-color-text-2: #a9b8bf;
  --tw-color-line: #2a4048;
  --tw-color-track: #24383f;
  --tw-color-disabled: #2a3b42;
  --tw-color-icon-on: #0d1a1f;
  --tw-color-primary: #16707f;
  --tw-focus-color: var(--tw-color-on-petrol-2);
  --tw-color-selected-edge: var(--tw-color-on-petrol-2);
  --tw-color-ok: #5cc98a;
  --tw-color-warning: #f2b04a;
  --tw-color-error: #ff8a7a;
  --tw-color-needs-review: #b69cff;
  --tw-color-waiting: #8fb0f0;
  --tw-color-unknown: #a9b8bf;
  --tw-color-ok-ring: rgba(92, 201, 138, 0.35);
  --tw-color-new-row: #183a2b;
  --tw-color-sheet-glass: rgba(13, 26, 31, 0.84);
  --tw-color-popup-glass: rgba(22, 38, 44, 0.84);
  --tw-glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --tw-glass-edge-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/*
 * Translucent layers only where blur works and the user has not asked for less transparency
 * (design/brief.md, "Chosen direction"). Both blocks are :root, so the reduced-transparency block
 * wins only because it comes later; tokens.test.ts checks the order.
 */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  :root {
    --tw-layer-bar: var(--tw-color-bar-glass);
    --tw-layer-sheet: var(--tw-color-sheet-glass);
    --tw-layer-popup: var(--tw-color-popup-glass);
    --tw-layer-filter: blur(22px) saturate(160%);
    --tw-layer-edge: var(--tw-glass-edge);
    --tw-layer-edge-sheet: var(--tw-glass-edge-sheet);
    --tw-layer-radius: var(--tw-radius-glass);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --tw-layer-bar: var(--tw-color-petrol);
    --tw-layer-sheet: var(--tw-color-bg);
    --tw-layer-popup: var(--tw-color-surface);
    --tw-layer-filter: none;
    --tw-layer-edge: inset 0 0 0 transparent;
    --tw-layer-edge-sheet: inset 0 0 0 transparent;
    --tw-layer-radius: var(--tw-radius-sheet);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --tw-duration-press: 0ms;
    --tw-duration-colour: 0ms;
    --tw-duration-scan-hit: 0ms;
    --tw-duration-camera-shrink: 0ms;
    --tw-duration-result-rise: 0ms;
    --tw-duration-number: 0ms;
    --tw-duration-check-pop: 0ms;
    --tw-duration-sheet-up: 0ms;
    --tw-duration-modal-pop: 0ms;
    --tw-duration-toggle: 0ms;
    --tw-duration-tile-in: 0ms;
    --tw-duration-bar-grow: 0ms;
    --tw-duration-tree-row: 0ms;
    --tw-duration-ring: 0ms;
    --tw-duration-new-row: 0ms;
    --tw-stagger-result: 0ms;
    --tw-stagger-tile: 0ms;
    --tw-scale-press: 1;
    --tw-scale-press-round: 1;
    --tw-scale-press-chip: 1;
    --tw-scale-press-tile: 1;
    --tw-scale-scan-hit: 1;
    --tw-scale-check-from: 1;
    --tw-scale-check-over: 1;
  }
}
