/* 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(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--fs-0);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: 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-accent); }

/* links */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--line-strong);
  transition: color var(--t-fast) var(--ease), text-decoration-color var(--t-fast) var(--ease);
}
a:hover {
  color: var(--accent-ink);
  text-decoration-color: currentColor;
}

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

/* headings */
h1, h2, h3 { font-weight: 500; line-height: 1.15; }
h1 {
  font-size: var(--fs-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.02;
}
h2 {
  font-size: var(--fs-1);
  letter-spacing: -0.01em;
}
.lead { font-size: var(--fs-1); line-height: 1.45; max-width: 34ch; }
p { max-width: var(--measure); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

/* utilities */
.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: absolute;
  left: var(--s-4);
  top: var(--s-2);
  z-index: 10;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

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

main { flex: 1 0 auto; }

.page {
  display: grid;
  gap: var(--s-8);
  padding-block: var(--s-7) var(--s-9);
}
.page__aside { display: grid; gap: var(--s-6); align-content: start; }
.page__main { display: grid; gap: var(--s-8); align-content: start; min-width: 0; }

.section { display: grid; gap: var(--s-4); }
.section > h2 { margin-bottom: var(--s-1); }

@media (min-width: 600px) {
  .page { padding-block: var(--s-8) var(--s-9); }
}

/* one column, wider margins on tablets */
@media (min-width: 600px) and (max-width: 1023px) {
  .page__aside, .page__main { max-width: 44rem; }
}

/* asymmetric two columns: ~5/12 sticky left, ~7/12 right */
@media (min-width: 1024px) {
  .page {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: clamp(48px, 6vw, 112px);
    padding-block: var(--s-9) var(--s-10);
    align-items: start;
  }
  .page__aside {
    position: sticky;
    top: var(--s-7);
  }
}

/* ultra-wide: container stays capped (see --container), type grows only via clamp ceilings */
@media (min-width: 1800px) {
  :root { --gutter: 64px; }
}

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

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
