/* Base layer. Colors via tokens.css only. */

/* --- Fonts: self-hosted variable woff2 (OFL) --- */
@font-face {
  font-family: 'Unbounded';
  font-weight: 200 900;
  font-display: swap;
  src: url('../fonts/unbounded-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Unbounded';
  font-weight: 200 900;
  font-display: swap;
  src: url('../fonts/unbounded-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Onest';
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/onest-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest';
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/onest-latin.woff2') format('woff2');
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

html {
  /* Anchors land 1px under the sticky header */
  scroll-padding-top: calc(var(--header-h) - 1px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* smooth only after load (nav.js): deep links land instantly */
@media (prefers-reduced-motion: no-preference) {
  html.smooth-scroll { scroll-behavior: smooth; }
}

body {
  min-height: 100vh;
  background: var(--c-paper);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  /* only 12+ letter words may hyphenate; shorter ones wrap whole */
  hyphenate-limit-chars: 12 5 5;
}
h1 { font-size: var(--fs-display); font-weight: 800; line-height: .95; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-h2); font-weight: 800; line-height: 1; letter-spacing: -0.025em; }
h3 { font-size: var(--fs-h3); line-height: 1.1; }
h4, h5, h6 { font-size: var(--fs-body); line-height: 1.1; }

p { max-width: 70ch; text-wrap: pretty; }


a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }

::selection { background: var(--c-green); color: var(--c-ink); }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* --section-pad: above and below the content; --section-pad-top: where it starts */
.section {
  --section-pad: clamp(64px, 10vw, 160px);
  --section-pad-top: var(--section-pad);
  padding-block: var(--section-pad);
  /* A jump skips the top padding, capped by --section-h (nav.js) */
  scroll-margin-top: calc(-1 * min(var(--section-pad-top) - var(--s-5) - 1px, max(0px, var(--section-h, 9999px) - (100lvh - var(--header-h) + 1px))));
}
/* Paper after paper: one padding, a hairline between */
.section--paper + .section--paper { padding-top: 0; --section-pad-top: clamp(48px, 7vw, 112px); }
.section--paper + .section--paper > .container {
  padding-top: var(--section-pad-top);
  background: linear-gradient(color-mix(in srgb, var(--c-ink) 18%, transparent) 0 0) top / calc(100% - 2 * var(--gutter)) 1px no-repeat;
}

/* Surfaces set their colors and the roles components read */
.section--paper {
  --surface: var(--c-paper);
  --on-surface: var(--c-ink);
  --fg-muted: var(--c-muted);
  --ring: var(--c-ink);
  background: var(--surface);
  color: var(--on-surface);
}
.section--ink {
  --surface: var(--c-ink);
  --on-surface: var(--c-paper);
  --fg-muted: var(--c-muted-on-ink);
  --ring: var(--c-paper);
  background: var(--surface);
  color: var(--on-surface);
}
.section--green {
  --surface: var(--c-green);
  --on-surface: var(--c-ink);
  --fg-muted: var(--c-ink-2);
  --ring: var(--c-ink);
  background: var(--surface);
  color: var(--on-surface);
}
.section--green ::selection { background: var(--c-ink); color: var(--c-paper); }

/* --- Utilities --- */
.visually-hidden {
  position: absolute !important;
  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;
}
.nowrap { white-space: nowrap; }

.skip-link {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: calc(var(--z-modal) + 1);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  background: var(--c-ink);
  color: var(--c-paper);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(calc(-100% - var(--s-6)));
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: none; }


.lead { font-size: var(--fs-lead); line-height: 1.45; max-width: 56ch; }

.footnote { font-size: var(--fs-small); line-height: 1.5; color: var(--fg-muted); }

.fn-ref {
  position: relative;
  font-family: var(--font-label);
  font-size: .7em;
  font-variant-numeric: tabular-nums;
  line-height: 0;
  vertical-align: super;
  padding-inline: 1px;
  text-decoration: none;
}
.fn-ref::after { /* 44×44 hit area without moving the line box */
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
@media (hover: hover) {
  .fn-ref:hover { text-decoration: underline; }
}

/* --- Scroll reveal (reveal.js arms html.reveal-ready) --- */
.reveal-ready [data-reveal]:not(.is-revealed) { opacity: 0; transform: translateY(16px); }
.reveal-ready [data-reveal].is-revealing { transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
/* 40ms stagger per row of 4 */
.reveal-ready [data-reveal].is-revealing:nth-child(4n+2) { transition-delay: 40ms; }
.reveal-ready [data-reveal].is-revealing:nth-child(4n+3) { transition-delay: 80ms; }
.reveal-ready [data-reveal].is-revealing:nth-child(4n+4) { transition-delay: 120ms; }

/* --- Reduced motion: everything in its final state --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print --- */
@media print {
  html, body,
  .section--paper, .section--ink, .section--green {
    background: var(--c-white) !important;
    color: var(--c-ink) !important;
  }
  header, [class*="header"] { position: static !important; }
  .skip-link { display: none !important; }
  a[href^="http"]::after { content: ' (' attr(href) ')'; font-size: .85em; }
  h1, h2, h3 { break-after: avoid; }
  p { orphans: 3; widows: 3; }
}
