/* ============================================================================
   KLARO PRODUCT FOUNDATION — COLOUR
   Territory A "The Clear Record". One token foundation, four expressions.
   Brand tokens (tokens/colors.css) are unchanged and still own marketing.
   These --k- tokens own the product, operational and print expressions.

   HEALTHCARE RULE ENFORCED HERE:
   Health status and system feedback use SEPARATE, non-interchangeable ramps.
   Health status is a desaturated clinical ramp (pine / ochre / clay).
   System feedback is the bright brand palette (teal / blue / coral).
   A failed payment must never look like a raised liver enzyme.
   ========================================================================= */
:root{
  /* ---- 1.1 Primary brand (inherited, unchanged) ---- */
  --k-brand-teal:#36A089;          /* @kind color */
  --k-brand-blue:#4880BE;          /* @kind color */
  --k-brand-coral:#EF5745;         /* @kind color */
  --k-brand-yellow:#FBD854;        /* @kind color */

  /* ---- 1.2 Accessible text-safe variants (AAA on white, >=7:1) ----
     Brand values above are FILL-ONLY below 18px. These are their text twins. */
  --k-teal-text:#17614F;           /* 7.45:1 @kind color */
  --k-blue-text:#2C5C8A;           /* 7.12:1 @kind color */
  --k-coral-text:#A8301B;          /* 7.28:1 @kind color */

  /* ---- 1.3 Neutral scale ----
     TEXT-LEGAL FLOOR IS --k-n-600 (5.9:1 on white). n-500 and below are for
     borders, fills, disabled states and decoration ONLY. Never a text colour.
     Prefer the --k-text-* aliases below over a raw step — reaching into the
     scale for "a quieter grey" is how AA failures get shipped. */
  --k-n-0:#FFFFFF;                 /* @kind color */
  --k-n-25:#FBFCFD;                /* @kind color */
  --k-n-50:#F5F8FA;                /* @kind color */
  --k-n-100:#EDF1F4;               /* @kind color */
  --k-n-200:#DFE6EB;               /* @kind color */
  --k-n-300:#C6D0D8;               /* @kind color */
  --k-n-400:#9CAAB4;               /* @kind color */
  --k-n-500:#78888F;               /* @kind color */
  --k-n-600:#5A6B76;               /* 5.9:1  @kind color */
  --k-n-700:#41535F;               /* 8.6:1  @kind color */
  --k-n-800:#263947;               /* 11.9:1 @kind color */
  --k-n-900:#16283A;               /* 15.0:1 @kind color */
  --k-n-950:#0C1922;               /* @kind color */

  /* ---- 1.4 Surfaces ---- */
  --k-surface-page:var(--k-n-0);
  --k-surface-sunken:var(--k-n-50);
  --k-surface-raised:var(--k-n-0);
  --k-surface-band:var(--k-n-50);        /* tinted grouping band, replaces cards */
  --k-surface-inset:var(--k-n-100);      /* inputs, code, table zebra */
  --k-surface-overlay:var(--k-n-0);      /* sheets, menus, dialogs */
  --k-surface-scrim:rgba(12,25,34,.55);
  --k-surface-inverse:var(--k-n-900);
  --k-surface-brand:var(--k-brand-teal);       /* text-free surfaces only */
  --k-surface-brand-text:#267865;              /* brand surface that carries white text @kind color */

  /* Tint grounds. NOT status — these carry do/don't panels, callouts and the
     DoDontCard, where the tint is rhetorical framing, not a clinical state.
     The product namespace had no tint surface at all, so every exploration
     reached across to the legacy marketing --surface-tint-* and any file that
     did not load the marketing sheet rendered transparent. Added deliberately
     rather than aliased, so there is one product answer. */
  /* Klaro Yellow is a FILL, never a text colour. Measured against every brand
     ground it clears 4.5:1 only against navy — teal 2.30, deck gradient 3.01–4.96,
     white 1.40. There is deliberately no --k-brand-yellow-text: a yellow dark
     enough to carry small text on teal is olive, and is no longer the brand
     colour. Use the pair below, in either direction. */
  --k-yellow-fill:var(--k-brand-yellow);  /* ground */
  --k-yellow-on:#16283A;                  /* the only ink legal on it — 10.76:1 @kind color */

  --k-surface-tint-teal:#E7F2EF;  /* @kind color */
  --k-surface-tint-coral:#FCE7E4; /* @kind color */

  /* ---- 1.5 Text ---- */
  --k-text-primary:var(--k-n-900);
  --k-text-secondary:var(--k-n-700);
  --k-text-tertiary:var(--k-n-600);
  --k-text-disabled:var(--k-n-400);      /* inactive components only — WCAG 1.4.3 exempt */
  --k-text-placeholder:var(--k-n-600);   /* empty-value dashes, input placeholders */
  --k-text-inverse:var(--k-n-0);
  --k-text-inverse-secondary:rgba(255,255,255,.82);
  --k-text-link:var(--k-teal-text);
  --k-text-link-hover:#0F4A3B;
  --k-text-numeric:var(--k-n-900);

  /* ---- 1.6 Borders and rules ---- */
  --k-border-hairline:var(--k-n-200);    /* the Territory A workhorse */
  --k-border-default:var(--k-n-300);
  --k-border-strong:var(--k-n-400);
  --k-border-inverse:rgba(255,255,255,.24);
  --k-border-rule-heavy:var(--k-n-900);  /* section rules, table head underline */

  /* ---- 1.7 Interactive ---- */
  /* Brand teal (#36A089) is 3.21:1 under white text and CANNOT carry a label.
     The action ramp is its darkened, AA-safe form. Brand teal stays the fill
     for logo, marks and text-free surfaces. */
  --k-action-fg:var(--k-n-0);
  --k-action-bg:#267865;        /* 5.31:1 white @kind color */
  --k-action-bg-hover:#216B5B;  /* 6.24:1 white @kind color */
  --k-action-bg-active:#1B5B4D; /* 7.78:1 white @kind color */
  --k-action-bg-disabled:var(--k-n-200);
  --k-action-fg-disabled:var(--k-n-400);
  --k-action-quiet-fg:var(--k-teal-text);
  --k-action-quiet-bg-hover:var(--k-n-100);
  --k-action-danger-bg:#B42318;        /* destructive UI only; not brand coral or health */
  --k-action-danger-bg-hover:#912018;
  --k-action-danger-bg-active:#7A1C14;
  --k-selected-bg:#E8F2EF;
  --k-selected-border:var(--k-brand-teal);

  /* ---- 1.8 Focus — one value, never removed ---- */
  --k-focus-ring:#0B6FD6;                /* @kind color */
  --k-focus-ring-offset:var(--k-n-0);
  --k-focus-width:2px; /* @kind spacing */
  --k-focus-offset:2px; /* @kind spacing */
  --k-focus-shadow:0 0 0 var(--k-focus-offset) var(--k-focus-ring-offset),0 0 0 calc(var(--k-focus-offset) + var(--k-focus-width)) var(--k-focus-ring); /* @kind shadow */

  /* Text on a coloured fill (action ramp, status fill, brand panel). Named so
     that "white text on a filled thing" is a token, not a literal. Found by
     DR-07: 21 separate #fff literals were all standing in for this. */
  --k-text-on-fill:#FFFFFF;
  --k-text-on-dark:var(--k-n-900);

  /* ---- 1.9 SYSTEM FEEDBACK — bright, brand-derived. NOT health status. ---- */
  --k-sys-info-fg:var(--k-blue-text);
  --k-sys-info-bg:#E8F0F8;
  --k-sys-info-mark:var(--k-brand-blue);
  --k-sys-success-fg:var(--k-teal-text);
  --k-sys-success-bg:#E6F2EE;
  --k-sys-success-mark:var(--k-brand-teal);
  --k-sys-warning-fg:#7A4F00;
  --k-sys-warning-bg:#FCF3DC;
  --k-sys-warning-mark:var(--k-brand-yellow);
  --k-sys-error-fg:var(--k-coral-text);
  --k-sys-error-bg:#FBE9E6;
  --k-sys-error-mark:var(--k-brand-coral);

  /* ---- 1.10 HEALTH STATUS — desaturated clinical ramp. Six states. ----
     Colour encodes DISTANCE FROM OPTIMAL, never moral valence.
     DIRECTION (low vs high) is encoded by glyph and track position, never hue:
     "below optimal" and "above optimal" are the SAME ochre by design.
     Every state ships: -fill (>=3:1, marks and bands), -text (>=7:1, AAA),
     -bg (tint), -glyph (non-colour redundancy), -label (mandatory word).

     SCOPE (DR-29, ratified 10 Aug 2026). These are the defined treatments for
     BIOMARKER STATUS. They are internally consistent and must stay so. They are
     NOT a global reservation: the underlying brand colours remain available to
     any other appropriate context where the meaning reads, contrast passes, and
     colour is not the sole carrier. A genuine same-screen collision is resolved
     in the product design that creates it, not predicted here.

     Founder vocabulary maps to these tokens as:
       Optimal              -> --k-st-optimal-*
       Suboptimal           -> --k-st-offoptimal-*   (with -low / -high glyphs)
       Deficient / out of range -> --k-st-outofrange-* (with -low / -high glyphs)
       (critical, pending, no-reference retained for cases the three-tier
        vocabulary does not cover) */

  --k-st-optimal-fill:#2A8C74;     /* @kind color */
  --k-st-optimal-text:#135445;     /* @kind color */ /* 8.81:1 white · 7.68:1 on own tint */
  --k-st-optimal-bg:#E6F2EE;
  --k-st-optimal-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 8m-3.2 0a3.2 3.2 0 1 0 6.4 0a3.2 3.2 0 1 0-6.4 0' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */

  --k-st-offoptimal-fill:#B07A12;  /* @kind color */
  --k-st-offoptimal-text:#6B4500;  /* @kind color */ /* 8.40:1 white · 7.54:1 on own tint */
  --k-st-offoptimal-bg:#FBF2DE;
  --k-st-offoptimal-glyph-low:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 13.2 L2.8 4.4 L13.2 4.4 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */
  --k-st-offoptimal-glyph-high:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2.8 L13.2 11.6 L2.8 11.6 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */

  --k-st-outofrange-fill:#B3402C;  /* @kind color */
  --k-st-outofrange-text:#8A2A17;  /* @kind color */ /* 8.67:1 white · 7.25:1 on own tint */
  --k-st-outofrange-bg:#F9E7E3;
  --k-st-outofrange-glyph-low:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 14.3 L3 8.1 L13 8.1 Z M8 8.2 L3 2 L13 2 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */
  --k-st-outofrange-glyph-high:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.7 L13 7.9 L3 7.9 Z M8 7.8 L13 14 L3 14 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */

  --k-st-critical-fill:#7F1D10;    /* @kind color */
  --k-st-critical-text:#6E1608;    /* @kind color */
  --k-st-critical-bg:#F4DCD8;
  --k-st-critical-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.9 2.9 H13.1 V13.1 H2.9 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */

  /* Process states — neutral by rule. A pending result is not a health finding. */
  --k-st-pending-fill:var(--k-n-600);   /* 4.81:1 on n-100 */
  --k-st-pending-text:var(--k-n-700);
  --k-st-pending-bg:var(--k-n-100);
  --k-st-pending-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.4a4.6 4.6 0 1 0 0 9.2a4.6 4.6 0 1 0 0-9.2 M8 5.2a2.8 2.8 0 1 1 0 5.6a2.8 2.8 0 1 1 0-5.6' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */
  --k-st-noref-fill:var(--k-n-500);     /* 3.24:1 on n-100 */
  --k-st-noref-text:var(--k-n-700);
  --k-st-noref-bg:var(--k-n-50);
  --k-st-noref-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.8 6.7 H13.2 V9.3 H2.8 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */
  --k-st-rejected-fill:var(--k-n-700);  /* 7.1:1 on n-100 */
  --k-st-rejected-text:var(--k-n-700);
  --k-st-rejected-bg:var(--k-n-100);
  --k-st-rejected-glyph:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.1 2.7 L13.3 11.9 L11.9 13.3 L2.7 4.1 Z M11.9 2.7 L13.3 4.1 L4.1 13.3 L2.7 11.9 Z' fill='%23000'/%3E%3C/svg%3E"); /* @kind other */

    /* Mark sizing — one optical size for every state. Severity is carried by
     the drawn ink area, not by the box. */
  /* Fallback for an unresolved --mark. A slashed hollow box is unmistakably
     "no such token" — without it, mask-image:none paints an unmasked rectangle,
     which is indistinguishable from Critical's reserved square. That exact
     silent failure has shipped three times in this project. */
  --k-mark-missing:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 1.5 H14.5 V14.5 H1.5 Z M3.5 3.5 V12.5 H12.5 V3.5 Z M4.4 3.2 L12.8 11.6 L11.6 12.8 L3.2 4.4 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mark-xs:11px; /* @kind spacing */
  --k-mark-sm:14px; /* @kind spacing */
  --k-mark:18px; /* @kind spacing */
  --k-mark-lg:24px; /* @kind spacing */

  /* Range-track bands — deliberately paler than the value mark, so the mark wins */
  --k-band-optimal:#CFE6DE;
  --k-band-reference:#E8EEF1;
  --k-band-outside:#F2E0DB;
  --k-band-track:var(--k-n-100);

  /* ---- 1.11 Chart / data ----
     Territory A charts are ink-first. Series colour is used only when a chart
     genuinely carries 2+ series. Ordered for deuteranopia/protanopia safety. */
  --k-chart-ink:var(--k-n-900);
  --k-chart-ink-soft:var(--k-n-400);
  --k-chart-grid:var(--k-n-200);
  --k-chart-baseline:var(--k-n-300);
  --k-chart-band:#EEF3F6;
  --k-chart-point:var(--k-n-900);
  --k-chart-1:#16283A;             /* @kind color */
  --k-chart-2:#2A8C74;             /* @kind color */
  --k-chart-3:#B07A12;             /* @kind color */
  --k-chart-4:#4880BE;             /* @kind color */
  --k-chart-5:#8E5BA6;             /* @kind color */
  --k-chart-6:#7A8B94;             /* @kind color */
}

