/* ==========================================================================
   Reset + primitives
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'ss01';
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-family: var(--font-display);
    color: var(--ink-strong);
    font-weight: 700;
    letter-spacing: -.018em;
    line-height: 1.2;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--brand-hover); }

img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

ul, ol { margin: 0; padding: 0; list-style: none; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }

code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection { background: var(--brand-soft); color: var(--ink-strong); }

/* Scrollbars — thin and unobtrusive, matching the surface ramp. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border: 3px solid transparent;
    border-radius: var(--r-full);
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: content-box; }

/* ── Layout primitives ─────────────────────────────────────────────────── */

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-6); }

.stack     { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm  { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-lg  { display: flex; flex-direction: column; gap: var(--sp-6); }

.row       { display: flex; align-items: center; gap: var(--sp-3); }
.row-sm    { display: flex; align-items: center; gap: var(--sp-2); }
.row-wrap  { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-end   { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.spacer { flex: 1 1 auto; }
.hidden { display: none !important; }

/* ── Type helpers ──────────────────────────────────────────────────────── */

.t-2xs { font-size: var(--text-2xs); }
.t-xs  { font-size: var(--text-xs); }
.t-sm  { font-size: var(--text-sm); }
.t-lg  { font-size: var(--text-lg); }
.t-xl  { font-size: var(--text-xl); }

.t-muted  { color: var(--ink-muted); }
.t-faint  { color: var(--ink-faint); }
.t-strong { color: var(--ink-strong); }
.t-ok     { color: var(--ok); }
.t-warn   { color: var(--warn); }
.t-danger { color: var(--danger); }
.t-brand  { color: var(--brand); }

.t-medium { font-weight: 500; }
.t-semi   { font-weight: 600; }
.t-bold   { font-weight: 700; }
.t-mono   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.t-num    { font-variant-numeric: tabular-nums; }
.t-upper  { text-transform: uppercase; letter-spacing: .07em; }
.t-center { text-align: center; }
.t-right  { text-align: right; }
.t-nowrap { white-space: nowrap; }

.t-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.t-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .container { padding-inline: var(--sp-4); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    h1 { font-size: var(--text-2xl); }
}
