/* MoneyTies colour roles.
 *
 * Part 0 of the locked presentation grammar (31 July 2026). ELEVEN role
 * families: severity.N.ink and identity.N.ink joined the named roles on
 * 31 July, which is not a new decision but the phase 2 contrast findings
 * written into the grammar. This file already bound both. Every pattern module refers to a role and never to a value,
 * so a palette change re-binds this file and invalidates no pattern.
 *
 * PHASE 0 RULE: this file is ADDITIVE. Every role below is an alias onto
 * a token the product already ships, so binding them changes nothing on
 * screen today. Views adopt roles as they convert, one commit at a time.
 *
 * The palette is under review by the owner. When it lands, it lands here
 * and nowhere else.
 *
 * Naming: every role is prefixed --r-. The screen contract asserts that
 * pattern modules reference only var(--r-*), which is what makes the
 * re-binding promise mechanical rather than aspirational.
 */

:root {
  /* severity: three states, each with ink and a wash. Never the only
     carrier of meaning - R8 requires an accompanying word or icon. */
  --r-severity-good-ink: var(--liveText);
  --r-severity-good-bg: var(--liveBg);
  /* NOT var(--amber). Measured 2026-07-31: #e0940f on its own wash over
     white is 2.15:1, a C21 failure. An alias that fails contrast is not
     a safe alias, so this role takes its own value in light. #8a5600
     measures 5.30:1 on the same wash. Dark keeps the bright amber,
     which already measures 8.60:1 on the dark wash. */
  --r-severity-watch-ink: #8a5600;
  --r-severity-watch-bg: rgba(224, 148, 15, .12);
  /* NOT var(--rose), for the same reason as watch and found the same
     way. #e5566f on its own wash over white measures 3.09:1. It has not
     shipped because P03 applies severity only to draft and
     needs-your-review, both watch; urgent arrives with P07 row severity
     in phase 6, so this was caught before it rendered rather than after.
     #b3243e measures 5.62:1 on the same wash. Dark keeps #e8697d, which
     already measures 4.72:1. */
  --r-severity-urgent-ink: #b3243e;
  --r-severity-urgent-bg: rgba(229, 86, 111, .12);

  /* identity: one hue per company, identity only, never severity and
     never a datum, always drawn with initials.

     Not "fixed for the product's life" yet, which is what this comment
     used to claim. P14.slotFor assigns from the entity identifier alone
     and IS stable; the shell still calls entSlot(), which indexes the
     entities the current viewer can see. Until the views convert, a
     company's hue can change when the viewer's access changes. */
  --r-identity-1: var(--e1);
  --r-identity-2: var(--e2);
  --r-identity-3: var(--e3);
  --r-identity-4: var(--e4);
  --r-identity-5: var(--e5);
  --r-identity-6: var(--e6);

  /* The ink the token's INITIALS are set in, chosen per hue.
     The entity hues were validated in 2026-07 at >= 3:1, which is the
     threshold for a graphical object. The token carries text, so it owes
     4.5:1, and measurement on 2026-07-31 found white letters failing on
     every hue in dark (3.03 to 3.94) and on four of six in light.
     No single ink passes across all six, so each hue takes whichever of
     near-black or white measures higher. Worst case after this is
     4.76:1. Re-measure whenever a hue changes. */
  --r-identity-1-ink: #000000;   /* 4.76 vs white 4.42 */
  --r-identity-2-ink: #000000;   /* 6.56 vs white 3.20 */
  --r-identity-3-ink: #000000;   /* 5.74 vs white 3.66 */
  --r-identity-4-ink: #ffffff;   /* 8.56 vs black 2.45 */
  --r-identity-5-ink: #000000;   /* 6.09 vs white 3.45 */
  --r-identity-6-ink: #ffffff;   /* 5.34 vs black 3.93 */

  /* accent: interactive things only. The prepared action, the link, the
     focus ring. Never ornament. */
  --r-accent: var(--accent);
  --r-accent-on: var(--accentOn);

  /* surface: elevation replaces borders as the grouping device. */
  --r-surface-base: var(--bg);
  --r-surface-raised: var(--card);
  --r-surface-sunken: var(--track);
  /* surface.inverse is the one role with no existing binding: the dark
     context band of P01 does not exist in the product yet. Derived in
     greyscale from the ink and page tokens rather than inventing a hue,
     pending the palette review. */
  --r-surface-inverse: #14161a;
  --r-ink-on-inverse: #f9f9fa;

  /* ink: figure and answer, supporting sentence, label. ink.faint is
     never used for a figure. */
  --r-ink-primary: var(--text);
  --r-ink-secondary: var(--muted);
  --r-ink-faint: var(--faint);

  /* edge: hairlines and chart axes. Solid at all times - texture carries
     nothing, per R9. */
  --r-edge: var(--border);
}

