/* ===================================================================
   DH-Media — light/dark themes, IBM Plex stack, smooth quint-easing
   =================================================================== */

:root {
  /* light theme by default — переопределяется ниже для dark */
  --bg: #ffffff;
  --bg-elev: #f8fafc;
  --bg-muted: #f1f5f9;
  --text: #0f172a;
  --text-strong: #050811;
  --text-muted: #475569;
  --text-faint: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0b5fff;
  --accent-hover: #0040d6;
  --accent-soft: #dbe7ff;

  --legal-bg: linear-gradient(0deg, rgba(255,255,255,0.96) 0%, rgba(255,255,255,0.6) 100%);
  --fade-top: linear-gradient(180deg, var(--bg) 0%, rgba(255,255,255,0.85) 35%, transparent 100%);
  --fade-bottom: linear-gradient(0deg, var(--bg) 0%, rgba(255,255,255,0.85) 35%, transparent 100%);

  /* ui/заголовки — Space Grotesk (характерный гротеск); body статей — Inter */
  --display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

/* ручной выбор темы перебивает media-query */
[data-theme="dark"] {
  --bg: #0a1628;
  --bg-elev: #0f1d33;
  --bg-muted: #112236;
  --text: #e6ebf5;
  --text-strong: #ffffff;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --border: #1e293b;
  --border-strong: #334155;
  --accent: #4d8aff;
  --accent-hover: #82a8ff;
  --accent-soft: #1e2a4f;

  --legal-bg: linear-gradient(0deg, rgba(10,22,40,0.95) 0%, rgba(10,22,40,0.6) 100%);
  --fade-top: linear-gradient(180deg, var(--bg) 0%, rgba(10,22,40,0.85) 35%, transparent 100%);
  --fade-bottom: linear-gradient(0deg, var(--bg) 0%, rgba(10,22,40,0.85) 35%, transparent 100%);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0a1628;
    --bg-elev: #0f1d33;
    --bg-muted: #112236;
    --text: #e6ebf5;
    --text-strong: #ffffff;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --border: #1e293b;
    --border-strong: #334155;
    --accent: #4d8aff;
    --accent-hover: #82a8ff;
    --accent-soft: #1e2a4f;
    --legal-bg: linear-gradient(0deg, rgba(10,22,40,0.95) 0%, rgba(10,22,40,0.6) 100%);
    --fade-top: linear-gradient(180deg, var(--bg) 0%, rgba(10,22,40,0.85) 35%, transparent 100%);
    --fade-bottom: linear-gradient(0deg, var(--bg) 0%, rgba(10,22,40,0.85) 35%, transparent 100%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--display);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 200ms var(--ease-out-quint), color 200ms var(--ease-out-quint);
}
a { color: var(--accent); text-decoration: none; transition: color 200ms var(--ease-out-quint); }
a:hover { color: var(--accent-hover); }
img, picture, svg { display: block; max-width: 100%; height: auto; }
::selection { background: var(--accent); color: #ffffff; }

/* ===================================================================
   topbar
   =================================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 18px 28px;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0;
  color: var(--text-strong);
  text-decoration: none;
  text-transform: none;
}
.brand:hover { color: var(--text-strong); }
.brand__mark { display: block; border-radius: 6px; }
.brand__name { display: inline-flex; align-items: center; }
.brand__dot {
  display: inline-block;
  margin: 0 1px;
  color: var(--accent);
  font-weight: 700;
  transform: translateY(-1px);
}
.brand--small { font-size: 0.75rem; gap: 8px; }
.brand--small .brand__mark { width: 22px; height: 22px; border-radius: 5px; }

.topbar__hint {
  color: var(--text-faint);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.back-link {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.back-link:hover { color: var(--text-strong); }

/* кнопка переключения темы */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms var(--ease-out-quint);
}
.theme-toggle:hover { color: var(--text-strong); border-color: var(--border-strong); }
.theme-toggle svg { width: 14px; height: 14px; }
/* показываем солнце в тёмной, луну в светлой */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ===================================================================
   home: barrel
   =================================================================== */
body.home {
  overflow: hidden;
  height: 100dvh;            /* dvh — учёт мобильных URL bars */
  height: 100vh;
}

.barrel {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.barrel__list {
  list-style: none;
  margin: 0; padding: 0;
  position: relative;
  width: min(94vw, 1200px);
  height: 100%;
}

.barrel__item {
  position: absolute;
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 0 24px;
  will-change: transform, opacity, filter;
}

.barrel__link {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--text-strong);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  max-width: 100%;
  transition: color 240ms var(--ease-out-quint);
}
.barrel__item.is-center .barrel__link { color: var(--text-strong); }
.barrel__item.is-center .barrel__link:hover { color: var(--accent-hover); cursor: pointer; }
.barrel__item:not(.is-center) .barrel__link { pointer-events: none; cursor: default; }

.barrel__fade {
  position: fixed; left: 0; right: 0;
  height: 38vh;
  pointer-events: none;
  z-index: 5;
}
.barrel__fade--top    { top: 0;    background: var(--fade-top); }
.barrel__fade--bottom { bottom: 0; background: var(--fade-bottom); }

.empty {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  height: 100vh; padding: 24px;
  text-align: center;
  font-family: var(--display);
}
.empty h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin: 0 0 12px;
  font-weight: 500; letter-spacing: -0.01em;
  color: var(--text-strong);
}
.empty p { color: var(--text-muted); max-width: 50ch; margin: 0; }

