/* ============================================================================
   KLARO CLINICAL VISUAL LANGUAGE
   The semantic layer for health data. Read strategy/05-clinical-visual-language.md
   for the encoding contract — this file only carries its tokens.

   CHANNEL CONTRACT — one concept per channel, never shared:
     COLOUR      distance from optimal. Nothing else. Never trend, never source.
     MARK        status identity and direction.
     POSITION-X  the value against its ranges.
     POSITION-Y  authority. Measured data sits flush; narrative is indented.
     RULE STYLE  who is speaking. Solid = human. Dashed = synthesised.
     PATTERN     uncertainty. Never severity.
     TYPE        data is tabular; narrative is prose.
     LABEL       always present. Positional vocabulary, never evaluative.
   ========================================================================= */
:root{
  --k-mk-trend-toward:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 4.6 H8.2 V6.9 H3 Z M3 9.1 H13 V11.4 H3 Z M10.2 2.2 L13.6 5.75 L10.2 9.3 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-trend-away:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 4.6 H13 V6.9 H3 Z M3 9.1 H8.2 V11.4 H3 Z M10.2 6.7 L13.6 10.25 L10.2 13.8 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-trend-stable:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.6 6.9 H13.4 V9.1 H2.6 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-trend-none:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.4 6.9 H5.2 V9.1 H2.4 Z M6.6 6.9 H9.4 V9.1 H6.6 Z M10.8 6.9 H13.6 V9.1 H10.8 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-lab:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6.4 1.8 H9.6 V6.2 L13.2 13.1 A1 1 0 0 1 12.3 14.6 H3.7 A1 1 0 0 1 2.8 13.1 L6.4 6.2 Z M7.9 3.3 V6.6 L5.1 12 H10.9 L8.1 6.6 V3.3 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-rule:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.2 3.4 H13.8 V5.2 H2.2 Z M2.2 7.1 H13.8 V8.9 H2.2 Z M2.2 10.8 H9.4 V12.6 H2.2 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-doctor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.6 A3.1 3.1 0 1 1 8 7.8 A3.1 3.1 0 1 1 8 1.6 M8 3.4 A1.3 1.3 0 1 0 8 6 A1.3 1.3 0 1 0 8 3.4 M2.4 14.4 A5.6 5.6 0 0 1 13.6 14.4 H11.8 A3.8 3.8 0 0 0 4.2 14.4 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-ai:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.9 L9.55 5.75 L13.4 7.3 L9.55 8.85 L8 12.7 L6.45 8.85 L2.6 7.3 L6.45 5.75 Z M12.6 11 L13.35 12.85 L15.2 13.6 L13.35 14.35 L12.6 16.2 L11.85 14.35 L10 13.6 L11.85 12.85 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-education:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2.1 L14.6 5.3 L8 8.5 L1.4 5.3 Z M3.6 7.4 V11.2 A5.6 3 0 0 0 12.4 11.2 V7.4 L8 9.6 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */
  --k-mk-src-discuss:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.2 2.8 H13.8 A1 1 0 0 1 14.8 3.8 V10.4 A1 1 0 0 1 13.8 11.4 H6.6 L3.2 14.4 V11.4 H2.2 A1 1 0 0 1 1.2 10.4 V3.8 A1 1 0 0 1 2.2 2.8 M3 4.6 V9.6 H4.9 V11 L6.1 9.6 H13 V4.6 Z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E"); /* @kind other */

  /* Trend is NEVER coloured. "Improving" in green would be a clinical judgement
     Klaro is not permitted to make, and would collide with the status ramp. */
  --k-trend-ink:var(--k-n-700);
  --k-trend-ink-quiet:var(--k-n-500);

  /* Range-track bands are BAND tokens, not surfaces. They are tuned to sit
     under a value mark, so they are darker than the surface tints and will
     fail AA behind --k-text-tertiary. For a tinted card ground use
     --k-st-<state>-bg. See foundation/color.css §1.10. */

  /* Band redundancy. The three band tints sit within ~4% luminance of one another,
     so the zoned track collapses in greyscale and under colour-vision deficiency.
     Outside-reference zones therefore carry a texture as well as a hue, and the
     optimal band carries a boundary tick. Colour is never the only zone signal. */
  --k-band-outside-pattern:repeating-linear-gradient(-45deg,transparent 0 2px,rgba(179,64,44,.28) 2px 3px); /* @kind other */
  --k-band-optimal-edge:1px dashed rgba(23,97,79,.55); /* @kind other */

  /* Uncertainty pattern — missing data, no reference, unreleased.
     Pattern means "we do not know", never "this is bad". */
  --k-hatch:repeating-linear-gradient(45deg,transparent 0 3px,var(--k-n-300) 3px 4px); /* @kind other */
  --k-hatch-dark:repeating-linear-gradient(45deg,transparent 0 3px,var(--k-n-400) 3px 4px); /* @kind other */

  /* Provenance rules. The left rule is the authority signal. */
  --k-prov-doctor-rule:2px solid var(--k-n-900); /* @kind other */
  --k-prov-ai-rule:2px dashed var(--k-n-400); /* @kind other */
  --k-prov-edu-rule:1px solid var(--k-n-300); /* @kind other */
  --k-prov-discuss-rule:2px solid var(--k-brand-teal); /* @kind other */
  --k-prov-indent:16px; /* @kind spacing */

  /* Range-bar geometry */
  --k-bar-h:10px; /* @kind spacing */
  --k-bar-h-sm:6px; /* @kind spacing */
  --k-bar-r:5px; /* @kind radius */
  --k-bar-mark-w:3px; /* @kind spacing */
  --k-bar-mark-halo:var(--k-surface-raised); /* @kind color */ /* separates the value mark from the band beneath it */
  --k-bar-mark-h:18px; /* @kind spacing */
  --k-optimal-tick:1px dashed var(--k-n-500); /* @kind other */
}