[data-theme="dark"] {
  /* Dark is a re-binding of the same roles, not a second design. Surface
     and ink swap; severity and identity keep their hue and shift
     lightness to hold contrast. */
  --r-severity-watch-ink: var(--amber);      /* 7.74:1 on the dark wash */
  --r-severity-urgent-ink: var(--rose);      /* 4.72:1 on the dark wash */
  --r-severity-watch-bg: rgba(251, 191, 36, .16);
  --r-severity-urgent-bg: rgba(232, 105, 125, .16);
  --r-surface-inverse: #05070a;
  --r-ink-on-inverse: #eef2f0;

  /* Dark: near-black letters clear 4.5:1 on all six hues (5.32 to 6.93);
     white clears none of them. */
  --r-identity-1-ink: #000000;
  --r-identity-2-ink: #000000;
  --r-identity-3-ink: #000000;
  --r-identity-4-ink: #000000;
  --r-identity-5-ink: #000000;
  --r-identity-6-ink: #000000;
}

/* Figure setting, P13. Kept here rather than in the pattern module so a
   figure typesets identically wherever it is rendered, and so the rule
   survives a pattern being called from an unconverted view. */
.r-figure {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}

.r-figure--column {
  display: block;
  text-align: end;
}

/* The technical name that trails a plain-language sentence. The sentence
   is the answer; this is traceability, per P13 figure.gloss. */
.r-gloss {
  color: var(--r-ink-faint);
  font-size: .82em;
  white-space: nowrap;
}

.r-formula {
  color: var(--r-ink-faint);
  font-size: .82em;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---------------------------------------------- P03. Trust chip */

/* A filled pill on surface.sunken with ink.secondary text. No opacity,
   no hatching, no dash, no grey-out: R2 and UX7 put trust on the chip
   and never on the drawing of the data. */
.r-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--r-surface-sunken);
  color: var(--r-ink-secondary);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
}

/* Only draft and needs-your-review take a severity, and both keep their
   word: the colour is never the only carrier, per R8. */
.r-chip--watch {
  background: var(--r-severity-watch-bg);
  color: var(--r-severity-watch-ink);
}

.r-chip__q {
  color: var(--r-ink-faint);
}

/* ------------------------------------------ P14. Identity token */

/* A solid rounded square with initials, never a bare dot. The letters
   are part of the token, not a fallback: colour is never the only
   carrier of identity. */
.r-ident {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 6px;
  background: var(--r-ident-hue);
  color: var(--r-ident-ink);
  font-weight: 650;
  letter-spacing: .01em;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Group mode reads the word, not a glyph, and the count sits OUTSIDE
   the token in ink.secondary separated by space. It used to read
   "Group . 6 companies" with a middle dot; the dot is retired product
   wide (C40) because it is bidirectionally neutral and resolves
   unstably beside Arabic text. ink.secondary now does the joining work
   the punctuation did. */
.r-ident--group {
  width: auto;
  height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--r-surface-sunken);
  color: var(--r-ink-secondary);
  font-size: 12px;
}