/* ---- 1.12 Dark mode — authored, not shipped (R4.6 is light-only).
   Kept current so the option stays open. Enable by adding data-theme="dark". */
[data-theme="dark"]{
  --k-n-0:#0C1922;--k-n-25:#101F29;--k-n-50:#142430;--k-n-100:#1B2E3B;
  --k-n-200:#243B4A;--k-n-300:#33505F;--k-n-400:#5B7686;--k-n-500:#7E97A4;
  --k-n-600:#9DB2BC;--k-n-700:#BDCCD4;--k-n-800:#DAE4E9;--k-n-900:#EEF4F7;--k-n-950:#FFFFFF;
  --k-surface-page:#0C1922;--k-surface-sunken:#101F29;--k-surface-raised:#142430;
  --k-surface-band:#142430;--k-surface-inset:#1B2E3B;--k-surface-overlay:#1B2E3B;
  --k-surface-scrim:rgba(0,0,0,.68);--k-surface-inverse:#EEF4F7;
  --k-surface-tint-teal:#16332C;--k-surface-tint-coral:#38211D;
  --k-text-primary:#EEF4F7;--k-text-secondary:#BDCCD4;--k-text-tertiary:#9DB2BC;
  --k-text-inverse:#0C1922;--k-text-link:#5FCBAE;--k-text-link-hover:#84DCC4;
  --k-teal-text:#5FCBAE;--k-blue-text:#8FBEEA;--k-coral-text:#FF9583;
  --k-focus-ring:#63B3F7;--k-focus-ring-offset:#0C1922;
  --k-st-optimal-fill:#4FBF9F;--k-st-optimal-text:#7FD9BF;--k-st-optimal-bg:#12332B;
  --k-st-offoptimal-fill:#D9A63C;--k-st-offoptimal-text:#EFC776;--k-st-offoptimal-bg:#33280F;
  --k-st-outofrange-fill:#E06A52;--k-st-outofrange-text:#F0947F;--k-st-outofrange-bg:#37170F;
  --k-st-critical-fill:#C4442C;--k-st-critical-text:#E8705A;--k-st-critical-bg:#40120A;
  --k-band-optimal:#1B4B3E;--k-band-reference:#1B2E3B;--k-band-outside:#3A211B;
  --k-chart-ink:#EEF4F7;--k-chart-grid:#243B4A;--k-chart-1:#EEF4F7;--k-chart-2:#4FBF9F;
}

