/* quiet — Zed / delta / helical lineage.
   Dense, hairline, one accent, no elevation theatre, mono for metadata.
   Token values are WCAG 2.2 AA-verified by tools/contrast.mjs; do not edit by
   hand without re-running it. */

/* @mode dark */
/* Scoping. A theme's unnamed defaults apply only where no theme is named --
   `:where(:root:not([data-ulex-theme]))`, at zero specificity -- so a page
   that loads both themes gets the one its attribute asks for rather than
   whichever file happened to load last. Every AAA block is also held to its
   own mode, so dark's AAA never reaches light or the reverse. The contrast
   checker reads these blocks by their @mode/@profile comments and cannot see
   selectors; test/browser.test.mjs checks the cascade delivers what it
   verified, for every theme, mode and level. */
:where(:root:not([data-ulex-theme])),
[data-ulex-theme="quiet"] {
  color-scheme: dark;

  /* surfaces */
  --ulex-bg:          #1b1d22;
  --ulex-surface:     #212429;
  --ulex-surface-hi:  #292d34;

  /* text — three levels at 12.6 / 7.0 / 4.5, so hierarchy survives AA */
  --ulex-text:        #dcdfe5;
  --ulex-text-dim:    #b4b9c1;
  --ulex-text-subtle: #8e949d;
  --ulex-accent:      #7fb0ff;

  /* edges, split by accessibility duty (see SPEC §5) */
  --ulex-edge-subtle:  #33383f;  /* decoration only — no contrast duty */
  --ulex-edge-control: #6c7685;  /* input / outline-button boundary — 3:1 */
  --ulex-edge-strong:  #8b96a5;  /* emphasis — 3:1 */
  --ulex-ring:         #7fb0ff;  /* focus indicator */

  /* tones */
  --ulex-tone-accent:  #7fb0ff;
  --ulex-tone-danger:  #e88b81;
  --ulex-tone-success: #8fd0b3;
  --ulex-tone-warning: #dcb877;
  --ulex-tone-info:    #a8aebc;

  /* Neutral needs two values: an ink (outline border, ghost label) that must
     clear 4.5:1 on every surface, and a solid fill, which in this theme is a
     raised surface rather than inverted text. A fill that close to the page
     cannot rely on colour for its edge, so neutral solid always draws one. */
  --ulex-tone-neutral: #dcdfe5;
  --ulex-neutral-fill: #292d34;
  --ulex-neutral-on:   #dcdfe5;

  /* Label on a solid semantic-tone fill. One token: every tone is already
     verified at >= 4.5:1 against the page background. */
  --ulex-on-tone: #1b1d22;

  /* fill="soft" tints the surface with the tone. Tinting moves the background
     TOWARD the text, so the ceiling is low -- measured at 12% for this
     palette, bound by danger. Verified by tools/contrast.mjs. */
  --ulex-fill-soft-mix: 10%;

  /* type — meta is a semantic role, mapped to mono in this theme */
  --ulex-font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ulex-font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ulex-font-meta: var(--ulex-font-mono);

  /* no elevation in this theme */
  --ulex-shadow-sm: none;
  --ulex-shadow-md: none;
  --ulex-shadow-lg: none;

  --ulex-radius-sm: 2px;
  --ulex-radius-md: 4px;
  --ulex-radius-lg: 6px;

  /* Dense: 13px body, 15px h1. The scale is the theme's, so retuning it here
     retunes every heading without touching a component. */
  --ulex-text-1: 1.125rem;
  --ulex-text-2: 0.9375rem;
  --ulex-text-3: 0.875rem;
  --ulex-text-4: 0.8125rem;
  --ulex-text-5: 0.8125rem;
  --ulex-text-6: 0.8125rem;
  --ulex-text-7: 0.8125rem;
  --ulex-text-8: 0.6875rem;

  --ulex-row-h:   1.875rem;  /* 30px — but the interactive target is a padded child, min 24px */
  --ulex-measure: 62ch;
}

/* @profile aaa */
/* AAA (1.4.6, 7:1). --ulex-text-dim and --ulex-text-subtle converge at this level;
   hierarchy below --ulex-text comes from weight and size, not colour. */
:where(:root:not([data-ulex-theme]))[data-ulex-level="aaa"]:not([data-ulex-mode="light"]),
[data-ulex-theme="quiet"][data-ulex-level="aaa"]:not([data-ulex-mode="light"]) {
  --ulex-text-dim:     #d0d4da;
  --ulex-text-subtle:  #b5b9be;
  --ulex-accent:       #8fbaff;
  --ulex-tone-accent:  #8fbaff;
  --ulex-tone-danger:  #eea79f;
  --ulex-tone-info:    #b3b9c5;

  /* At 7:1 the tones sit on the threshold, so any tint at all drops them
     below it: soft carries no tint at AAA and reads as outline. */
  --ulex-fill-soft-mix: 0%;
}

/* @mode light */
/* Light quiet.
 *
 * Not an inversion. helical's palette is tuned for dark, and flipping it gives
 * muddy tones and hairlines that vanish, so this is designed against the same
 * contract rather than derived from the values above: three text levels, edges
 * split by duty, tones that clear 4.5:1 on every surface.
 *
 * What carries over is the character, not the numbers. The neutrals stay
 * blue-cast rather than pure grey, the elevation stays a step in lightness
 * rather than a shadow, and "raised" still means closer to white — the same
 * direction the dark mode moves, so a component's surface logic is unchanged.
 */
[data-ulex-theme="quiet"][data-ulex-mode="light"] {
  color-scheme: light;

  --ulex-bg:          #eef1f5;
  --ulex-surface:     #f8fafc;
  --ulex-surface-hi:  #ffffff;

  --ulex-text:        #1c1f26;
  --ulex-text-dim:    #464c57;
  --ulex-text-subtle: #626a77;
  --ulex-accent:      #1f56b0;

  --ulex-edge-subtle:  #d7dce3;
  --ulex-edge-control: #7c8593;
  --ulex-edge-strong:  #5d6674;
  --ulex-ring:         #1f56b0;

  --ulex-tone-accent:  #1f56b0;
  --ulex-tone-danger:  #b02a1f;
  --ulex-tone-success: #10643c;
  --ulex-tone-warning: #7a4a05;
  --ulex-tone-info:    #40506a;

  --ulex-tone-neutral: #1c1f26;
  --ulex-neutral-fill: #dfe4ea;
  --ulex-neutral-on:   #1c1f26;

  --ulex-on-tone: #ffffff;

  --ulex-fill-soft-mix: 10%;
}

/* @profile aaa */
/* At 7:1 the dim and subtle levels converge here as they do in the dark mode,
   and every tone darkens onto the threshold. Soft carries no tint at AAA. */
[data-ulex-theme="quiet"][data-ulex-mode="light"][data-ulex-level="aaa"] {
  --ulex-text-dim:     #33383f;
  --ulex-text-subtle:  #454b55;
  --ulex-accent:       #17418a;
  --ulex-tone-accent:  #17418a;
  --ulex-tone-danger:  #8f2118;
  --ulex-tone-success: #0c4d2e;
  --ulex-tone-warning: #5e3904;
  --ulex-tone-info:    #333f54;
  --ulex-fill-soft-mix: 0%;
}
