/* Foundation layer: fonts, material, reset, and reusable primitives.
   Loaded AFTER tokens.brand.css + tokens.product.css and BEFORE app.css.
   Values come only from var(--token); no literal hex/radius here. */

/* --- Fonts (self-hosted, English/Latin subset) --- */
@font-face {
  font-family: "Onest Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-latin-wght-normal.d5c8e706f54e.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.79936b18df9f.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-500-normal.b1c8a895f5fd.woff2") format("woff2");
}

/* --- Base document typography (owns html/body; app.css must not redeclare) --- */
html {
  background: var(--paper);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Onest Variable", "Onest", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

/* --- Paper texture: one fixed, pointer-events-none overlay (no scroll repaint) --- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: url("textures/notebook-paper.648c51d93dc8.webp") center / 560px repeat;
  mix-blend-mode: multiply;
  opacity: var(--texture-opacity);
}
:root[data-theme="dark"] body::before {
  mix-blend-mode: soft-light;
  filter: grayscale(1) invert(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before {
    mix-blend-mode: soft-light;
    filter: grayscale(1) invert(1);
  }
}

/* --- Accessibility / focus primitive --- */
.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;
}
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
::selection { background: var(--blue-soft); color: var(--ink); }

/* --- Typography scale primitive --- */
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

/* --- Button primitive (9px radius, never a full pill) --- */
.button {
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font: inherit;
  font-weight: 620;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}
.button:active { transform: translateY(1px) scale(.985); }
.button-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.button-primary { background: var(--blue-strong); color: var(--paper-solid); border-color: var(--blue-strong); }
.button-primary:hover { background: var(--blue); border-color: var(--blue); transform: translateY(-1px); }

/* --- Form-control focus primitive --- */
input, textarea, select { font: inherit; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--blue);
}
