/* ==========================================================================
   Base — reset, typography, accessibility primitives
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar) + var(--s-5));
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  min-height: 100svh;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  letter-spacing: var(--track-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color var(--d-base) var(--e-inout),
              color var(--d-base) var(--e-inout);
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.018em;
  color: var(--ink);
  text-wrap: balance;          /* no orphan headings */
}
h1 { font-size: var(--t-3xl); }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-xl);  }
h4 { font-size: var(--t-lg);  }
p  { text-wrap: pretty; }

a { color: var(--accent-ink); text-underline-offset: .18em; }

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

/* A component's own `display` beats the UA's [hidden] rule on specificity,
   so hiding a grid/flex section needs this to actually take effect. */
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
[disabled] { cursor: not-allowed; }

/* ---- Focus: always visible, never obscured (WCAG 2.2) -------------------- */
:focus { outline: none; }
/* The focus ring is a non-text UI component: WCAG 1.4.11 wants 3:1 against
   whatever sits behind it. --accent (#2dadf2) managed only 2.27-2.51:1 on
   every light surface. --accent-ink is the contrast-checked tone in both
   themes: 5.1:1 on white, 7.4:1 on the dark ground. */
:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* ---- Screen-reader-only, but focusable when it needs to be -------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: var(--s-3); left: var(--s-3); z-index: 200;
  padding: var(--s-3) var(--s-5);
  background: var(--primary); color: var(--on-primary);
  border-radius: var(--r-sm); font-weight: 600; text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--d-base) var(--e-out-expo);
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---- Scrollbars --------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: var(--r-pill);
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: content-box; }

::selection { background: var(--accent); color: #fff; }

/* ---- Global reduced-motion contract -------------------------------------
   Motion is decoration here; every animated element is authored so its
   final state is the resting state, so cutting duration is always safe.   */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
