/* Shared components. Requires tokens.css. Class names are flat and prefixed by component. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text-body)/var(--leading-body) var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent-ink);
}
::selection { background: var(--accent); color: var(--accent-ink); }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-small); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:active { transform: none; }
}

/* Type */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}
.display { font-size: var(--text-display); line-height: var(--leading-tight); letter-spacing: -0.025em; }
h1 { font-size: var(--text-h1); line-height: 1.08; }
h2 { font-size: var(--text-h2); line-height: var(--leading-heading); }
h3 { font-size: var(--text-h3); line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; text-wrap: pretty; }
.lead { font-size: var(--text-lead); line-height: 1.5; color: var(--ink-2); }
.meta { font-size: var(--text-meta); color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums lining-nums; }
a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; text-decoration-color: var(--line-strong); transition: text-decoration-color 0.15s ease; }
a:hover { text-decoration-color: currentColor; }

.icon { width: 1.125em; height: 1.125em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Buttons: pills. Primary is ink, secondary is outlined. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 1.375rem;
  border: 1px solid var(--ink); border-radius: var(--r-pill);
  background: var(--ink); color: var(--paper);
  font: 500 var(--text-small)/1 var(--font-text);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.14s var(--ease-out);
}
.btn:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { border-radius: var(--r-pill); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--sunk); border-color: var(--ink); }
.btn--small { min-height: 2.5rem; padding: 0 1.125rem; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--sunk); border-color: var(--line); color: var(--ink-3); cursor: not-allowed; }
.link-arrow { font-weight: 500; }
.link-arrow .icon { display: inline-block; vertical-align: -0.18em; margin-left: 0.25em; transition: transform 0.2s var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .link-arrow:hover .icon { transform: translateX(3px); } }

/* Cards: hairline border, no shadow. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--card-pad); }
.card--sunk { background: var(--sunk); border-color: transparent; }
.card--accent { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.card--accent .lead, .card--accent .meta { color: var(--accent-ink); }
.card--accent a { text-decoration-color: currentColor; }

/* Status chips. Icon + text always; color is the third signal, never the only one. */
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.625rem 0.25rem 0.5rem; border-radius: var(--r-pill);
  font: 500 var(--text-meta)/1.2 var(--font-text); white-space: nowrap;
  background: var(--sunk); color: var(--ink-2);
}
.chip--overdue { background: var(--overdue-bg); color: var(--overdue-ink); }
.chip--soon { background: var(--soon-bg); color: var(--soon-ink); }
.chip--ontrack { background: var(--ontrack-bg); color: var(--ontrack-ink); }
.chip--imminent { background: var(--imminent-bg); color: var(--imminent-ink); }
.tag { display: inline-block; padding: 0.125rem 0.5rem; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: var(--text-meta); color: var(--ink-2); background: var(--surface); }

/* Form fields */
.field { display: grid; gap: var(--s-2); }
.field > label, .field > legend { font-weight: 500; font-size: var(--text-small); }
.field .hint { font-size: var(--text-meta); color: var(--ink-3); }
.field .error { font-size: var(--text-meta); color: var(--overdue-ink); display: flex; gap: 0.375rem; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--s-4);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
  font: 400 var(--text-body)/1.4 var(--font-text);
  transition: border-color 0.15s ease;
}
.textarea { padding-block: var(--s-3); min-height: 7rem; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--ink); border-radius: var(--r-control); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--overdue-ink); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.check { display: flex; gap: var(--s-3); align-items: flex-start; }
.check input { width: 1.25rem; height: 1.25rem; margin: 0.2rem 0 0; accent-color: var(--ink); flex: none; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
.table caption { text-align: left; padding-bottom: var(--s-3); color: var(--ink-3); font-size: var(--text-meta); }
.table th, .table td { padding: var(--row-pad) var(--s-4); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-weight: 500; color: var(--ink-2); font-size: var(--text-meta); border-bottom-color: var(--line-strong); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .num, .table th.num { text-align: right; }
/* position: relative keeps absolutely positioned .sr-only labels inside the scroll area, so they cannot widen the page. */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: var(--card-pad); }
.table-wrap .table th:last-child, .table-wrap .table td:last-child { padding-right: var(--card-pad); }

/* Callout: a notice inside content. Full tint, leading icon. */
.callout { display: flex; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--r-inner); background: var(--sunk); color: var(--ink-2); font-size: var(--text-small); }
.callout .icon { margin-top: 0.2em; }
.callout--imminent { background: var(--imminent-bg); color: var(--imminent-ink); }

/* Definition rows: label left, value right, hairline between. Used for ledgers, fact lists, audit lines. */
.rows { margin: 0; padding: 0; list-style: none; }
.rows > * { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); padding: var(--row-pad) 0; border-bottom: 1px solid var(--line); }
.rows > *:last-child { border-bottom: 0; }
.rows dt, .rows .k { color: var(--ink-2); }
.rows dd, .rows .v { margin: 0; text-align: right; }

/* Stat: a number with its label. For app dashboards; use sparingly on www. */
.stat { display: grid; gap: var(--s-1); }
.stat__value { font: 400 2.25rem/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums lining-nums; }
.stat__label { font-size: var(--text-small); color: var(--ink-2); }

/* Case board: columns by stage. */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s-3); }
.board__col { background: var(--sunk); border-radius: var(--r-inner); padding: var(--s-3); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); align-content: start; }
.board__head { display: flex; justify-content: space-between; font-size: var(--text-meta); font-weight: 500; color: var(--ink-2); padding: 0 var(--s-1); }
.board__card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-small); padding: var(--s-2) var(--s-3); font-size: var(--text-meta); display: grid; gap: 0.25rem; }
.board__card b { font-weight: 500; font-variant-numeric: tabular-nums; }
