/* Guru Estates OS — design tokens (Step 3, 2026-11-26)
 * Custom properties only. Light and dark come from light-dark(); set color-scheme on <html>.
 * Every value names its source:
 *   [measured: product]  = read with getComputedStyle, see measurements-2026-11-26.md
 *   [guideline: source]  = read in a published guideline
 *   [chosen: reason]     = decided here; D-numbers are the rulings Ross accepted 2026-11-26
 * Contrast was checked by script (WCAG 2.2 + APCA 0.0.98G); the results are in guru-rules.md §Contrast.
 */

:root {
  color-scheme: light dark;                     /* [guideline: Vercel — set color-scheme] */

  /* ── Brand scale, 12 steps, OKLCH from #123F24 (hue 153.7) ─────────────── */
  /* step roles follow Radix: 1-2 backgrounds, 3-5 element fills, 6-8 lines, 9-10 solid, 11-12 text */
  --b-1:  light-dark(#FBFEFB, #09130C);         /* [guideline: Radix step 1] app bg tint */
  --b-2:  light-dark(#F5FBF7, #0D1B12);         /* [guideline: Radix step 2] subtle bg */
  --b-3:  light-dark(#EAF4EC, #122719);         /* [guideline: Radix step 3] element bg */
  --b-4:  light-dark(#E0EEE3, #173120);         /* [guideline: Radix step 4] element hover */
  --b-5:  light-dark(#D3E5D8, #1D3A27);         /* [guideline: Radix step 5] selected */
  --b-6:  light-dark(#C5DACA, #274731);         /* [guideline: Radix step 6] subtle line */
  --b-7:  light-dark(#B1CAB7, #345840);         /* [guideline: Radix step 7] line */
  --b-8:  light-dark(#93B39C, #497356);         /* [guideline: Radix step 8] strong line */
  --b-9:  light-dark(#123F24, #366747);         /* [chosen: Anoop's brand colour, onboarding 25 Nov; dark lifted to L .47 so white text holds APCA Lc 87] */
  --b-10: light-dark(#285437, #447655);         /* [guideline: Radix step 10] solid hover; lighter, since step 9 is dark */
  --b-11: light-dark(#386146, #B5D8BF);         /* [guideline: Radix step 11] brand text; checked Lc 83 / 77 */
  --b-12: light-dark(#0B2A17, #E0F0E4);         /* [guideline: Radix step 12] strong brand text; Lc 101 / 95 */

  /* ── Neutral scale, green-tinted greys from the same hue ───────────────── */
  --n-1:  light-dark(#FCFDFC, #0F100F);         /* [chosen: D4 — tinted, never pure white/black] */
  --n-2:  light-dark(#F8F9F8, #141615);         /* [measured: Mercury rail #FBFCFD, Attio #F4F5F6] */
  --n-3:  light-dark(#EEF1EF, #1D1F1E);         /* [guideline: Radix step 3] */
  --n-4:  light-dark(#E6E9E7, #242725);         /* [guideline: Radix step 4] */
  --n-5:  light-dark(#DDE0DE, #2C2E2C);         /* [guideline: Radix step 5] */
  --n-6:  light-dark(#D2D6D3, #404341);         /* [guideline: Radix step 6] */
  --n-7:  light-dark(#C3C7C4, #545855);         /* [guideline: Radix step 7; dark lifted so APCA Lc ≥ 15, the visibility floor] */
  --n-8:  light-dark(#A6AAA7, #5C605D);         /* [guideline: Radix step 8] */
  --n-9:  light-dark(#797D7A, #707471);         /* [guideline: WCAG 1.4.11 — input border ≥ 3:1; checked 4.1 / 4.0] */
  --n-10: light-dark(#676C68, #898D8A);         /* [guideline: WCAG 4.5:1 — placeholder text, checked 5.3 / 5.7] */
  --n-11: light-dark(#545855, #D1D3D1);         /* [guideline: APCA Lc 75 body minimum — checked Lc 84 / 79; dark lifted so hover rows hold Lc 77] */
  --n-12: light-dark(#1B1F1C, #EBEDEC);         /* [chosen: D4 — near-black from the brand hue; Lc 102 / 95] */

  /* ── Semantic roles (components use these, never the steps) ────────────── */
  --bg-app:        var(--n-1);                  /* [guideline: Radix 1] */
  --bg-subtle:     var(--n-2);                  /* [measured: Mercury rail] side rail, table head */
  --bg-element:    var(--n-3);                  /* [guideline: Radix 3] inputs, chips */
  --bg-hover:      var(--n-3);                  /* [guideline: Radix — step 3 is hover when rest is transparent] row hover */
  --bg-selected:   var(--b-3);                  /* [chosen: selection carries the brand hue] */
  --surface:       light-dark(#FFFFFF, #141615);/* [measured: Mercury cards white on white page; dark rgb(30,30,42) analogue] */
  --paper:         #F5F1ED;                     /* [measured: The Modern House paper] A4 brief only, light only */
  --line-subtle:   var(--n-6);                  /* [measured: Attio/Mercury hairlines at 5-10% alpha ≈ step 6] */
  --line:          var(--n-7);                  /* [guideline: Radix 7] */
  --line-input:    var(--n-9);                  /* [guideline: WCAG 1.4.11] */
  --text:          var(--n-12);                 /* body text */
  --text-muted:    var(--n-11);                 /* labels, metadata */
  --text-faint:    var(--n-10);                 /* placeholder, disabled */
  --brand:         var(--b-9);                  /* primary solid */
  --brand-hover:   var(--b-10);
  --brand-text:    var(--b-11);                 /* links, brand-coloured text */
  --on-brand:      #FFFFFF;                     /* [checked: Lc 101 light / 87 dark] */
  --focus:         light-dark(#123F24, #B5D8BF);/* [guideline: WCAG 1.4.11 ≥ 3:1; checked 11.7 / 12.3] */

  /* status: hues from the live roadmap portal, lightness set so small text holds APCA Lc 75 on its chip (proof page, 26 Nov) */
  --positive:      light-dark(#005D3D, #ABF0CD);/* [chosen: roadmap hue 162; Lc 77 on chip light, ≥ 80 dark] */
  --warning:       light-dark(#793900, #FFD2A4);/* [chosen: roadmap hue 62; Lc 80 / 78] */
  --info:          light-dark(#204B8D, #BCE0FF);/* [chosen: roadmap hue 259; Lc 77 / 79] */
  --negative:      light-dark(#822D22, #FFCDC0);/* [chosen: red hue 30; Lc 81 / 77] */
  --positive-soft: light-dark(#E3F2EA, color-mix(in srgb, #ABF0CD 10%, transparent)); /* [measured: roadmap --done-bg; dark 10% so text keeps Lc 75] */
  --warning-soft:  light-dark(#FBEEDB, color-mix(in srgb, #FFD2A4 10%, transparent)); /* [measured: roadmap --wait-bg] */
  --info-soft:     light-dark(#E4ECF8, color-mix(in srgb, #BCE0FF 10%, transparent)); /* [measured: roadmap --doing-bg] */
  --negative-soft: light-dark(#FDECEA, color-mix(in srgb, #FFCDC0 10%, transparent)); /* [chosen: same lightness as the others] */
  --chart-fill-top:    color-mix(in srgb, var(--brand) 22%, transparent); /* [measured: Mercury chart fill .28 → .08] */
  --chart-fill-bottom: color-mix(in srgb, var(--brand) 4%, transparent);

  /* ── Type ───────────────────────────────────────────────────────────────── */
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif; /* [chosen: Ross 26 Nov: all sans, everywhere; pack videinfra (Graphik stand-in); was Newsreader] */
  --font-body:    "Inter", ui-sans-serif, system-ui, sans-serif;     /* [measured: Attio, Linear use Inter] */
  --font-mono:    "IBM Plex Mono", ui-monospace, Menlo, monospace;   /* [measured: roadmap portal] reference numbers only */
  --num:          tabular-nums;                 /* [measured: Mercury] [guideline: Vercel, Rauno, Emil] */
  --decimal-scale: 0.73;                        /* [measured: Mercury decimals 20.44 / 28px] */

  /* size / line-height / tracking, one set per step. Tracking grows negative with size. */
  --text-12: 12px;  --lh-12: 16px;  --tr-12: 0em;       /* [measured: Attio 12/16] metadata only, never body */
  --text-13: 13px;  --lh-13: 20px;  --tr-13: -0.005em;  /* [measured: Linear 13 −0.01em, Mercury 13/20] */
  --text-14: 14px;  --lh-14: 20px;  --tr-14: -0.005em;  /* [measured: Attio 14/20 −0.005em] staff body, D6 */
  --text-16: 16px;  --lh-16: 24px;  --tr-16: -0.01em;   /* [measured: Attio 16 −0.01em; Addepar, Modern House 16/24] portal body, D6 */
  --text-18: 18px;  --lh-18: 28px;  --tr-18: -0.01em;   /* [measured: Addepar 18/27] portal lead */
  --text-22: 22px;  --lh-22: 28px;  --tr-22: -0.012em;  /* [guideline: M3 Title L 22/28] section titles */
  --text-28: 28px;  --lh-28: 36px;  --tr-28: -0.02em;   /* [chosen: videinfra pack, headings −0.02em softened from −0.05em] */
  --text-36: 36px;  --lh-36: 44px;  --tr-36: -0.02em;   /* [chosen: videinfra pack, headings −0.02em] [guideline: M3 Display S 36/44 size] */
  --text-48: 48px;  --lh-48: 56px;  --tr-48: -0.03em;   /* [chosen: videinfra pack, display −0.03em softened from −0.07em] [measured: Addepar h1 48px size] */
  --tr-figure: -0.03em;                         /* [measured: Mercury balance and row figures] */
  --tr-caps: 0.12em;                            /* [measured: Addepar 0.12em; Modern House 0.10–0.15em] portal and brief only, D3 */
  --weight-regular: 400;                        /* [guideline: Rauno — never below 400] */
  --weight-medium: 500;                         /* [measured: Attio default text weight] staff body, D6 */
  --weight-semibold: 600;                       /* [measured: Attio heading weight] */
  --weight-display: 500;                        /* [measured: videinfra Graphik headings at 500; Attio Inter Display 500] sans headings */
  --measure: 65ch;                              /* [guideline: Emil ~65ch; Anthropic < 80 chars] */

  /* ── Space: 4px grid ───────────────────────────────────────────────────── */
  --s-0: 0;  --s-1: 2px;  --s-2: 4px;  --s-3: 8px;  --s-4: 12px;  --s-5: 16px;  /* [guideline: ui-ux-pro-max 4pt grid] */
  --s-6: 20px;  --s-7: 24px;  --s-8: 32px;  --s-9: 40px;  --s-10: 48px;  --s-11: 64px;  --s-12: 80px;
  --row-h: 36px;                                /* [measured/20 Nov: Attio 36px rows] */
  --card-pad: 24px;                             /* [measured: Mercury card padding 24px] */
  --grid-gap-photo: 40px;                       /* [measured: Modern House 40px] */
  --target-min: 44px;                           /* [guideline: Apple HIG, Vercel mobile, Emil] touch */
  --target-min-pointer: 24px;                   /* [guideline: Vercel — visual < 24px gets a ≥ 24px hit area] */

  /* ── Radius ────────────────────────────────────────────────────────────── */
  --r-0: 0;                                     /* [measured: Modern House photos square] photographs */
  --r-chip: 4px;                                /* [measured: Attio 4px chips; Linear radius-4] */
  --r-control: 8px;                             /* [measured: Attio 8px controls (62×); Mercury containers] */
  --r-card: 12px;                               /* [measured: Mercury, Linear --card-radius 12px] */
  --r-sheet: 16px;                              /* [measured: Linear radius-16] sheets, dialogs */
  --r-pill: 9999px;                             /* [measured: Mercury buttons 67×, Modern House buttons] portal buttons */

  /* ── Elevation: three levels, two+ layers, tinted from #123F24 ─────────── */
  --shadow-tint: light-dark(#123F24, #000000); /* [guideline: Vercel — tint shadows toward the background hue] */
  --shadow-1:                                   /* raised: hovered card, segmented selection [measured: Mercury raised card] */
    0 0 0 1px color-mix(in srgb, var(--shadow-tint) 6%, transparent),
    0 1px 3px -1px color-mix(in srgb, var(--shadow-tint) 14%, transparent);
  --shadow-2:                                   /* floating: menu, dropdown, popover, AI panel [measured: Attio floating panel] */
    0 0 1px 1px color-mix(in srgb, var(--shadow-tint) 2%, transparent),
    0 4px 12px -1px color-mix(in srgb, var(--shadow-tint) 7%, transparent),
    0 1px 3px -1px color-mix(in srgb, var(--shadow-tint) 18%, transparent);
  --shadow-3:                                   /* overlay: sheet, dialog [measured: Attio deep panel + roadmap --gshadow] */
    0 1px 3px color-mix(in srgb, var(--shadow-tint) 8%, transparent),
    0 8px 16px -4px color-mix(in srgb, var(--shadow-tint) 8%, transparent),
    0 24px 48px -12px color-mix(in srgb, var(--shadow-tint) 20%, transparent);
  --edge-ring: light-dark(transparent, rgb(255 255 255 / 0.06)); /* [measured: Linear inset 1px white .05] dark surfaces need an edge, shadow can't show */
  --edge-light: inset 0 1px 0 rgb(255 255 255 / 0.18);          /* [measured: roadmap buttons .18; Attio dark buttons] light on brand-filled surfaces */
  --edge-light-glass: inset 0 1px 0 rgb(255 255 255 / 0.6);     /* [guideline: apple-design — bright top edge on materials] glass bars only */

  /* ── Translucency (portal floating chrome only) ────────────────────────── */
  --blur-chip: 4px;                             /* [measured: Attio blur(4px), Linear chips 4px] */
  --blur-bar: 12px;                             /* [measured: Attio header blur(12px)] sticky bars */
  --blur-sheet: 20px;                           /* [measured: Linear --header-blur 20px] [guideline: Emil < 20px ceiling] */
  --saturate: 1.2;                              /* [chosen: between roadmap 1.15 and Apple's 1.8; brand green stays green] */
  --glass-bar:   color-mix(in srgb, var(--n-1) 80%, transparent);  /* [measured: Attio header 80% white] */
  --glass-thick: color-mix(in srgb, var(--n-1) 88%, transparent);  /* [guideline: Apple — thicker material for text] anything holding text */
  --scrim: color-mix(in srgb, #0B2A17 35%, transparent);           /* [guideline: Apple HIG — 35% dimming layer] behind dialogs */

  /* ── Motion ────────────────────────────────────────────────────────────── */
  --dur-instant: 0ms;                           /* [guideline: Emil, Rauno — keyboard actions and theme switch get none] */
  --dur-press: 100ms;                           /* [measured: Linear speed-quickTransition .1s] */
  --dur-hover: 150ms;                           /* [measured: Attio default .15s; Linear .1–.16s] [guideline: Emil 100–150ms] */
  --dur-enter: 200ms;                           /* [guideline: Emil tooltips/dropdowns 150–250; Rauno ≤ 200] D1 staff ceiling */
  --dur-exit: 150ms;                            /* [guideline: ui-ux-pro-max exit ≈ 60–70% of enter; Emil ~20% faster] */
  --dur-dialog: 250ms;                          /* [guideline: Emil modals 200–300] D1 portal dialogs */
  --dur-sheet: 400ms;                           /* [chosen: D2 — prompt cap; measured sheets run 500–700ms] */
  --dur-sheet-exit: 300ms;                      /* [guideline: exit faster than enter] */
  --dur-page: 500ms;                            /* [chosen: D2 — portal page-level transitions only] */
  --ease-out: cubic-bezier(0, 0, 0, 1);         /* [measured: Attio --ease-out] [guideline: M3 standard-decelerate] enter */
  --ease-move: cubic-bezier(0.2, 0, 0, 1);      /* [measured: Attio --ease-in-out] [guideline: M3 standard] movement on screen, D10 */
  --ease-hover: cubic-bezier(0.25, 0.46, 0.45, 0.94); /* [measured: Linear ease-out-quad, 187×] colour changes */
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1); /* [measured: Attio, Mercury, Linear] [guideline: Emil/Vaul] sheets, drawers */
  --press-scale: 0.97;                          /* [guideline: Emil 0.97] D8 */
  --enter-scale: 0.96;                          /* [chosen: D9 — between Rauno .8 and Emil ≥ .93–.95, kept subtle] */
  --enter-shift: 4px;                           /* [chosen: menus drop 4px toward their trigger's side] */
  --travel: 1;                                  /* [chosen: multiplier on every slide distance; reduced motion sets 0] */
  --spring-damping: 1;                          /* [guideline: apple-design — critically damped default] JS gestures only */
  --spring-response: 0.35s;                     /* [guideline: apple-design response 0.3–0.4] */

  /* ── Layers ────────────────────────────────────────────────────────────── */
  --z-base: 0;  --z-sticky: 10;  --z-menu: 20;  --z-sheet: 40;  --z-toast: 100; /* [guideline: ui-ux-pro-max z-scale] */

  /* ── Focus ─────────────────────────────────────────────────────────────── */
  --focus-ring: 0 0 0 2px var(--bg-app), 0 0 0 4px var(--focus); /* [guideline: Rauno — box-shadow ring follows radius] */
}

/* Explicit theme from the user's setting overrides the system one. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* Reduced motion keeps the state change and drops the travel. [guideline: apple-design §14, Emil, Vercel] */
/* The same two settings also exist in the app (data-motion / data-transparency on <html>),
   for people who want them without changing their whole system. [chosen: Apple ships them as in-app settings too] */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) {
    --press-scale: 1;  --enter-scale: 1;  --enter-shift: 0px;  --travel: 0;
    --dur-sheet: 200ms;  --dur-sheet-exit: 150ms;  --dur-page: 200ms;  --dur-dialog: 200ms;
    --ease-sheet: var(--ease-out);
  }
}
:root[data-motion="reduce"] {
  --press-scale: 1;  --enter-scale: 1;  --enter-shift: 0px;  --travel: 0;
  --dur-sheet: 200ms;  --dur-sheet-exit: 150ms;  --dur-page: 200ms;  --dur-dialog: 200ms;
  --ease-sheet: var(--ease-out);
}

/* No translucency where the user asked for none, or where the browser can't blur. [guideline: apple-design §14] */
@media (prefers-reduced-transparency: reduce) {
  :root:not([data-transparency="full"]) { --blur-chip: 0px; --blur-bar: 0px; --blur-sheet: 0px; --glass-bar: var(--n-1); --glass-thick: var(--n-1); }
}
:root[data-transparency="reduce"] { --blur-chip: 0px; --blur-bar: 0px; --blur-sheet: 0px; --glass-bar: var(--n-1); --glass-thick: var(--n-1); }
@supports not (backdrop-filter: blur(1px)) {
  :root { --glass-bar: var(--n-1); --glass-thick: var(--n-1); }
}

/* More contrast: solid lines at input strength. [guideline: apple-design §14 prefers-contrast] */
@media (prefers-contrast: more) {
  :root { --line-subtle: var(--n-8); --line: var(--n-9); --text-muted: var(--n-12); --glass-bar: var(--n-1); --glass-thick: var(--n-1); }
}
