/* house-design tokens, v0.1.0
 *
 * Light theme only. Every colour, size and duration a page uses comes from here.
 * A page sets its THEME INPUTS (section 1) in its own :root block, after this file,
 * and everything in sections 2 to 9 derives from them. Never edit sections 2 to 9
 * for one page; change the inputs. See references/anti-sameness.md for how to pick them.
 *
 * Inputs must be set on :root. Custom properties resolve where they are declared,
 * so an input changed on a child element does not re-derive the ramps.
 *
 * Adapted material (licences in ../licenses/, credits in ../NOTICE.md):
 * - the 12-step role scale (what each step is for) follows the Radix Colors scale model, MIT;
 *   the lightness and chroma values are our own, chosen so contrast holds by construction
 *   (proved by scripts/derive_theme.py --sweep);
 * - the ease-out and ease-in-out curves are Open Props' --ease-out-3, --ease-out-4 and
 *   --ease-in-out-3 values, MIT;
 * - the fluid type method (a scale at each of two viewport widths, clamp() between them)
 *   follows the Utopia method by James Gilyead and Trys Mudford; the formula is used with
 *   credit, no text or code taken.
 */

:root {
  color-scheme: light only;

  /* ------------------------------------------------------------------ 1. THEME INPUTS
     Set these per brief. The defaults are a placeholder, not a look. */
  --in-hue: 250;              /* brand hue anchor, OKLCH degrees, from the subject's world */
  --in-chroma: 0.11;          /* brand chroma at step 9; 0.04 quiet, 0.11 clear, 0.2 max */
  --in-support-hue: 60;       /* a second hue for one supporting role, or the brand hue again */
  --in-support-chroma: 0.08;
  --in-neutral-hue: 250;      /* the tint inside the greys: warm (40 to 90) or cool (200 to 260) */
  --in-neutral-chroma: 0.012; /* 0 = pure grey, 0.02 = clearly tinted */
  --in-radius: 4px;           /* radius character: 0 sharp, 2 to 4px crisp, 6 to 10px soft */
  --in-density: 1;            /* 0.85 compact (tools), 1 default, 1.2 airy (editorial) */
  --in-text-min: 17;          /* body size in px at 390 wide (16 is the floor) */
  --in-text-max: 19;          /* body size in px at 1440 wide */
  --in-ratio-min: 1.2;        /* type scale ratio at 390 */
  --in-ratio-max: 1.28;       /* type scale ratio at 1440: 1.2 product, 1.25 to 1.333 marketing */
  --font-display: Georgia, "Times New Roman", serif;   /* replace with the brief's display face */
  --font-text: Verdana, Geneva, sans-serif;            /* replace with the brief's text face */
  --font-ui: var(--font-text);
  /* Never a monospace face, in any role (house floor). Tabular figures come from
     font-variant-numeric on the text face, not from a code font. */
  /* Per-page overrides allowed besides the inputs: --radius-media, --leading-body,
     --measure, --reveal-distance, the headline emphasis tokens --em-* (section 4), and the four
     --status-*-hue values when derive_theme.py asks for a move. Everything else in sections 2 to 9 is derived; do not set it per page. */

  /* ------------------------------------------------------------------ 2. COLOUR RAMPS
     Twelve steps per hue. Roles (adapted from the Radix Colors scale model):
       1 page background        2 subtle background     3 component background
       4 hovered component       5 pressed or selected   6 quiet divider
       7 decorative border       8 control border (3:1)  9 solid fill (white text 4.5:1)
      10 hovered solid, focus    11 secondary text (4.5:1 on 1 to 3)
      12 primary text (12:1 on 1)
     Lightness is fixed per step and chroma scales with the input, so contrast holds for
     any hue up to chroma 0.2. scripts/derive_theme.py checks a theme before use. */
  --brand-1:  oklch(0.985 calc(var(--in-chroma) * 0.06) var(--in-hue));
  --brand-2:  oklch(0.965 calc(var(--in-chroma) * 0.12) var(--in-hue));
  --brand-3:  oklch(0.935 calc(var(--in-chroma) * 0.25) var(--in-hue));
  --brand-4:  oklch(0.905 calc(var(--in-chroma) * 0.35) var(--in-hue));
  --brand-5:  oklch(0.87  calc(var(--in-chroma) * 0.45) var(--in-hue));
  --brand-6:  oklch(0.82  calc(var(--in-chroma) * 0.55) var(--in-hue));
  --brand-7:  oklch(0.74  calc(var(--in-chroma) * 0.70) var(--in-hue));
  --brand-8:  oklch(0.60  calc(var(--in-chroma) * 0.85) var(--in-hue));
  --brand-9:  oklch(0.50  var(--in-chroma) var(--in-hue));
  --brand-10: oklch(0.44  var(--in-chroma) var(--in-hue));
  --brand-11: oklch(0.42  calc(var(--in-chroma) * 0.85) var(--in-hue));
  --brand-12: oklch(0.26  calc(var(--in-chroma) * 0.45) var(--in-hue));

  --support-1:  oklch(0.985 calc(var(--in-support-chroma) * 0.06) var(--in-support-hue));
  --support-2:  oklch(0.965 calc(var(--in-support-chroma) * 0.12) var(--in-support-hue));
  --support-3:  oklch(0.935 calc(var(--in-support-chroma) * 0.25) var(--in-support-hue));
  --support-6:  oklch(0.82  calc(var(--in-support-chroma) * 0.55) var(--in-support-hue));
  --support-8:  oklch(0.60  calc(var(--in-support-chroma) * 0.85) var(--in-support-hue));
  --support-9:  oklch(0.50  var(--in-support-chroma) var(--in-support-hue));
  --support-11: oklch(0.42  calc(var(--in-support-chroma) * 0.85) var(--in-support-hue));
  --support-12: oklch(0.26  calc(var(--in-support-chroma) * 0.45) var(--in-support-hue));

  --neutral-1:  oklch(0.985 calc(var(--in-neutral-chroma) * 0.5) var(--in-neutral-hue));
  --neutral-2:  oklch(0.965 calc(var(--in-neutral-chroma) * 0.6) var(--in-neutral-hue));
  --neutral-3:  oklch(0.935 calc(var(--in-neutral-chroma) * 0.7) var(--in-neutral-hue));
  --neutral-4:  oklch(0.905 calc(var(--in-neutral-chroma) * 0.8) var(--in-neutral-hue));
  --neutral-5:  oklch(0.87  calc(var(--in-neutral-chroma) * 0.9) var(--in-neutral-hue));
  --neutral-6:  oklch(0.82  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-7:  oklch(0.74  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-8:  oklch(0.60  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-9:  oklch(0.50  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-10: oklch(0.44  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-11: oklch(0.42  var(--in-neutral-chroma) var(--in-neutral-hue));
  --neutral-12: oklch(0.26  calc(var(--in-neutral-chroma) * 1.2) var(--in-neutral-hue));
  --white: oklch(0.995 calc(var(--in-neutral-chroma) * 0.3) var(--in-neutral-hue));

  /* ------------------------------------------------------------------ 3. SEMANTIC COLOUR
     Name by role, never by value. Status hues are fixed and kept apart from the brand:
     if the brand hue sits within 30 degrees of a status hue, move the status hue (see
     references/colour.md), never the brand. */
  --surface: var(--neutral-1);          /* the page */
  --surface-sunk: var(--neutral-2);     /* a recessed band or well */
  --surface-raised: var(--white);       /* a panel that sits above the page */
  --surface-tint: var(--brand-2);       /* the one brand-coloured band, used once or twice */
  --surface-support: var(--support-2);
  --text: var(--neutral-12);
  --text-muted: var(--neutral-11);
  --text-on-solid: var(--white);
  --text-accent: var(--brand-11);       /* links and accent words */
  --border-quiet: var(--neutral-6);     /* dividers, card edges */
  --border: var(--neutral-7);           /* decorative frames */
  --border-control: var(--neutral-8);   /* inputs and controls: 3:1 against the page */
  --accent: var(--brand-9);             /* primary action fill; roughly a tenth of the area at most */
  --accent-hover: var(--brand-10);
  --accent-soft: var(--brand-3);
  --support: var(--support-9);
  --focus: var(--brand-10);
  --selection: var(--brand-4);

  --status-danger-hue: 27;
  --status-warning-hue: 75;
  --status-success-hue: 150;
  --status-info-hue: 235;
  --danger-surface:  oklch(0.965 0.025 var(--status-danger-hue));
  --danger-border:   oklch(0.80  0.09  var(--status-danger-hue));
  --danger-text:     oklch(0.45  0.15  var(--status-danger-hue));
  --danger:          oklch(0.50  0.17  var(--status-danger-hue));
  --warning-surface: oklch(0.975 0.035 var(--status-warning-hue));
  --warning-border:  oklch(0.82  0.10  var(--status-warning-hue));
  --warning-text:    oklch(0.43  0.09  var(--status-warning-hue));
  --success-surface: oklch(0.97  0.03  var(--status-success-hue));
  --success-border:  oklch(0.80  0.09  var(--status-success-hue));
  --success-text:    oklch(0.42  0.10  var(--status-success-hue));
  --info-surface:    oklch(0.97  0.02  var(--status-info-hue));
  --info-border:     oklch(0.80  0.07  var(--status-info-hue));
  --info-text:       oklch(0.43  0.11  var(--status-info-hue));

  /* ------------------------------------------------------------------ 4. TYPE
     Fluid steps between 390 and 1440 wide (Utopia method, credited above).
     step 0 is body. Steps -2 and -1 are small print and labels; 1 to 6 are headings
     and display. Display never exceeds 6rem. */
  --vw-min: 390;
  --vw-max: 1440;
  --s-2-min: calc(var(--in-text-min) / pow(var(--in-ratio-min), 2));
  --s-2-max: calc(var(--in-text-max) / pow(var(--in-ratio-max), 2));
  --s-1-min: calc(var(--in-text-min) / var(--in-ratio-min));
  --s-1-max: calc(var(--in-text-max) / var(--in-ratio-max));
  --s1-min: calc(var(--in-text-min) * var(--in-ratio-min));
  --s1-max: calc(var(--in-text-max) * var(--in-ratio-max));
  --s2-min: calc(var(--in-text-min) * pow(var(--in-ratio-min), 2));
  --s2-max: calc(var(--in-text-max) * pow(var(--in-ratio-max), 2));
  --s3-min: calc(var(--in-text-min) * pow(var(--in-ratio-min), 3));
  --s3-max: calc(var(--in-text-max) * pow(var(--in-ratio-max), 3));
  --s4-min: calc(var(--in-text-min) * pow(var(--in-ratio-min), 4));
  --s4-max: calc(var(--in-text-max) * pow(var(--in-ratio-max), 4));
  --s5-min: calc(var(--in-text-min) * pow(var(--in-ratio-min), 5));
  --s5-max: calc(var(--in-text-max) * pow(var(--in-ratio-max), 5));
  --s6-min: calc(var(--in-text-min) * pow(var(--in-ratio-min), 5.5));
  --s6-max: min(96, calc(var(--in-text-max) * pow(var(--in-ratio-max), 7)));

  --step--2: clamp(calc(max(13, var(--s-2-min)) / 16 * 1rem), calc((max(13, var(--s-2-min)) - (max(13, var(--s-2-max)) - max(13, var(--s-2-min))) / 1050 * 390) / 16 * 1rem + (max(13, var(--s-2-max)) - max(13, var(--s-2-min))) / 1050 * 100vw), calc(max(13, var(--s-2-max)) / 16 * 1rem));
  --step--1: clamp(calc(max(14, var(--s-1-min)) / 16 * 1rem), calc((max(14, var(--s-1-min)) - (var(--s-1-max) - max(14, var(--s-1-min))) / 1050 * 390) / 16 * 1rem + (var(--s-1-max) - max(14, var(--s-1-min))) / 1050 * 100vw), calc(var(--s-1-max) / 16 * 1rem));
  --step-0: clamp(calc(var(--in-text-min) / 16 * 1rem), calc((var(--in-text-min) - (var(--in-text-max) - var(--in-text-min)) / 1050 * 390) / 16 * 1rem + (var(--in-text-max) - var(--in-text-min)) / 1050 * 100vw), calc(var(--in-text-max) / 16 * 1rem));
  --step-1: clamp(calc(var(--s1-min) / 16 * 1rem), calc((var(--s1-min) - (var(--s1-max) - var(--s1-min)) / 1050 * 390) / 16 * 1rem + (var(--s1-max) - var(--s1-min)) / 1050 * 100vw), calc(var(--s1-max) / 16 * 1rem));
  --step-2: clamp(calc(var(--s2-min) / 16 * 1rem), calc((var(--s2-min) - (var(--s2-max) - var(--s2-min)) / 1050 * 390) / 16 * 1rem + (var(--s2-max) - var(--s2-min)) / 1050 * 100vw), calc(var(--s2-max) / 16 * 1rem));
  --step-3: clamp(calc(var(--s3-min) / 16 * 1rem), calc((var(--s3-min) - (var(--s3-max) - var(--s3-min)) / 1050 * 390) / 16 * 1rem + (var(--s3-max) - var(--s3-min)) / 1050 * 100vw), calc(var(--s3-max) / 16 * 1rem));
  --step-4: clamp(calc(var(--s4-min) / 16 * 1rem), calc((var(--s4-min) - (var(--s4-max) - var(--s4-min)) / 1050 * 390) / 16 * 1rem + (var(--s4-max) - var(--s4-min)) / 1050 * 100vw), calc(var(--s4-max) / 16 * 1rem));
  --step-5: clamp(calc(var(--s5-min) / 16 * 1rem), calc((var(--s5-min) - (var(--s5-max) - var(--s5-min)) / 1050 * 390) / 16 * 1rem + (var(--s5-max) - var(--s5-min)) / 1050 * 100vw), calc(var(--s5-max) / 16 * 1rem));
  --step-6: clamp(calc(var(--s6-min) / 16 * 1rem), calc((var(--s6-min) - (var(--s6-max) - var(--s6-min)) / 1050 * 390) / 16 * 1rem + (var(--s6-max) - var(--s6-min)) / 1050 * 100vw), calc(var(--s6-max) / 16 * 1rem));

  --leading-tight: 1.05;   /* display */
  --leading-snug: 1.2;     /* headings */
  --leading-body: 1.55;    /* sans body; add 0.05 for a serif body */
  --tracking-display: -0.025em;  /* never tighter than -0.04em */
  --tracking-heading: -0.01em;
  --tracking-small: 0.01em;
  --measure: 68ch;         /* body text column; 60 to 75ch */
  --measure-narrow: 52ch;

  /* Headline emphasis (0.2.4; type.md section 5; the .hd-em--* classes in components.css).
     Defaults suit a regular-weight headline; a page sets them in theme.css to fit its own pair. */
  --em-italic-weight: 500;            /* .hd-em--italic: the headline's own family, true italic, a step heavier */
  --em-italic-tracking: -0.015em;
  --em-serif-family: var(--font-text); /* .hd-em--serif: the contrasting family's italic (the text face by default) */
  --em-serif-weight: 400;
  --em-serif-size: 1em;               /* 1.04em to 1.08em when the italic's x-height sits lower than the headline's */
  --em-serif-tracking: -0.01em;
  --em-cut-family: var(--font-display); /* .hd-em--cut: a condensed or heavier cut of the display face */
  --em-cut-weight: 800;
  --em-cut-stretch: 75%;
  --em-accent-colour: var(--text-accent); /* .hd-em--accent: same face, the accent text colour */

  /* ------------------------------------------------------------------ 5. SPACE
     A 4px unit. Tight inside a group, generous between groups. Section padding
     is fluid and takes the density input, and sections are expected to vary. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;
  --section-tight: calc(clamp(40px, 5vw, 72px) * var(--in-density));
  --section: calc(clamp(64px, 8vw, 128px) * var(--in-density));
  --section-loose: calc(clamp(88px, 12vw, 192px) * var(--in-density));
  --gutter: clamp(16px, 4.5vw, 64px);   /* 16 to 20px at 390 */
  --container: 1240px;                   /* max content width at 1440 */
  --container-wide: 1360px;

  /* ------------------------------------------------------------------ 6. RADIUS
     Derived from one character input. Media keep their own radius (default 0) so
     not every box shares one corner. */
  --radius-s: calc(var(--in-radius) * 0.5);
  --radius-m: var(--in-radius);
  --radius-l: calc(var(--in-radius) * 2);
  --radius-media: 0px;
  --radius-pill: 999px;   /* only for chips and switches */

  /* ------------------------------------------------------------------ 7. ELEVATION
     Three levels, each with an offset and a soft blur, tinted from the neutral hue.
     Use one level per role; never the same shadow on every card. */
  --shadow-1: 0 1px 2px oklch(0.25 0.02 var(--in-neutral-hue) / 0.08), 0 2px 6px oklch(0.25 0.02 var(--in-neutral-hue) / 0.06);
  --shadow-2: 0 4px 10px oklch(0.25 0.02 var(--in-neutral-hue) / 0.10), 0 12px 28px oklch(0.25 0.02 var(--in-neutral-hue) / 0.08);
  --shadow-3: 0 10px 24px oklch(0.25 0.02 var(--in-neutral-hue) / 0.14), 0 30px 60px oklch(0.25 0.02 var(--in-neutral-hue) / 0.12);

  /* ------------------------------------------------------------------ 8. MOTION
     Durations: UI motion stays under 300ms. --dur-scene is for the one authored
     page moment only. Easings: ease-out for anything entering or responding,
     ease-in-out for things moving on screen. No bounce, no overshoot. */
  --dur-instant: 90ms;
  --dur-quick: 160ms;
  --dur-standard: 240ms;
  --dur-scene: 600ms;
  --ease-out: cubic-bezier(0, 0, .3, 1);        /* Open Props --ease-out-3, MIT */
  --ease-out-strong: cubic-bezier(0, 0, .1, 1); /* Open Props --ease-out-4, MIT */
  --ease-in-out: cubic-bezier(.5, 0, .5, 1);    /* Open Props --ease-in-out-3, MIT */
  --reveal-distance: 28px;

  /* ------------------------------------------------------------------ 9. LAYERS */
  --z-sticky: 10;
  --z-menu: 20;
  --z-dialog: 30;
  --z-toast: 40;
}

/* Fallback for browsers without CSS pow(): fixed steps for the default scale, so headings
   never collapse to body size. Browsers with pow() use the fluid steps above. */
@supports not (width: calc(pow(2, 2) * 1px)) {
  :root {
    --step--2: 0.8125rem; --step--1: 0.875rem; --step-0: 1.125rem; --step-1: 1.375rem;
    --step-2: 1.75rem; --step-3: 2.25rem; --step-4: 2.875rem; --step-5: 3.5rem; --step-6: 4.5rem;
  }
}

/* Light only. A dark OS setting must change nothing (house floor). This block exists so
   no later stylesheet can opt the page into a dark scheme by accident. */
@media (prefers-color-scheme: dark) {
  :root { color-scheme: light only; }
}
