/* house set v2. 2026-11-19, lane design-critique. proposed as the one token file for design/ (see house-set-v2.md).
   every value is a default, not a gate: the file sits in low-priority layers, so any unlayered rule in a product wins.
   three ways to change it, cheapest first:
     1. one value:   :root { --control-height: 28px }            in the product's own css (design.overrides.css)
     2. a preset:    <html data-density="tool">  or  <html data-preset="house-classic">
     3. a layer:     .paper / .paper.warm-dark on a page or subtree
   each change from v1 names the finding behind it (critique/findings.md).
   needs: oklch + color-mix (chrome 111, firefox 113, safari 16.2), light-dark() (123 / 120 / 17.5), @layer. */

@layer house.tokens, house.presets, house.base;

@layer house.tokens {
  :root {
    color-scheme: light dark;

    /* ---------- type ---------- */
    --font-ui: -apple-system, BlinkMacSystemFont, "Geist", system-ui, sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --font-rounded: ui-rounded, "SF Pro Rounded", "Geist", sans-serif;   /* cute consumer products only */
    --font-serif: "EB Garamond", "Iowan Old Style", Georgia, serif;      /* reading products only */
    --text-xs: 12px;        /* v1 11. floor for the web. B1 */
    --text-sm: 13px;        /* v1 12 */
    --text-ui: 14px;        /* v1 13. web tools and public pages. 13 lives in data-density="tool" */
    --text-heading: 16px;   /* v1 14. a heading is 1.15x its body or more. B2 */
    --text-body: 16px;      /* v1 15 */
    --text-prose: 17px;     /* kept: ryanaque, fpui.dev, maycord.dev. inside the 15-25px range for web prose */
    --text-title: 24px;
    --text-display: 40px;
    --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600;
    --tracking-body: 0;           /* v1 -0.02em. the system font tightens itself with size. C7 */
    --tracking-heading: -0.015em; /* v1 -0.025em. from 20px up only */
    --tracking-display: -0.025em; /* v1 -0.04em. from 40px up only */
    --leading-ui: 1.4; --leading-body: 1.5; --leading-prose: 1.6; --leading-display: 1.1;
    --measure: 68ch;              /* prose line length. B8 */

    /* ---------- space: closed scale. 4px grid plus 2 and 6. v1 also had 10 and 14. C4 ---------- */
    --space-0-5: 2px; --space-1: 4px; --space-1-5: 6px; --space-2: 8px; --space-3: 12px;
    --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

    /* ---------- size ---------- */
    --control-height: 32px;       /* v1 28. public web default. 28 lives in data-density="tool". B4 */
    --control-height-sm: 24px;    /* the wcag 2.5.8 floor. nothing interactive is smaller */
    --control-height-touch: 44px;
    --row-height: 32px;
    --target-min: 24px;
    --icon-size: 16px;
    --content-width: 720px;
    --switch-width: 40px; --switch-height: 24px;  /* v1 38x22. B4 */

    /* ---------- radius: four steps and round. C4 ---------- */
    --radius-inner: 4px;     /* items inside a control-radius container */
    --radius-control: 6px;   /* a soft site may set 10px here, once */
    --radius-card: 12px;     /* cards, dialogs, popovers with content, sheets */
    --radius-surface: 16px;  /* hero panels, media */
    --radius-round: 999px;

    /* ---------- colour, tool layer ---------- */
    --background: light-dark(oklch(1 0 0), oklch(0.21 0 0));
    --surface:    light-dark(oklch(0.97 0 0), oklch(0.25 0 0));
    --elevated:   light-dark(oklch(1 0 0), oklch(0.26 0 0));
    --ink:        light-dark(oklch(0.24 0.008 200), oklch(0.93 0.005 200));
    --muted:      light-dark(oklch(0.49 0.012 200), oklch(0.76 0.012 200));  /* dark was 0.70: Lc -49 -> -59. C1 */
    --border:         light-dark(oklch(0.9 0 0), oklch(0.33 0 0));           /* separators and cards. decorative */
    --border-strong:  light-dark(oklch(0.84 0.006 200), oklch(0.42 0.006 200));
    --border-control: light-dark(oklch(0.62 0.006 200), oklch(0.56 0.006 200)); /* new. edge of inputs, checks, switch tracks: 3.3:1 or more on every surface. wcag 1.4.11 */
    --hover:      light-dark(oklch(0.943 0 0), oklch(0.285 0 0));
    --active:     light-dark(oklch(0.919 0 0), oklch(0.31 0 0));
    --accent:     light-dark(oklch(0.45 0.075 200), oklch(0.8 0.075 200));   /* swap the hue per product. keep L */
    --accent-ink: light-dark(oklch(1 0 0), oklch(0.21 0 0));
    --control-fill: var(--ink);        /* primary button. set to var(--accent) for an accent primary: both pass */
    --control-ink: var(--background);
    --selection:  color-mix(in oklab, var(--accent) 22%, var(--background)); /* v1 mixed in oklch and came out pink. C2 */
    --overlay:    oklch(0 0 0 / 0.2);
    --backdrop:   oklch(0 0 0 / 0.45);
    --status-success: light-dark(oklch(0.437 0.097 149), oklch(0.874 0.103 138));
    --status-warning: light-dark(oklch(0.432 0.093 71),  oklch(0.865 0.088 86));
    --status-danger:  light-dark(oklch(0.484 0.171 20),  oklch(0.833 0.093 19));
    --status-info:    light-dark(oklch(0.439 0.140 262), oklch(0.833 0.085 256));
    /* there is no third text grey on purpose. placeholders, empty states, dates and counts use --muted. B3 */

    /* ---------- focus: one spec, no alpha. B5 ---------- */
    --focus-width: 2px; --focus-offset: 2px; --focus-color: var(--accent);

    /* ---------- depth ---------- */
    --shadow-raised: 0 1px 2px light-dark(rgb(0 0 0 / 4%), rgb(0 0 0 / 30%)), 0 8px 24px -12px light-dark(rgb(0 0 0 / 12%), rgb(0 0 0 / 50%));
    --shadow-popover: 0 6px 24px var(--overlay);

    /* ---------- motion: design/motion/tokens.md, unchanged. the user's faster values and 30 studies agree ---------- */
    --motion-instant: 0ms; --motion-exit: 90ms; --motion-fast: 120ms; --motion-base: 200ms; --motion-pane: 240ms; --motion-slow: 320ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --ease-out-soft: ease-out; --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1); --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
    --delay-loader: 300ms;         /* wait state appears after this */
    --loader-min-visible: 400ms;   /* new. once shown, it stays this long so it does not flash */
    --disabled-opacity: 0.5;
    --grain-opacity: 0.3;
  }
}

