/* KHub base — reset, typography, links, scrollbars, focus, motion.
   Load order: tokens → base → layout → components (17-DESIGN-SYSTEM.md §3). */

/* ---------- Font (local Inter variable, no CDN — §2/§5) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/Inter-var.woff2") format("woff2");
  /* latin + cyrillic subset shipped locally; see fonts/README.md */
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD,
    U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

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

* {
  margin: 0;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  line-height: var(--lh-base);
}

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

svg {
  flex-shrink: 0;
}

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

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

button:disabled {
  cursor: not-allowed;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--fw-semibold);
  /* §5: headings 600, never heavier */
}

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

/* ---------- Typography (§5) ---------- */
html {
  font-family: var(--font-sans);
  font-size: var(--fs-base);   /* 14px base */
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  color: var(--text);
  background-color: var(--bg);
}

h1 {
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
}

h2 {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
}

h3 {
  font-size: var(--fs-md);
  line-height: var(--lh-md);
}

h4,
h5,
h6 {
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

small {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

code {
  font-size: var(--fs-sm); /* §5: ids/keys 13px mono */
}

/* §5: max line length 72 chars */
.prose,
.text-measure {
  max-width: 68ch;
}

/* §5: numbers in tables and metrics use tabular figures */
.tabular-nums,
table,
.num {
  font-variant-numeric: tabular-nums;
}

/* §5: identifiers, keys, ids, cron */
.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ---------- Links ---------- */
a {
  color: var(--accent-600);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--accent-700);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

a:active {
  color: var(--accent-700);
}

/* ---------- Focus-visible (§6.1, §11) ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-100);
  color: var(--text);
}

[data-theme="dark"] ::selection {
  background: var(--accent-700);
  color: var(--text-invert);
}

/* ---------- Scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-subtle);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  transform: translateY(calc(-100% - var(--sp-4)));
  transition: transform var(--dur-fast) var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

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