/* ---- 1.10b Status mark utility ----
   Renders a --k-st-*-glyph as a masked shape in a status fill colour.
   Font-independent by design: the mark is the primary non-colour signal, so it
   must not depend on OS glyph fallback (WCAG 1.4.11, and the PDF).

     <span class="k-mark" style="--mark:var(--k-st-critical-glyph);
                                 --mark-color:var(--k-st-critical-fill)"></span>
   Always accompanied by the status word. Never the sole carrier of meaning. */
.k-mark{display:inline-block;width:var(--k-mark);height:var(--k-mark);flex:0 0 var(--k-mark);
  background-color:var(--mark-color,currentColor);
  -webkit-mask-image:var(--mark,var(--k-mark-missing));mask-image:var(--mark,var(--k-mark-missing));
  -webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;
  -webkit-mask-position:center;mask-position:center;
  -webkit-mask-size:contain;mask-size:contain;vertical-align:middle}
.k-mark--sm{width:var(--k-mark-sm);height:var(--k-mark-sm);flex-basis:var(--k-mark-sm)}
.k-mark--lg{width:var(--k-mark-lg);height:var(--k-mark-lg);flex-basis:var(--k-mark-lg)}
/* xs — for marks set inside a chip or badge, where the label carries the meaning
   and the mark is confirmation. Use the modifier; never redefine --k-mark-* inline. */
.k-mark--xs{width:var(--k-mark-xs);height:var(--k-mark-xs);flex-basis:var(--k-mark-xs)}
