/* ══════════════════════════════════════════════════════════════════════
   THE LEDGER — Stage 4 refinement
   ══════════════════════════════════════════════════════════════════════

   WHAT "PREMIUM" MEANS FOR THIS PRODUCT, BECAUSE IT IS NOT GLOSS.

   The design direction is "immutable, inspectable records". A children's
   home manager opens this at 2am after an incident, and an inspector reads
   it across a table while the registered manager watches. Neither is
   impressed by gradients, and both are reassured by the same things that
   make a well-set legal document reassuring: consistent rhythm, confident
   typography, hairline rules, numbers that line up, and nothing moving
   that does not need to.

   So this file adds almost no colour and no ornament. It fixes the four
   things that were actually making the product look unfinished:

     1. NO SPACING RHYTHM — eight ad-hoc paddings, so nothing aligned.
     2. FLAT TYPOGRAPHIC HIERARCHY — a big bold h1 and then everything
        else at 14px, so no page had a shape.
     3. DEFAULT BOOTSTRAP TABLES — in a product whose entire job is
        records, the table was the least considered thing on the screen.
     4. NO INTERACTION FEEDBACK — nothing responded to a cursor, which
        reads as unfinished even when nobody could say why.

   Loaded after app.css and before the component stylesheets, so a
   component that needs something different still wins.
   ══════════════════════════════════════════════════════════════════════ */


/* ══ 1. RHYTHM ═════════════════════════════════════════════════════════
   The frame, set from the scale rather than from whatever looked right. */

.content {
    padding: var(--kc-space-6) var(--kc-space-6) var(--kc-space-7);
    max-width: var(--kc-content-max-w);
    margin-inline: auto;
}

@media (max-width: 767px) {
    .content { padding: var(--kc-space-4) var(--kc-space-4) var(--kc-space-6); }
}

/* Consecutive blocks get one gap, not the sum of a margin-bottom and a
   margin-top — which is the other half of why nothing lined up. */
.content > * + * { margin-top: var(--kc-space-5); }
.content > h1 + p, .content > h2 + p { margin-top: var(--kc-space-2); }


/* ══ 2. TYPOGRAPHY ═════════════════════════════════════════════════════

   The hierarchy was: 2rem bold, then 14px for everything else. A page
   with two sizes has no shape, and a reader cannot tell a section from a
   caption without reading both.

   Large text gets NEGATIVE letter-spacing because at display sizes the
   default tracking of a UI typeface looks loose; small text gets slightly
   positive, because at 12px it looks cramped. This is the single change
   that most makes type look professionally set rather than defaulted. */

h1, .h1 {
    font-family: var(--kc-font-heading);
    font-weight: var(--kc-weight-heading);
    font-size: clamp(1.625rem, 1.3rem + 1.1vw, 2.125rem);
    line-height: var(--kc-leading-tight);
    letter-spacing: -0.021em;
    color: var(--kc-ink);
    margin-bottom: var(--kc-space-2);
}

h2, .h2 {
    font-size: var(--kc-text-xl);
    line-height: var(--kc-leading-snug);
    letter-spacing: -0.014em;
    font-weight: var(--kc-weight-heading);
    color: var(--kc-ink);
}

h3, .h3, h4, .h4 {
    font-size: var(--kc-text-lg);
    line-height: var(--kc-leading-snug);
    letter-spacing: -0.008em;
    font-weight: var(--kc-weight-heading);
    color: var(--kc-ink);
}

h5, .h5, h6, .h6 {
    font-size: var(--kc-text-base);
    line-height: var(--kc-leading-snug);
    letter-spacing: -0.004em;
    font-weight: var(--kc-weight-heading);
    color: var(--kc-ink);
}

/* THE BASE TYPEFACE, RECLAIMED. Found by measuring the running product
   rather than reading the CSS: headings were rendering in Inter and every
   paragraph, label and table cell in Helvetica Neue.

   `app.css` is still the stock Blazor template file, and it claims
   `html, body { font-family: 'Helvetica Neue', Helvetica, Arial }`. Stage 1
   self-hosted Inter and defined --kc-font-body, Stage 4 set tracking and
   leading on `body` -- but nothing ever set font-family on it, so the
   template's rule was never displaced. The fonts were loading and going
   unused for body text.

   This is not cosmetic. Every letter-spacing value in this file was chosen
   for Inter's metrics and was being applied to a different typeface. And
   the tabular-figures rule below -- the one thing that most makes a records
   product read as professional -- was a no-op, because Helvetica and Arial
   have no tnum feature to enable. Stage 4's headline claim was untrue in
   the running product until this line existed. */