/* ===================================================================
   article page
   =================================================================== */
body.article-page { background: var(--bg); }
.article-page .topbar {
  position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.preview-banner {
  position: sticky; top: 60px; z-index: 40;
  background: var(--accent); color: #fff;
  padding: 8px 16px; text-align: center;
  font-family: var(--display);
  font-size: 0.75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
}

.article {
  max-width: 720px;
  margin: 56px auto;
  padding: 0 24px;
  font-family: var(--sans);
}
.article__title {
  font-family: var(--display);
  font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--text-strong);
}
.article__dek {
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 24px;
  font-weight: 400;
}
.article__meta {
  font-family: var(--display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.article__hero { margin: 0 -24px 32px; border-radius: 12px; overflow: hidden; background: var(--bg-muted); }
.article__hero img { width: 100%; height: auto; max-height: 520px; object-fit: cover; }

.article__body {
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
}
.article__body > * + * { margin-top: 1.2em; }
.article__body p { margin: 0; }
.article__body p + p { margin-top: 1.2em; }
.article__body strong { color: var(--text-strong); font-weight: 600; }
.article__body em { color: var(--text-strong); }
.article__body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.article__body h2 {
  font-family: var(--display);
  font-size: 1.5rem; font-weight: 500;
  letter-spacing: -0.02em; line-height: 1.2;
  color: var(--text-strong);
  margin: 2.2em 0 0.5em;
}
.article__body h3 {
  font-family: var(--display);
  font-size: 1.1875rem; font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  margin: 1.8em 0 0.4em;
}
.article__body blockquote {
  margin: 1.6em 0; padding: 0 0 0 20px;
  border-left: 2px solid var(--accent);
  color: var(--text-strong);
  font-size: 1.1875rem; line-height: 1.45;
}
.article__body ul, .article__body ol { margin: 1em 0; padding-left: 1.4em; }
.article__body li::marker { color: var(--accent); }
.article__body code {
  font-family: var(--display);
  font-size: 0.9em;
  background: var(--bg-muted);
  padding: 2px 6px; border-radius: 4px;
}

.article__tags { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--display); }
.tag {
  display: inline-block; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); font-size: 0.75rem;
}

.article-nav {
  max-width: 720px; margin: 56px auto 80px;
  padding: 0 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  font-family: var(--display);
}
.article-nav__link {
  display: flex; flex-direction: column;
  padding: 16px; border-radius: 8px;
  border: 1px solid var(--border);
  color: inherit;
  transition: border-color 240ms var(--ease-out-quint);
}
.article-nav__link:hover { border-color: var(--accent); color: inherit; }
.article-nav__link--next { text-align: right; }
.article-nav__label { color: var(--text-faint); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.article-nav__title { color: var(--text-strong); font-weight: 500; line-height: 1.3; font-size: 0.9375rem; }

/* ===================================================================
   legal footer (на главной)
   =================================================================== */
.legal {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  font-family: var(--display);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  background: var(--legal-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
.legal__col { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legal__col--center { justify-self: center; text-align: center; }
.legal__col--right { justify-self: end; }
.legal a { color: var(--text-muted); text-decoration: none; transition: color 200ms var(--ease-out-quint); }
.legal a:hover { color: var(--text-strong); }
.legal__age {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--text-faint);
  border-radius: 4px;
  font-size: 0.625rem;
  letter-spacing: 0;
}

/* ===================================================================
   адаптация под вертикальный мобильный экран
   =================================================================== */
@media (max-width: 800px) {
  .topbar { padding: 14px 16px; gap: 8px; }
  .topbar__hint { display: none; }    /* hint только для desktop */
  .brand__name { font-size: 0.75rem; }

  .legal {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 16px 14px;
    text-align: center;
    font-size: 0.625rem;
  }
  .legal__col, .legal__col--center, .legal__col--right { justify-self: center; }
  .legal__col--center { display: none; }   /* центральный слоган скрыт на мобиле */
  .legal__col--right { gap: 6px; flex-wrap: wrap; justify-content: center; }

  .article { margin: 36px auto 64px; padding: 0 18px; }
  .article__hero { margin: 0 -18px 24px; border-radius: 8px; }
  .article-nav { padding: 0 18px; gap: 12px; margin: 36px auto 64px; }

  .article-page .article { padding-top: 8px; }
}

@media (max-width: 600px) {
  .article-nav { grid-template-columns: 1fr; }
  .article-nav__link--next { text-align: left; }
}

/* очень узкие — iPhone SE и т.п. */
@media (max-width: 380px) {
  .topbar { padding: 12px 14px; }
  .legal { padding: 8px 12px 12px; font-size: 0.625rem; }
  .legal__col--right { font-size: 0.625rem; }
}

/* уважаем prefers-reduced-motion: останавливаем авто-кручение в JS, плюс упрощаем переходы */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
