/*
 * Seq semantic colour roles — the only colour tokens a component may read
 * (docs/plans/seq-redesign.md § Colour carries one thing each, § Both themes, § 2).
 *
 * Every value references a geneops-brand role (--background-*, --text-*, --border-*, the grey
 * scale) or one step of the four Seq scales in _color-palette.css. No hex literal here. The
 * roles are declared under `:root, .theme-dark` and under `.theme-light`, the gem's own hooks,
 * the way the gem's tokens-semantic.css does; the class on <html> is set by the pre-paint
 * script in layouts/_head.html.erb, so a first visit follows the system scheme. Components
 * are theme-blind: they read roles only.
 *
 * Each accent scale has one job. Emerald marks succeeded; golden marks queued and running;
 * cardinal marks failed and blocked; gold, as the double border of .seq-canonical and its one
 * label, marks the production configuration; grey is everything else, and tyrian marks nothing
 * but the diff's added rows. A state colour appears on the one state word inside the dominant
 * element's figure (.seq-dominant__state), on the .seq-state mark in rows and on the node of
 * the run graph, and nowhere else: never as the background or border of a module. Each role
 * is read as the colour of 32px bold text, of 14px text beside a dot, or of the dot itself,
 * so 4.5:1 against both grounds is the bar for every value; the measured contrast of every
 * step is in the header of _color-palette.css.
 */

:root,
.theme-dark {
  /* ---------- State: the three colours of a run, job or check state ----------
     Dark: emerald-400 5.39:1 on grey-950 (4.95:1 on grey-900), golden-400 8.81:1 (8.10:1),
     cardinal-400 5.75:1 (5.28:1). Pending and cancelled are grey: the mark reads the gem's
     --border-strong and --text-secondary and has no role here. */
  --state-succeeded: var(--color-emerald-400);
  --state-working:   var(--color-golden-400);
  --state-failed:    var(--color-cardinal-400);

  /* ---------- Ornament: the gold of the production mark, .seq-canonical ----------
     --ornament is the two hairlines (golden-600, 4.93:1 on base, 4.53:1 on surface-1, a dull
     step so a hairline of it is not read as a lit running state); --ornament-ink is the one
     label, "Production", golden-300 at 70 % over the ground (at full opacity 10.36:1). No
     other element reads either: no focus ring, no wash, no control accent is gold. */
  --ornament:     var(--color-golden-600);
  --ornament-ink: color-mix(in oklab, var(--color-golden-300) 70%, transparent);

  /* ---------- Diff: the comparison of two runs or configurations (.seq-diff) ----------
     Added is tyrian, removed is cardinal, changed is golden; each is drawn as a stroke or a
     low-alpha wash, never a fill, and each module pairs it with a glyph (+, −, ~) so the
     meaning survives without colour. Added is tyrian on purpose: a row added in a diff is not
     a check that passed, and the triad purple, red, gold keeps a diff apart from a state. */
  --diff-added:        var(--color-tyrian-300);
  --diff-added-ink:    var(--color-tyrian-200);
  --diff-added-wash:   color-mix(in oklab, var(--color-tyrian-400) 7%, transparent);
  --diff-removed:      var(--color-cardinal-400);
  --diff-removed-ink:  var(--color-cardinal-200);
  --diff-removed-wash: color-mix(in oklab, var(--color-cardinal-500) 7%, transparent);
  --diff-changed:      var(--color-golden-500);
  --diff-changed-ink:  var(--color-golden-300);
  --diff-changed-wash: color-mix(in oklab, var(--color-golden-400) 7%, transparent);

  /* ---------- Changed-row wash: a row a Turbo Stream just replaced fades from this to its ground
     (09-utilities/_changed.css), and the console's selected lines and the copy control read it
     as a tint. Neutral, the text colour at 10 %: the wash is an attention cue, not a state, and
     gold marks the production configuration only. */
  --wash-changed: color-mix(in oklab, var(--text-primary) 10%, transparent);

  /* ---------- Focus ring: the :focus-visible outline in 03-generic/_base.css and the two
     scroll containers that restate it (05-objects/_scroll.css, .seq-graph). The text colour,
     so it clears 4.5:1 on every ground in both themes and is not gold. */
  --focus-ring: var(--text-primary);

  /* ---------- A form error and the copy control's refusal: the gem's danger text ---------- */
  --invalid:     var(--text-danger);
  --invalid-ink: var(--text-danger);

  /* ---------- Console (log viewer) ---------- */
  --console-surface: var(--background-base);
  --console-ink:     var(--text-primary);

  /* ---------- The one shadow (--shadow-lift in _layout.css) ---------- */
  --shadow-color: var(--color-grey-950-75);
}

/* ---------- Light theme ----------
   The gem's .theme-light block supplies --background-*, --text-* and --border-*; only Seq's
   own roles are declared here. State: emerald-700 8.69:1 on grey-50 (8.05:1 on grey-100),
   golden-700 5.38:1 (4.98:1), cardinal-700 7.89:1 (7.30:1). Ornament is golden-700 (5.38:1 on
   grey-50, 4.98:1 on grey-100) and its ink golden-800 (8.44:1). The run graph's state words
   read the state roles and its boxes the gem's grounds, so it needs no role of its own. */
.theme-light {
  --state-succeeded: var(--color-emerald-700);
  --state-working:   var(--color-golden-700);
  --state-failed:    var(--color-cardinal-700);

  --ornament:     var(--color-golden-700);
  --ornament-ink: var(--color-golden-800);

  --diff-added:        var(--color-tyrian-500);
  --diff-added-ink:    var(--color-tyrian-600);
  --diff-added-wash:   color-mix(in oklab, var(--color-tyrian-500) 7%, transparent);
  --diff-removed:      var(--color-cardinal-600);
  --diff-removed-ink:  var(--color-cardinal-700);
  --diff-removed-wash: color-mix(in oklab, var(--color-cardinal-600) 7%, transparent);
  --diff-changed:      var(--color-golden-600);
  --diff-changed-ink:  var(--color-golden-700);
  --diff-changed-wash: color-mix(in oklab, var(--color-golden-500) 7%, transparent);

  --console-surface: var(--color-grey-100);
  --console-ink:     var(--color-grey-800);
  --shadow-color:    var(--color-grey-950-10);
}

/* ---------- Light ground, scoped: .seq-mail ----------
   The transactional email is not a theme: a mail client will not carry the gem's .theme-light
   block, so the surface redeclares the gem's grounds, text and borders and every Seq role from
   the light steps, scoped to its own root. Nothing outside the root is affected. */
.seq-mail {
  --background-base:      var(--color-grey-50);
  --background-surface-1: var(--color-grey-100);
  --background-surface-2: var(--color-grey-200);
  --background-hover:     var(--color-grey-300);
  --text-primary:   var(--color-grey-800);
  --text-secondary: var(--color-grey-600);
  --text-tertiary:  var(--color-grey-600);
  --border-strong:  var(--color-grey-500);
  --border-default: var(--color-grey-300);
  --border-subtle:  var(--color-grey-200);

  --state-succeeded: var(--color-emerald-700);
  --state-working:   var(--color-golden-700);
  --state-failed:    var(--color-cardinal-700);
  --ornament:        var(--color-golden-700);
  --ornament-ink:    var(--color-golden-800);
  --focus-ring:      var(--color-grey-800);
  --console-surface: var(--color-grey-100);
  --console-ink:     var(--color-grey-800);
  --shadow-color:    var(--color-grey-950-10);
}