body {
    font-family: var(--kc-font-body);
    line-height: var(--kc-leading);
    letter-spacing: -0.002em;
    color: var(--kc-ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* PROSE IS CAPPED AT A READABLE MEASURE. Explanatory text was running the
   full width of a 1440px screen, which is roughly 180 characters — the eye
   loses the line on the way back and the reader skips it. Much of this
   product's most important writing is in these paragraphs. */
.content > p,
.profile-muted,
.audit-stamp,
.lead { max-width: var(--kc-measure); }

/* The muted class was doing two jobs — quiet body text and fine print —
   at one size. Fine print is now smaller as well as quieter, so the two
   are distinguishable at a glance. */
.audit-stamp {
    font-size: var(--kc-text-sm);
    line-height: var(--kc-leading);
    color: var(--kc-slate);
}

/* NUMBERS AND DATES LINE UP IN COLUMNS. Proportional digits in a table of
   dates make every row a slightly different width, which is the detail
   that makes a records product look amateur to anybody who reads tables
   for a living — which is who reads this one. */
td, th, .kc-numeric, time, code {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

code, .font-monospace {
    font-family: var(--kc-font-mono);
    font-size: 0.9em;
    letter-spacing: -0.01em;
}


/* ══ 3. TABLES — the product itself ════════════════════════════════════

   Everything KingCare does ends up in one of these: an evidence journey,
   an inspection pack, a reconciliation, a child's records. They were
   default Bootstrap.

   The treatment is a financial-statement one rather than a dashboard one:
   small caps column labels, hairline rules, generous cells, no vertical
   borders, no zebra striping. Striping is a crutch for rows too tight to
   track; fix the row height instead and the table reads cleanly AND
   prints cleanly, which matters because these get printed. */

.table {
    --bs-table-bg: transparent;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
    font-size: var(--kc-text-sm);
    line-height: var(--kc-leading-snug);
}

/* BOOTSTRAP'S OWN CELL SELECTOR HAS TO BE MATCHED, not out-specified by
   accident. `.table > :not(caption) > * > *` sets .5rem on every cell, and
   a plainer `.table th` loses to it — which is why the first version of
   this file produced a beautifully labelled table with cramped rows.
   Row height is most of what makes a long table readable. */
.table > :not(caption) > * > th,
.table > :not(caption) > * > td {
    padding: var(--kc-space-3);
}

.table > thead > tr > th {
    font-family: var(--kc-font-body);
    font-size: var(--kc-text-xs);
    font-weight: var(--kc-weight-body-medium);
    letter-spacing: 0.055em;
    text-transform: uppercase;
    color: var(--kc-slate);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--kc-ink);
    white-space: nowrap;
    vertical-align: bottom;
}

.table > tbody > tr > td {
    border: none;
    border-bottom: 1px solid var(--kc-card-border);
    vertical-align: top;
    color: var(--kc-ink);
}

/* The last rule would otherwise double with the container's own edge. */
.table > tbody > tr:last-child > td { border-bottom: none; }

/* A row responds to the cursor. In a table of forty children, the row the
   mouse is on is the one piece of state the reader needs and the browser
   does not give for free. */
.table > tbody > tr {
    transition: background-color var(--kc-duration) var(--kc-ease);
}
.table > tbody > tr:hover > td { background: var(--kc-paper); }

/* Scrollable tables keep their header in view. A reconciliation of three
   hundred rows is unreadable once the column names have scrolled away. */
.table-responsive { border-radius: var(--kc-radius); }
.table-responsive > .table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--kc-card-bg);
}


/* ══ 4. SURFACES ═══════════════════════════════════════════════════════

   Hairline borders and no resting shadow. A card that floats by default
   has nothing left to say when something actually needs attention. */

.card, .profile-card {
    background: var(--kc-card-bg);
    border: 1px solid var(--kc-card-border);
    border-radius: var(--kc-radius);
    box-shadow: var(--kc-shadow-sm);
    /* Bootstrap's .card sets color: var(--bs-body-color), which is #212529 --
       a neutral near-black. Measured in the running product: body text was
       --kc-ink (#1A2E2A, very slightly green) and every card's text was
       Bootstrap's grey, so the two were a shade apart everywhere a card sat
       on the page. Small, and in a product that is almost entirely cards it
       is the difference between one ink and two. */
    color: var(--kc-ink);
}

.card-body { padding: var(--kc-space-5); }

.card-header, .profile-card-header {
    background: transparent;
    border-bottom: 1px solid var(--kc-card-border);
    padding: var(--kc-space-3) var(--kc-space-5);
    font-weight: var(--kc-weight-heading);
    letter-spacing: -0.006em;
}

.card-footer { background: transparent; padding: var(--kc-space-3) var(--kc-space-5); }


/* ══ 5. CONTROLS ═══════════════════════════════════════════════════════

   One height, one radius, one transition. Previously every page defined
   its own button in its own stylesheet, which is why no two pages had
   buttons the same size. */

.btn, .btn-action, .btn-action-outline, .btn-draft, .btn-draft-quiet {
    border-radius: var(--kc-radius);
    font-family: var(--kc-font-body);
    font-size: var(--kc-text-sm);
    font-weight: var(--kc-weight-body-medium);
    letter-spacing: -0.004em;
    line-height: 1.4;
    padding: var(--kc-space-2) var(--kc-space-4);
    transition:
        background-color var(--kc-duration) var(--kc-ease),
        border-color var(--kc-duration) var(--kc-ease),
        transform var(--kc-duration) var(--kc-ease);
}