.r-ident__count {
  color: var(--r-ink-secondary);
  white-space: nowrap;
}

.r-ident-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.r-ident__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------- P04. Named absence */

/* Set at answer size in ink.secondary. Not italic, not greyed to the
   edge of legibility, not centred in an empty box. No severity colour:
   an absence is not an alarm. Solid edge only, per R9. */
.r-absence {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--r-edge);
  border-radius: 10px;
  background: var(--r-surface-raised);
  color: var(--r-ink-secondary);
}

.r-absence__subject {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--r-ink-primary);
  font-size: 17px;
  font-weight: 600;
}

.r-absence__reason,
.r-absence__unlock,
.r-absence__value {
  font-size: 13px;
}

.r-absence__value {
  color: var(--r-ink-faint);
}

.r-absence__action {
  margin-top: 6px;
}

.r-absence__lock {
  display: inline-flex;
  color: var(--r-ink-faint);
}

/* ------------------------------------------------------ buttons */

.r-btn {
  padding: 7px 13px;
  border: 1px solid var(--r-edge);
  border-radius: 8px;
  background: var(--r-surface-raised);
  color: var(--r-ink-primary);
  font: inherit;
  font-size: 13px;
}

.r-btn--primary {
  border-color: transparent;
  background: var(--r-accent);
  color: var(--r-accent-on);
}

.r-btn:focus-visible {
  outline: 2px solid var(--r-accent);
  outline-offset: 2px;
}

/* ------------------------------------ P05. Finding explanation */

.r-finding {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.r-finding__headline {
  color: var(--r-ink-primary);
  font-size: 15px;
  font-weight: 600;
}

/* Directly under the headline at body size in ink.primary, never behind
   a disclosure. It is the most persuasive line in the product. */
.r-finding__why {
  color: var(--r-ink-primary);
  font-size: 13.5px;
  line-height: 1.55;
}

.r-finding__confidence {
  color: var(--r-ink-secondary);
  font-size: 12.5px;
}

.r-finding__evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Outlined, label in small caps, value after a SPACE. No severity
   colour: chips are facts, not judgements. The gap IS the separator,
   which is why no character sits between label and value. */
.r-chip-ev {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--r-edge);
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.r-chip-ev__label {
  color: var(--r-ink-secondary);
  font-variant-caps: all-small-caps;
  letter-spacing: .06em;
}

.r-chip-ev__value {
  color: var(--r-ink-primary);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ------------------------------------ P06. Prepared action set */

.r-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Where an owner would expect execution, the limit is stated in the same
   breath as the offer. */
.r-actions__boundary {
  margin-block-start: 6px;
  color: var(--r-ink-secondary);
  font-size: 12px;
  line-height: 1.5;
}

/* ------------------------------------ P12. Completeness readout */

.r-done {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.r-done__subject {
  color: var(--r-ink-primary);
  font-weight: 600;
}

/* The count is the load-bearing part, so it is the one set in the
   figure treatment. */
.r-done__count {
  color: var(--r-ink-primary);
  font-variant-numeric: tabular-nums;
}

.r-done__outstanding {
  color: var(--r-ink-secondary);
  font-size: 13px;
  line-height: 1.55;
}

/* C48. Excluded from the count, and visibly so.
   Quieter than the outstanding line, because it is NOT the owner's to
   act on: it names our unfinished work or a limit of their source. It
   carries no severity role for the same reason - a badge here would ask
   them to fix something they cannot reach. */
.r-done__pending {
  color: var(--r-ink-faint);
  font-size: 13px;
  line-height: 1.55;
  padding-block-start: 2px;
}

.r-done__track {
  block-size: 6px;
  border-radius: 999px;
  background: var(--r-surface-sunken);
  overflow: hidden;
}

.r-done__fill {
  block-size: 100%;
  background: var(--r-severity-watch-ink);
}
