/* Base: reset, typography, layout primitives, language switch */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--sheet);
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}
html.menu-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--fs-body);
  letter-spacing: -0.01em;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  overflow-x: clip;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; letter-spacing: inherit; }

/* language: RU is the default; JS (or the head snippet) sets data-lang */
html[data-lang="ru"] [data-l="en"],
html[data-lang="en"] [data-l="ru"] { display: none !important; }

::selection { background: var(--accent); color: var(--on-paper); }

a { color: inherit; text-decoration: none; }
p a, .quiet a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--dim);
  transition: text-decoration-color var(--t-fast) var(--ease);
}
p a:hover, .quiet a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 { font-weight: 400; }
p { max-width: var(--measure); }
.ital { font-family: var(--font-serif); font-style: italic; font-weight: 300; letter-spacing: var(--tracking); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }

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

.skip-link {
  position: fixed;
  left: var(--s-4);
  top: var(--s-2);
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--paper);
  color: var(--on-paper);
  border-radius: var(--r-pill);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

html:not(.js) .js-only { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

[hidden] { display: none !important; }
