/* ============================================================================
   KLARO PRODUCT FOUNDATION — SPACE, GRID, RESPONSIVE
   Base unit 4px. Vertical rhythm 4px. Comfortable density (R2.4).
   ========================================================================= */
:root{
  --k-unit:4px;
  --k-s-0:0; /* @kind spacing */
  --k-s-1:4px;   --k-s-2:8px;   --k-s-3:12px;  --k-s-4:16px;
  --k-s-5:20px;   --k-s-6:24px;  --k-s-7:28px;  --k-s-8:32px;  --k-s-10:40px;
  --k-s-12:48px;  --k-s-14:56px; --k-s-16:64px; --k-s-20:80px; --k-s-24:96px;
  --k-s-32:128px; --k-s-40:160px;

  /* Vertical rhythm — the record's cadence */
  --k-rhythm:4px;
  --k-stack-tight:8px;      /* label to value */
  --k-stack:16px;           /* paragraph to paragraph */
  --k-stack-loose:24px;     /* sub-section */
  --k-section:48px;         /* section to section */
  --k-section-major:80px;   /* page-level break */

  /* Record rows — Territory A's core rhythm.
     A record row SIZES FROM ITS CONTENT. Marker names run from "TSH" to
     "Vitamin D, 25-OH" to "Alanine aminotransferase (SGPT)"; a fixed height
     either clips the long ones or pads the short ones. Height is an OUTPUT of
     padding + content, never an input. Use .k-row. */
  --k-row-pad-y:14px;       /* the row's vertical padding — this is the knob */
  --k-row-h-touch:56px;     /* min-height floor for a TAPPABLE row */
  --k-row-h-compact:36px;   /* doctor / operational, MOUSE ONLY — below the touch floor by design */

  /* DEPRECATED v1.0 — removed at the next major (§F).
     Replacement: .k-row, or --k-row-pad-y with --k-row-h-touch as a min-height.
     Zero uses at deprecation. Enforced by K003. */
  --k-row-h:60px; /* @kind spacing */
  --k-target-min:44px;      /* touch floor. Never below. */
  --k-target-gap:8px;       /* minimum clear space BETWEEN adjacent targets.
                               A 44px target with a 2px neighbour gap still mis-taps. */
  --k-target-comfortable:56px;  /* seniors, one-handed, primary actions */
  --k-thumb-zone:120px;     /* bottom band of the viewport reachable one-handed.
                               Primary mobile actions live here, never in the header. */

  /* Page gutters, by breakpoint */
  --k-gutter:20px; /* @kind spacing */
  --k-container:100%; /* @kind spacing */
  --k-col-gap:16px;
  --k-cols:4; /* @kind other */

  /* Band and inset padding (Territory A groups with bands, not cards) */
  --k-band-pad:20px;
  --k-inset-pad:16px;
  --k-overlay-pad:24px;

  /* Dense data */
  --k-cell-pad-x:12px;
  --k-cell-pad-y:8px;
  --k-cell-pad-y-compact:6px;

  /* ---- v1.0 · iPhone/Android safe areas. Merged from the v1.0.0 landing
     increment. A sticky bottom action without these sits under the home
     indicator on every notched device. Requires
     <meta name="viewport" content="...,viewport-fit=cover"> on the page. ---- */
  --k-safe-top:env(safe-area-inset-top,0px);
  --k-safe-right:env(safe-area-inset-right,0px);
  --k-safe-bottom:env(safe-area-inset-bottom,0px);
  --k-safe-left:env(safe-area-inset-left,0px);
  --k-sticky-action-pad-bottom:max(var(--k-s-4),var(--k-safe-bottom));
}

/* ---- v1.0 · interactive target floor, enforced rather than documented.
   Icon artwork may be 20-24px; its interactive wrapper still meets 44px.
   :where() keeps specificity at zero so any component can override upward. ---- */
:where(button,a[role="button"],input[type="button"],input[type="submit"],input[type="reset"]){
  min-block-size:var(--k-target-min,44px);
}

@media (min-width:600px){:root{
  --k-gutter:32px; /* @kind spacing */
  --k-cols:8; /* @kind other */
  --k-col-gap:20px;
  --k-container:100%; /* @kind spacing */
}}
@media (min-width:1024px){:root{
  --k-gutter:48px; /* @kind spacing */
  --k-cols:12; /* @kind other */
  --k-col-gap:24px;
  --k-container:960px; /* @kind spacing */
}}
@media (min-width:1440px){:root{
  --k-gutter:64px; /* @kind spacing */
  --k-cols:12; /* @kind other */
  --k-col-gap:24px;
  --k-container:1200px; /* @kind spacing */
}}

/* ---- Border-box floor. DR-07 territory: a rule enforced by memory is not a rule.
   Third recurrence of the same defect — flex:0 0 N + padding silently consumes
   N + padding + border, so authored widths never hold. Global, not per-site. ---- */
*,*::before,*::after{box-sizing:border-box}

.k-container{width:100%;max-width:var(--k-container);margin-inline:auto;padding-inline:var(--k-gutter)}
.k-container--narrow{max-width:720px}
.k-container--record{max-width:880px}
.k-container--wide{max-width:1440px}
.k-grid{display:grid;grid-template-columns:repeat(var(--k-cols),minmax(0,1fr));gap:var(--k-col-gap)}

/* ---- Record row. The replacement for --k-row-h (DR-46).
   Height is an output: padding + content. Long marker names grow the row
   instead of being clipped by it. ---- */
.k-row{display:flex;align-items:center;gap:var(--k-s-3);
  padding-block:var(--k-row-pad-y);border-bottom:1px solid var(--k-border-hairline)}
.k-row--tappable{min-height:var(--k-row-h-touch)}
.k-row--compact{padding-block:var(--k-cell-pad-y-compact);min-height:var(--k-row-h-compact)}

/* Print — A4 with a 180mm live area; Letter falls back cleanly */
@page{size:A4;margin:18mm 15mm 16mm}
@media print{
  :root{
    --k-gutter:0; /* @kind spacing */
    --k-container:180mm; /* @kind spacing */
    --k-cell-pad-y:4px;
  }
  .k-container,.k-container--record,.k-container--narrow{max-width:100%;padding-inline:0}
  .k-page-break{break-before:page}
  .k-no-break{break-inside:avoid}
  thead{display:table-header-group}
  tr{break-inside:avoid}
}
