/* Manrope, вариативный, самохостинг: CSP запрещает внешние шрифты, да и
   лишний RTT на странице входа не нужен. SIL OFL 1.1, см. fonts/LICENSE.txt */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/manrope-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/manrope-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;
}

/* Техническая монохромная схема. Тёмная остаётся стартовой, светлая
   инвертирует поверхности и контраст по сохранённым токенам. */
:root {
  color-scheme: dark light;

  --paper: #0a0a0a;
  --paper-2: #121212;
  --wash: #000000;

  --ink: #f5f5f5;
  --ink-2: #a3a3a3;
  --ink-3: #707070;

  --line: #1f1f1f;
  --line-strong: #2e2e2e;

  /* Акцент монохромный: цветом в этом интерфейсе ничего не сообщается,
     различают заливка против обводки и светлота. Красный оставлен ровно для
     ошибки входа — это статус, а не украшение. */
  --accent: #f5f5f5;
  --accent-2: #ffffff;
  --accent-ink: #000000;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --danger: #e0685e;
  --danger-soft: rgba(224, 104, 94, 0.08);
  --danger-border: rgba(255, 106, 94, 0.32);
  --ok: #e6e6e6;

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --tech: 11px;
  --gap: clamp(20px, 3vw, 40px);
}

html[data-theme='light'] {
  color-scheme: light;

  --paper: #f5f5f5;
  --paper-2: #ededed;
  --wash: #ffffff;

  --ink: #111111;
  --ink-2: #5d5d5d;
  --ink-3: #858585;

  --line: #dedede;
  --line-strong: #bdbdbd;

  --accent: #111111;
  --accent-2: #000000;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 0, 0, 0.08);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --danger-border: rgba(180, 35, 24, 0.32);
  --ok: #222222;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.022em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font: 600 var(--tech) / 1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}
.skip-link:focus {
  top: 12px;
}

/* ── технические подписи ────────────────────────────────────────────── */
.tech {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: var(--tech);
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.tech::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: none;
  background: var(--accent);
}
.tech-plain {
  font-family: var(--mono);
  font-size: var(--tech);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── кнопки ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 0;
  background: none;
  font-family: var(--mono);
  font-size: var(--tech);
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
}

.btn-ghost {
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover {
  border-color: var(--ink);
  background: var(--wash);
}

/* Компактный переключатель языка в шапках страниц. */
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  border: 1px solid var(--line-strong);
  padding: 2px;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.08em;
}
.language-switch button {
  min-width: 30px;
  min-height: 26px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.language-switch button:hover,
.language-switch button.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Компактный переключатель темы: две геометрические иконки вместо emoji,
   чтобы солнечный и лунный состояния одинаково хорошо смотрелись в RU/EN. */
.header-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.theme-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-2);
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.16s ease;
}
.theme-toggle:hover {
  border-color: var(--ink);
  background: var(--accent-soft);
  color: var(--ink);
}
.theme-toggle:active {
  transform: scale(0.92);
}
.theme-icon {
  position: absolute;
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0;
  transform: rotate(-45deg) scale(0.55);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}
.theme-icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}
.theme-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.theme-icon-moon {
  transform: translateY(5px) rotate(28deg) scale(0.55);
}
html[data-theme='light'] .theme-icon-sun {
  opacity: 0;
  transform: rotate(-45deg) scale(0.55);
}
html[data-theme='light'] .theme-icon-moon {
  opacity: 1;
  transform: translateY(0) rotate(0) scale(1);
  color: var(--ink);
}

/* Theme colors settle before the new page is captured. Normal hover
   transitions resume immediately; the sun/moon keeps its own motion. */
html.theme-committing,
html.theme-committing *:not(.theme-icon),
html.theme-committing *::before,
html.theme-committing *::after {
  transition: none !important;
}

/* The old page stays underneath while the real new theme grows from the
   toggle. Disable the browser's default crossfade and snapshot blending. */
html.theme-transitioning::view-transition {
  pointer-events: none;
}
html.theme-transitioning::view-transition-group(root) {
  animation: none;
}
html.theme-transitioning::view-transition-image-pair(root) {
  isolation: isolate;
}
html.theme-transitioning::view-transition-old(root),
html.theme-transitioning::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
html.theme-transitioning::view-transition-old(root) {
  z-index: 1;
}
html.theme-transitioning::view-transition-new(root) {
  z-index: 2;
  animation: theme-reveal 0.58s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--theme-x) var(--theme-y)); }
  to { clip-path: circle(var(--theme-radius) at var(--theme-x) var(--theme-y)); }
}

/* ── спиннер ────────────────────────────────────────────────────────── */
.spinner {
  width: 12px;
  height: 12px;
  flex: none;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.btn-spinner {
  display: none;
}
.btn[data-busy='true'] .btn-spinner {
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spinner {
    animation: none;
    border-top-color: currentColor;
    opacity: 0.35;
  }
}