/* Uncertainty fill utility */
.k-unknown{background-image:var(--k-hatch);background-color:var(--k-n-50)}

/* Provenance blocks — position and rule style carry the source, not colour. */
.k-prov{padding-left:var(--k-prov-indent);margin-left:2px}
.k-prov--doctor{border-left:var(--k-prov-doctor-rule)}
.k-prov--ai{border-left:var(--k-prov-ai-rule)}
.k-prov--edu{border-left:var(--k-prov-edu-rule)}
.k-prov--discuss{border-left:var(--k-prov-discuss-rule)}
.k-prov__src{display:flex;align-items:center;gap:6px;font-family:var(--k-font-ui);font-size:10.5px;
  font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:var(--k-n-600);margin-bottom:8px}
/* n-700, not n-600: this class is placed on status tints as well as white, and
   n-600 measures only 4.23:1 on --k-st-critical-bg. n-700 clears AA on every
   ground the class can land on. */
.k-prov__attr{font-family:var(--k-font-ui);font-size:11px;line-height:1.5;color:var(--k-n-700);margin-top:10px}

/* Zone redundancy utilities — apply to the outside-reference segments of any range bar. */
.k-band-outside{background-color:var(--k-band-outside);background-image:var(--k-band-outside-pattern)}
.k-band-optimal{background-color:var(--k-band-optimal);box-shadow:inset 1px 0 0 rgba(23,97,79,.45),inset -1px 0 0 rgba(23,97,79,.45)}

/* R9 · Out-of-scale values. A ferritin of 2000 against a 30–400 reference cannot
   sit on the track. The mark pins to the edge, gains a caret, and the axis says so. */
.k-bar-overflow{position:relative}
.k-bar-overflow::after{content:"";position:absolute;top:50%;right:-2px;transform:translateY(-50%);
  border-left:6px solid var(--k-chart-point);border-top:5px solid transparent;border-bottom:5px solid transparent}
.k-bar-overflow--low::after{right:auto;left:-2px;border-left:none;border-right:6px solid var(--k-chart-point)}
