/* ==========================================================================
   Base — reset, typography, accessibility primitives
   ========================================================================== */

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

* { margin: 0; }

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }

/* Default box for inline icons. An SVG with no width/height attributes fills
   its container, so icons dropped into a plain wrapper need a floor. Any
   context rule (.btn svg, .icon-tile svg, …) is more specific and overrides it. */
.ic { width: 20px; height: 20px; flex: none; }

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: 0; padding: 0; cursor: pointer; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

table { border-collapse: collapse; width: 100%; }

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

/* ---- Headings --------------------------------------------------------- */

h1, h2, h3, h4, h5 {
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--fw-bold);
  color: var(--text);
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
h4 { font-size: var(--fs-h4); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }

p { text-wrap: pretty; }

/* ---- Text utilities --------------------------------------------------- */

.display     { font-size: var(--fs-display); font-weight: var(--fw-extra); line-height: 1.04; letter-spacing: -.03em; }
.text-2      { color: var(--text-2); }
.text-3      { color: var(--text-3); }
.text-sm     { font-size: var(--fs-sm); }
.text-xs     { font-size: var(--fs-xs); }
.text-lg     { font-size: var(--fs-lg); }
.fw-medium   { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }
.lead        { font-size: var(--fs-lg); color: var(--text-2); line-height: 1.65; }
.tabular     { font-variant-numeric: tabular-nums; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.eyebrow {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-2);
}

.gradient-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Layout utilities ------------------------------------------------- */

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1; min-width: 0; }
.center  { display: flex; align-items: center; justify-content: center; }

.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }

.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }

/* 12-column grid */
.grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

/* ---- Accessibility ---------------------------------------------------- */

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

/* Programmatic focus targets (route changes move focus to #main for screen
   readers). They must not paint a focus ring around the whole region. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible { outline: none; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: var(--z-toast);
  background: var(--brand-primary);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--t-base) var(--ease);
}
.skip-link:focus { top: var(--s-4); text-decoration: none; }

[hidden] { display: none !important; }

/* Honour the OS reduced-motion setting across every animation in the app */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Forced-colors / high-contrast: keep structure legible without our palette */
@media (forced-colors: active) {
  .card, .btn, .input { border: 1px solid CanvasText; }
}

/* ---- Scrollbars ------------------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

::selection { background: var(--brand-200); color: var(--brand-900); }
