/* ==========================================================================
   @agentu/ui  tokens.css
   One set of design tokens for every Agentu surface (web app, Bridge desktop
   app, Chrome extension, phone app). Source of truth together with
   tokens.json; the test in test/tokens.test.ts asserts the two agree.

   Theme resolution
     :root, [data-theme="light"]                light (default; the attribute
                                                  also scopes a light region)
     [data-theme="dark"]                          dark, forced by theme.js
     @media (prefers-color-scheme: dark)
       :root:not([data-theme="light"])            dark, following the system

   Contrast (WCAG 2.1, relative luminance, computed 7 Oct 2026; AA is 4.5:1 for
   text, 3:1 for large text and non-text UI). "soft" backgrounds are alpha fills
   composited over `surface`, the usual host of a pill or chip.

     pair                              dark      light
     text on bg                        17.60     19.66
     text on surface                   16.14     18.06
     text on surface-3                 13.80     15.40
     text-muted on bg                   7.69      6.39
     text-muted on surface              7.05      5.87
     text-muted on surface-2 (pill)     6.56      5.43
     text-muted on surface-3            6.03      5.00
     accent-ink on accent (primary)    15.67     15.67
     accent-text on bg                 15.67      6.26
     accent-text on surface            14.37      5.75
     accent-text on accent-soft        10.71      5.47
     danger on bg                       7.09      6.57
     danger on surface                  6.50      6.04
     danger on danger-soft              5.34      5.13
     ok on bg                          10.23      6.64
     ok on surface                      9.38      6.10
     ok on ok-soft                      7.19      5.28
     warn on bg                        11.14      6.56
     warn on surface                   10.22      6.02
     warn on warn-soft                  7.70      5.23
     info on bg                         9.41      6.09
     info on surface                    8.63      5.59
     info on info-soft                  6.66      4.86
     border-strong on bg (non-text)     3.75      4.24
     border-strong on surface           3.43      3.89
     bg on text (toast, inverse)       17.60     19.66
     accent on bg (focus ring)         15.67      1.25  *
     white knob on border-strong        5.25      4.24

   * Lime on white is 1.25:1, so the light focus ring adds a 1 px ink hairline
     outside the 2 px lime ring (ink on white 19.66:1, ink on lime 15.67:1);
     the dark ring is lime alone. Lime is never used as text in light mode;
     accent-text is #4A6A00 there (6.26:1).
   Deviations from the v2 prototype: light `ok` #1F7A45 -> #176A3B and light
   `warn` #9A6700 -> #7F5500, because the prototype values measured 4.31:1 and
   3.95:1 on their soft pill backgrounds, under AA for 12-13 px pill text.
   Everything else is the prototype value.
   ========================================================================== */

:root,
[data-theme="light"] {
  color-scheme: light;

  /* colour: directive table */
  --bg: #FFFFFF;
  --surface: #F5F5F7;
  --border: #E3E3EA;
  --border-strong: #7A7A86;
  --text: #0B0B0D;
  --text-muted: #5E5E6A;
  --accent: #CDF542;
  --accent-text: #4A6A00;
  --danger: #B42318;

  /* colour: extras from the prototype */
  --surface-2: #ECECF1;
  --surface-3: #E3E3EA;
  --accent-ink: #0B0B0D;
  --accent-soft: rgba(205, 245, 66, 0.28);
  --danger-soft: rgba(180, 35, 24, 0.10);
  --ok: #176A3B;
  --ok-soft: rgba(23, 106, 59, 0.10);
  --warn: #7F5500;
  --warn-soft: rgba(127, 85, 0, 0.10);
  --info: #1F5FBF;
  --info-soft: rgba(31, 95, 191, 0.10);
  --scrim: rgba(11, 11, 13, 0.55);

  /* elevation: shadows only in light; borders do the work in dark */
  --shadow: 0 1px 2px rgba(11, 11, 13, 0.06), 0 8px 24px rgba(11, 11, 13, 0.06);
  --shadow-pop: 0 20px 60px rgba(11, 11, 13, 0.18);

  /* focus ring: 2 px lime, 2 px outside offset (+1 px ink hairline in light) */
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;
  --focus-halo: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-ink);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent), 0 0 0 5px var(--accent-ink);

  /* alias kept for code written against the prototype */
  --muted: var(--text-muted);

  /* radius */
  --radius: 16px;
  --radius-s: 10px;
  --radius-xs: 6px;
  --radius-pill: 999px;

  /* type */
  --font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Space Grotesk Fallback", "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-display: 28px;
  --lh-body: 1.5;
  --lh-tight: 1.2;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* spacing: 4 pt grid */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 48px;

  /* z-index */
  --z-raised: 1;
  --z-nav: 10;
  --z-popover: 30;
  --z-modal: 50;
  --z-toast: 70;

  /* motion: 150-200 ms ease-out on state changes, none on page load */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 160ms;
  --dur-slow: 240ms;

  /* layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --bottom-nav-h: 64px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0D;
  --surface: #16161B;
  --border: #2A2A33;
  --border-strong: #6B6B78;
  --text: #F2F2F5;
  --text-muted: #A1A1AC;
  --accent: #CDF542;
  --accent-text: #CDF542;
  --danger: #FF6B6B;
  --surface-2: #1D1D23;
  --surface-3: #24242B;
  --accent-ink: #0B0B0D;
  --accent-soft: rgba(205, 245, 66, 0.12);
  --danger-soft: rgba(255, 107, 107, 0.14);
  --ok: #5AD18A;
  --ok-soft: rgba(90, 209, 138, 0.14);
  --warn: #F5B942;
  --warn-soft: rgba(245, 185, 66, 0.14);
  --info: #8AB4FF;
  --info-soft: rgba(138, 180, 255, 0.14);
  --scrim: rgba(11, 11, 13, 0.55);
  --shadow: none;
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.40);
  --focus-halo: 0 0 0 2px var(--bg);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B0B0D;
    --surface: #16161B;
    --border: #2A2A33;
    --border-strong: #6B6B78;
    --text: #F2F2F5;
    --text-muted: #A1A1AC;
    --accent: #CDF542;
    --accent-text: #CDF542;
    --danger: #FF6B6B;
    --surface-2: #1D1D23;
    --surface-3: #24242B;
    --accent-ink: #0B0B0D;
    --accent-soft: rgba(205, 245, 66, 0.12);
    --danger-soft: rgba(255, 107, 107, 0.14);
    --ok: #5AD18A;
    --ok-soft: rgba(90, 209, 138, 0.14);
    --warn: #F5B942;
    --warn-soft: rgba(245, 185, 66, 0.14);
    --info: #8AB4FF;
    --info-soft: rgba(138, 180, 255, 0.14);
    --scrim: rgba(11, 11, 13, 0.55);
    --shadow: none;
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.40);
    --focus-halo: 0 0 0 2px var(--bg);
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  }
}

/* Narrow touch screens (phone-sized web, extension on mobile): 17 px body. */
@media (pointer: coarse) and (max-width: 720px) {
  :root {
    --fs-md: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur: 0ms;
    --dur-slow: 0ms;
  }
}
