/* ============================================================================
   kHouse Dossier · Base
   ----------------------------------------------------------------------------
   Reset + element defaults + container + type primitives.
   Reads tokens only — never hardcodes color, spacing, or radius.
   ============================================================================ */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, dl, dd { margin: 0; padding: 0; }
ul, ol { padding-left: 1.2em; }

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--kd-font-sans);
    font-size: var(--kd-text-3);
    line-height: 1.55;
    color: var(--kd-fg);
    background: var(--kd-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background var(--kd-dur) var(--kd-ease), color var(--kd-dur) var(--kd-ease);
}

img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--kd-accent); color: var(--kd-accent-fg); }

:focus-visible {
    outline: 2px solid var(--kd-accent);
    outline-offset: 2px;
    border-radius: var(--kd-radius);
}

/* ---- Container ---- */
.kd-container {
    width: 100%;
    max-width: var(--kd-container);
    margin-inline: auto;
    padding-inline: var(--kd-container-pad);
}

/* ---- Type primitives ----
   These map intent → token. Use these on any element so swaps are global. */
.kd-display   { font-size: var(--kd-text-9); font-weight: var(--kd-w-bold); line-height: 1.05; letter-spacing: var(--kd-track-tight); }
.kd-h1        { font-size: var(--kd-text-8); font-weight: var(--kd-w-bold); line-height: 1.1;  letter-spacing: var(--kd-track-tight); }
.kd-h2        { font-size: var(--kd-text-7); font-weight: var(--kd-w-bold); line-height: 1.15; letter-spacing: var(--kd-track-snug); }
.kd-h3        { font-size: var(--kd-text-6); font-weight: var(--kd-w-semi); line-height: 1.25; letter-spacing: var(--kd-track-snug); }
.kd-h4        { font-size: var(--kd-text-5); font-weight: var(--kd-w-semi); line-height: 1.3; }
.kd-lede      { font-size: var(--kd-text-4); color: var(--kd-fg-soft); line-height: 1.55; }
.kd-body      { font-size: var(--kd-text-3); color: var(--kd-fg); line-height: 1.6; }
.kd-small     { font-size: var(--kd-text-2); color: var(--kd-fg-muted); }

/* Mono micro-label — used for INTEL · COMMS · DOSSIER · refs */
.kd-mono {
    font-family: var(--kd-font-mono);
    font-size: var(--kd-text-1);
    font-weight: var(--kd-w-semi);
    text-transform: uppercase;
    letter-spacing: var(--kd-track-mono);
    color: var(--kd-fg-muted);
}
.kd-mono--xs { font-size: var(--kd-text-0); }
.kd-mono--fg { color: var(--kd-fg); }

/* Section eyebrow — mono label + a thin rule so titles get a consistent header */
.kd-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--kd-s-2);
    margin-bottom: var(--kd-s-3);
}
.kd-eyebrow::before {
    content: '';
    width: 24px;
    height: 1px;
    background: var(--kd-fg-muted);
}

/* Text helpers */
.kd-muted   { color: var(--kd-fg-muted); }
.kd-soft    { color: var(--kd-fg-soft); }
.kd-tabnums { font-variant-numeric: tabular-nums; }

/* ---- Section scaffolding ---- */
.kd-section            { padding-block: var(--kd-pad-section-y); }
.kd-section--alt       { background: var(--kd-bg-alt); }
.kd-section--sunken    { background: var(--kd-bg-sunken); }
.kd-section--bordered  { border-top: var(--kd-border-w) solid var(--kd-border); }

.kd-section__head      { margin-bottom: var(--kd-s-8); }
.kd-section__head--center { text-align: center; max-width: 720px; margin-inline: auto; }
.kd-section__head .kd-h2 { margin-top: var(--kd-s-2); }
.kd-section__head .kd-lede { margin-top: var(--kd-s-3); max-width: 60ch; }

/* Divider */
.kd-rule { border: 0; height: var(--kd-border-w); background: var(--kd-border); margin: 0; }

/* Visually-hidden (for a11y labels) */
.kd-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---- .kd-pn-input: THE control class, defined here (not per-page) ----
   Used to live only in kd-commerce.css, on the theory that the product
   page's buy box and the cart were the only server-rendered inputs this
   site had -- the catalogue's own facet search box (product_list.html)
   is a THIRD, and it rendered with NO min-height/font-size at all
   (kd-commerce.css is not loaded on that page), a real, measured defect
   this platform found live. kd-base.css loads on every page, so this is
   the one place the class's floor can live and actually reach every
   page that uses it -- kd-commerce.css keeps only the pieces genuinely
   specific to the buy box/cart forms (.kd-pn-input--qty, .kd-pn-form-row). */
.kd-pn-input {
    padding: var(--kd-s-2) var(--kd-s-3);
    background: var(--kd-bg-alt);
    border: var(--kd-border-w) solid var(--kd-border);
    border-radius: var(--kd-radius);
    color: var(--kd-fg);
    font-family: var(--kd-font-sans);
    /* 16px FLOOR, deliberately not a token -- iOS Safari zooms the page
     * when a focused input's text is smaller than 16px. --kd-text-2
     * (13px) is free to set the size everywhere else; it is not free to
     * set it below this floor. */
    font-size: max(16px, var(--kd-text-2));
    /* --kd-touch-min, the accessible touch-target minimum -- a thumb,
     * not a mouse, the same floor .kd-pn-qty__step gives its buttons. */
    min-height: var(--kd-touch-min);
    transition: border-color var(--kd-dur) var(--kd-ease);
}
.kd-pn-input:focus-visible { outline: 2px solid var(--kd-accent-ring); border-color: var(--kd-accent); }

/* `.kd-pn-input` also renders as a <select> (the buy box's "Condition"
 * dropdown, commerce/_buy_box.html) -- same chevron kd-forms.css draws
 * for `.kd-form select` on every other kd-* site: an inline data: URI
 * so currentColor follows this theme's foreground into dark mode, no
 * extra request, no wrapper element. */
select.kd-pn-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: var(--kd-s-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--kd-s-4) center;
    background-size: 12px 8px;
    cursor: pointer;
}