/* A 1px drop on press. Almost imperceptible and the thing that makes a
   control feel physical rather than painted on. */
.btn:active:not(:disabled),
.btn-action:active:not(:disabled),
.btn-action-outline:active:not(:disabled) { transform: translateY(1px); }

.btn-action, .btn-primary {
    background: var(--kc-action-primary);
    border: 1px solid var(--kc-action-primary);
    color: var(--kc-on-primary);
}
.btn-action:hover:not(:disabled), .btn-primary:hover:not(:disabled) {
    background: var(--kc-action-primary-hover);
    border-color: var(--kc-action-primary-hover);
}

.btn-action-outline {
    background: transparent;
    border: 1px solid var(--kc-card-border);
    color: var(--kc-action-primary);
}
.btn-action-outline:hover:not(:disabled) {
    background: var(--kc-sage);
    border-color: var(--kc-action-primary);
    color: var(--kc-action-primary);
}

/* Inputs: one height, and a focus state that is a ring rather than a
   colour change, so it is visible to somebody who does not see the
   colour. 9.4's focus-visible rules handle keyboard focus. */
.form-control, .form-select {
    border: 1px solid var(--kc-card-border);
    border-radius: var(--kc-radius);
    padding: var(--kc-space-2) var(--kc-space-3);
    font-family: var(--kc-font-body);
    font-size: var(--kc-text-sm);
    line-height: 1.5;
    color: var(--kc-ink);
    background-color: var(--kc-card-bg);
    transition:
        border-color var(--kc-duration) var(--kc-ease),
        box-shadow var(--kc-duration) var(--kc-ease);
}

.form-control:focus, .form-select:focus {
    border-color: var(--kc-action-primary);
    box-shadow: 0 0 0 3px rgba(47, 93, 80, 0.14);
    outline: none;
}

.form-control::placeholder { color: var(--kc-slate); opacity: 0.75; }

.form-label {
    font-size: var(--kc-text-sm);
    font-weight: var(--kc-weight-body-medium);
    color: var(--kc-ink);
    margin-bottom: var(--kc-space-1);
    letter-spacing: -0.004em;
}

.form-text {
    font-size: var(--kc-text-xs);
    color: var(--kc-slate);
    max-width: var(--kc-measure-tight);
}


/* ══ 6. THE FRAME ══════════════════════════════════════════════════════ */

.topbar {
    border-bottom: 1px solid var(--kc-topbar-border);
    padding-inline: var(--kc-space-5);
}

.nav-rail { border-right: 1px solid rgba(255, 255, 255, 0.08); }

/* Navigation items respond, and the active one is marked by a rule rather
   than by colour alone — so it survives forced-colours mode and is legible
   to somebody who does not distinguish the active tint. */
.nav-rail .nav-link {
    border-radius: var(--kc-radius);
    transition:
        background-color var(--kc-duration) var(--kc-ease),
        color var(--kc-duration) var(--kc-ease);
}

.breadcrumb {
    font-size: var(--kc-text-sm);
    margin-bottom: var(--kc-space-4);
}
.breadcrumb a { color: var(--kc-slate); text-decoration: none; }
.breadcrumb a:hover { color: var(--kc-action-primary); text-decoration: underline; }


/* Sections separate themselves wherever they are nested, which the
   .content > * + * rule cannot reach — most pages wrap their sections in a
   container, and the result was headings running into the block above. */
section + section,
.content section { margin-top: var(--kc-space-6); }

section > h2:first-child,
section > h3:first-child { margin-bottom: var(--kc-space-2); }


/* ══ 7. EMPTY STATES ═══════════════════════════════════════════════════

   This product has a great many of them on purpose — 8.5's manifest, 8.6's
   radar, the evidence journey all say "there is nothing here and that is a
   fact about the period, not a verdict". The writing was already careful;
   the presentation was a grey sentence floating in white space, which
   reads as a page that failed to load.

   A rule and a measure make it read as a considered statement. */
section > .profile-muted:last-child,
.kc-empty {
    display: block;
    max-width: var(--kc-measure);
    padding: var(--kc-space-4) 0 var(--kc-space-4) var(--kc-space-4);
    border-left: 2px solid var(--kc-card-border);
    color: var(--kc-slate);
}


/* ══ 8. PRINT ══════════════════════════════════════════════════════════

   These records get printed and put in front of inspectors, and the
   default print output had a navigation rail down the side of every page. */
@media print {
    .nav-rail, .topbar, .nav-scrim, .presentation-panel,
    .btn, .btn-action, .btn-action-outline { display: none !important; }

    .content { max-width: none; padding: 0; }
    .card { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
    .table > thead > tr > th { border-bottom: 1.5px solid #000; }

    /* A table split across pages repeats its header. */
    thead { display: table-header-group; }
    tr { break-inside: avoid; }
}
