/* ===== токены ===== */
:root {
  --font: "Roboto Flex", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wide: 128%;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --r: 12px;
  --r-lg: 20px;
  --r-xl: 28px;
  --maxw: 1320px;
  --gutter: clamp(16px, 2.6vw, 32px);
  --hdr-h: 68px;
  --accent: #0071e3;
  --accent-ink: #fff;
  --ok: #22a05a;
  --warn: #e0a100;
  --bad: #e5484d;
  interpolate-size: allow-keywords;
}

/* Производные от акцента пересчитываются там, где акцент меняется */
:root, .accent-scope {
  --accent-hi: color-mix(in srgb, var(--accent) 45%, #fff);
  --accent-lo: color-mix(in srgb, var(--accent) 62%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 50%, transparent);
}

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --card: #f4f4f5;
  --card-2: #ffffff;
  --ink: #0a0a0b;
  --ink-2: #3a3a3c;
  --ink-3: #6e6e73;
  --ink-4: #8e8e93;
  --line: #e4e4e7;
  --line-2: #d1d1d6;
  --glass: rgb(255 255 255 / .74);
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 12px 32px -12px rgb(0 0 0 / .12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --card: #161618;
  --card-2: #0a0a0b;
  --ink: #f5f5f7;
  --ink-2: #d1d1d6;
  --ink-3: #a1a1a6;
  --ink-4: #6e6e73;
  --line: #2a2a2e;
  --line-2: #3a3a3f;
  --glass: rgb(10 10 11 / .72);
  --shadow: 0 1px 2px rgb(0 0 0 / .6), 0 12px 32px -12px rgb(0 0 0 / .7);
}

/* ===== база ===== */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--hdr-h) + 16px);
}

html.is-inertia-scrolling { scroll-behavior: auto; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  animation: page-in .7s var(--ease) backwards;
}

@keyframes page-in { from { opacity: 0; } }

h1, h2, h3, h4, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }

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

.display {
  font-stretch: var(--wide);
  font-weight: 560;
  letter-spacing: -0.035em;
  line-height: 1.02;
  text-wrap: balance;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  font-stretch: 100%;
}

.card {
  background: var(--card);
  border-radius: var(--r-xl);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ===== логотип ===== */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 620;
  font-stretch: var(--wide);
  letter-spacing: -0.03em;
  font-size: 17px;
}

/* имя в логотипе строчными, как заголовки сайта; в тексте и заголовке вкладки — «Кодверк» */
.logo > span, .hdr__logo > span { text-transform: lowercase; }

.logo__mark { width: 28px; height: 28px; flex: none; }
.logo__mark rect { fill: var(--accent); transition: fill .5s var(--ease); }
.logo__mark path { fill: none; stroke: var(--accent-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ===== кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform .25s var(--ease), background-color .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease), box-shadow .4s var(--ease), opacity .3s;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--accent:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 86%, #000);
  box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn--ghost { background: var(--card-2); color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover:not(:disabled) { border-color: var(--ink); }

.btn--lg { height: 52px; padding: 0 22px; font-size: 15px; }
.btn--sm { height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--ink);
  transition: border-color .3s, background-color .3s, transform .25s var(--ease);
}

.icon-btn:hover { border-color: var(--line-2); }
.icon-btn:active { transform: scale(.94); }

/* иконки внутри svg-спрайтов */
.i-sun, .i-moon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.i-moon { fill: currentColor; stroke: none; }
.i-tg { fill: currentColor; }
.i-arrow { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* в светлой теме показываем луну (переключить на тёмную), в тёмной — солнце */
[data-theme-toggle] .i-sun { display: none; }
[data-theme="dark"] [data-theme-toggle] .i-sun { display: block; }
[data-theme="dark"] [data-theme-toggle] .i-moon { display: none; }

/* ===== плавная смена темы ===== */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color .5s var(--ease), color .5s var(--ease), border-color .5s var(--ease), fill .5s var(--ease) !important;
}

/* ===== появление при скролле ===== */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
  transition-delay: var(--d, 0ms);
}

.js .reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
