/* =============================================================================
   Base — reset, typography, icons, utilities, responsive grid.
   ============================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  scroll-padding-top: calc(var(--topbar-h) + var(--s-4));
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

html.is-locked, html.is-locked body { overflow: hidden; }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4 { font-weight: var(--fw-semibold); line-height: var(--lh-tight); letter-spacing: -0.011em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; border-spacing: 0; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
pre { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
[hidden] { display: none !important; }
summary { cursor: pointer; }

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-xs); }

/* Scrollbars: thin and quiet */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Icons from core/icons.js (stroke set) */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 28px; height: 28px; stroke-width: 1.5; }

/* Typography helpers */
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num, .tabular { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: var(--fw-semibold); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.link { color: var(--accent-fg); text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.tone-neutral { color: var(--neutral); }
.tone-info { color: var(--info); }
.tone-success { color: var(--success); }
.tone-warning { color: var(--warning); }
.tone-danger { color: var(--danger); }
.tone-accent { color: var(--accent-fg); }
.tone-muted { color: var(--muted); }

/* Flow helpers */
.stack { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.stack--sm { gap: var(--s-2); }
.stack--lg { gap: var(--s-6); }
.row { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }
.spacer { flex: 1 1 auto; }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--s-4) 0; }

/* Responsive 12/6/1 column grid */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.grid > * { min-width: 0; }
@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .grid > * { grid-column: span 6; }
  .grid > .span-3 { grid-column: span 3; }
  .grid > .span-4 { grid-column: span 6; }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-5); }
  .grid > * { grid-column: span 12; }
  .grid > .span-3 { grid-column: span 3; }
  .grid > .span-4 { grid-column: span 4; }
  .grid > .span-6 { grid-column: span 6; }
  .grid > .span-8 { grid-column: span 8; }
  .grid > .span-12 { grid-column: span 12; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