@layer house.presets {
  /* desktop tool density. supported by evidence for fine pointers: apple hig macos control 28pt and text 13pt, github small 28px */
  [data-density="tool"] {
    --control-height: 28px; --row-height: 28px;
    --text-ui: 13px; --text-sm: 12px; --text-xs: 12px; --text-heading: 15px; --text-body: 15px;
  }
  /* the user's own v1 values, one attribute away. the checker reports each as "overridden by user", not as a failure */
  [data-preset="house-classic"] {
    --control-height: 28px; --row-height: 28px;
    --text-xs: 11px; --text-sm: 12px; --text-ui: 13px; --text-heading: 14px; --text-body: 15px;
    --tracking-body: -0.02em; --tracking-heading: -0.025em; --tracking-display: -0.04em;
    --space-2-5: 10px; --space-3-5: 14px;      /* the 2px-grid half steps. components do not use them. product css may */
    --switch-width: 38px; --switch-height: 22px;
    --muted: light-dark(oklch(0.49 0.012 200), oklch(0.7 0.012 200));
  }
  /* a coarse pointer always gets real targets and 16px form text, whatever preset is on. placed last on purpose */
  @media (pointer: coarse) {
    :root, [data-density], [data-preset] { --control-height: var(--control-height-touch); --row-height: var(--control-height-touch); --control-height-sm: 32px; --text-ui: 16px; --text-sm: 14px; --text-xs: 12px; --switch-width: 51px; --switch-height: 31px; }
  }
  @media (prefers-contrast: more) { :root { --muted: var(--ink); --border: var(--border-control); } }

  /* paper layer: sites and reading surfaces */
  .paper {
    --background: light-dark(oklch(0.985 0.022 93), oklch(0.19 0 0));
    --surface:    light-dark(oklch(0.975 0.014 78), oklch(0.22 0 0));
    --ink:        light-dark(oklch(0.225 0.011 73), oklch(0.94 0 0));
    --muted:      light-dark(oklch(0.47 0.025 74), oklch(0.76 0 0));   /* v1 light 0.378 was hibi's body colour: 1.69:1 under ink. now 2.5:1 under ink, 6.0:1 on the grain */
    --border:     light-dark(rgb(31 27 22 / 0.2), oklch(0.36 0 0));
    --border-control: light-dark(oklch(0.6 0.02 74), oklch(0.58 0 0));
  }
  .paper.grain { background-image: url("paper-grain.svg"); }  /* the page only. never a surface that holds body text. C9 */
  .paper.warm-dark {
    --background: light-dark(oklch(0.912 0.030 86), oklch(0.212 0.017 79));
    --surface:    light-dark(oklch(0.975 0.014 78), oklch(0.266 0.023 75));
    --ink:        light-dark(oklch(0.225 0.011 73), oklch(0.934 0.035 85));
    --muted:      light-dark(oklch(0.44 0.025 74), oklch(0.74 0.04 84));  /* v1 dark 0.837 sat 1.36:1 under ink */
    --border:     light-dark(rgb(31 27 22 / 0.2), rgb(244 232 207 / 0.18));
  }
}

@layer house.base {
  :focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
  :where(input, textarea, select):focus-visible { outline-offset: calc(-1 * var(--focus-width)); }
  ::selection { background: var(--selection); color: var(--ink); }
  ::placeholder { color: var(--muted); opacity: 1; }
  @media (prefers-reduced-motion: reduce) {
    :root { --motion-exit: 0ms; --motion-fast: 0ms; --motion-base: 0ms; --motion-pane: 0ms; --motion-slow: 0ms; }
    *, *::before, *::after, ::backdrop { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; }
  }
}
