/* Топ Рейтинги — единственный файл стилей.
   Правила: без веб-шрифтов (системный стек), без внешних библиотек,
   эффекты только на CSS, тёмная тема по prefers-color-scheme.
   Цель — страница до 80 КБ и зелёные Core Web Vitals. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-card: #ffffff;
  --text: #1a1d21;
  --text-soft: #5b6470;
  --line: #e4e7eb;
  --accent: #1b5cff;
  --accent-soft: #eaf0ff;
  --good: #14915a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --wrap: 1120px;
  --read: 760px;
}

/* Тёмная тема работает двумя путями (решение 18.09.2026):
   1) по системной настройке — если посетитель не выбирал тему руками;
   2) по переключателю в шапке — тогда на <html> стоит data-theme,
      и он перебивает системную настройку.
   Поэтому системное правило не применяется, когда выбрана светлая вручную. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --bg-soft: #151a20;
    --bg-card: #161b22;
    --text: #e7ebf0;
    --text-soft: #9aa6b2;
    --line: #242b34;
    --accent: #6f9bff;
    --accent-soft: #17233d;
    --good: #3ecf8e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --bg-soft: #151a20;
  --bg-card: #161b22;
  --text: #e7ebf0;
  --text-soft: #9aa6b2;
  --line: #242b34;
  --accent: #6f9bff;
  --accent-soft: #17233d;
  --good: #3ecf8e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

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

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* ── шапка ─────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.logo svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top details { position: relative; }
.top summary {
  list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); font-weight: 500; user-select: none;
}
.top summary::-webkit-details-marker { display: none; }
.top summary:hover { background: var(--bg-soft); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px; min-width: 260px; max-height: 70vh; overflow: auto;
  display: grid; gap: 2px;
}
.menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 15px;
}
.menu a:hover { background: var(--accent-soft); color: var(--accent); }
.menu svg { width: 18px; height: 18px; flex: none; opacity: .8; }

/* ── хлебные крошки ────────────────────────────────────── */
.crumbs { font-size: 14px; color: var(--text-soft); padding: 18px 0 6px; }
.crumbs a { color: var(--text-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { opacity: .5; margin: 0 6px; }

/* ── статья ────────────────────────────────────────────── */
main { padding-bottom: 48px; }
article { max-width: var(--read); }
article h1 {
  font-size: clamp(26px, 4.2vw, 38px); line-height: 1.22; letter-spacing: -.02em;
  margin: 10px 0 18px;
}
article h2 {
  font-size: clamp(21px, 2.8vw, 26px); line-height: 1.3; margin: 38px 0 14px;
  scroll-margin-top: 76px;
}
article h3 { font-size: clamp(18px, 2.2vw, 21px); margin: 26px 0 10px; }
article p { margin: 0 0 16px; }
article a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
article ul { padding-left: 22px; }
article li { margin: 0 0 10px; }
article strong { font-weight: 650; }

.byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 14px; color: var(--text-soft);
  padding: 12px 0 0; border-top: 1px solid var(--line);
}
.byline .ava {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 15px;
}
.byline b { color: var(--text); font-weight: 600; }

/* оглавление */
.toc {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 22px 0 30px;
}
.toc b { display: block; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 4px 0; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* FAQ-аккордеон */
.faq details {
  border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; margin: 0 0 10px;
  background: var(--bg-card); transition: border-color .15s ease, box-shadow .15s ease;
}
.faq details[open] { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow); }
.faq summary {
  cursor: pointer; list-style: none; padding: 13px 0; font-weight: 600;
  display: flex; gap: 10px; align-items: flex-start;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "+"; flex: none; width: 20px; height: 20px; margin-top: 2px;
  display: grid; place-items: center; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; line-height: 1;
}
.faq details[open] summary::before { content: "−"; }
.faq .ans { padding: 0 0 14px 30px; color: var(--text-soft); }

/* Место под рекламный блок.
   Растянуто во всю ширину колонки, содержимое центрируется по горизонтали и
   вертикали — так два баннера 300×250 можно поставить в строку своим div-ом
   прямо в рекламном коде.
   Высота резервируется ТОЛЬКО если для слота реально лежит код в
   ads/blocks.html: иначе на странице оставались бы пустые провалы.
   Значения приходят из config.json → ads.block_layout. */
.ad {
  margin: 26px 0; width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 12px;
}
.ad[style] { min-height: var(--adh-d, 0); }

/* ── карточки и листинги ───────────────────────────────── */
/* Сетка карточек: ровно 3 колонки на ПК и 2 на телефоне (решение 18.09.2026).
   Задано числом колонок, а не auto-fill с минимальной шириной: auto-fill
   подстраивается под ширину окна и на промежуточных размерах давал то 4, то 5
   карточек в ряд. */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.grid-sm { gap: 12px; grid-template-columns: repeat(3, 1fr); }
.grid-sm .card { padding: 15px 16px; gap: 6px; }
.grid-sm .card svg { width: 24px; height: 24px; color: var(--accent); }
.grid-sm .card b { font-size: 16px; line-height: 1.3; }
.grid-sm .card span { font-size: 13.5px; }
.card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card b { font-size: 16px; font-weight: 600; line-height: 1.35; }
.card span { font-size: 13px; color: var(--text-soft); }
.rubric-head { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; }
.rubric-head svg { width: 30px; height: 30px; color: var(--accent); flex: none; }
.rubric-head h1 { margin: 0; }
.lead { color: var(--text-soft); max-width: var(--read); margin: 0 0 24px; }

.list { columns: 2 340px; column-gap: 28px; content-visibility: auto; contain-intrinsic-size: 800px; }
.list a { display: block; padding: 7px 0; color: var(--text); text-decoration: none; break-inside: avoid; }
.list a:hover { color: var(--accent); }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 30px 0 0; }
.pager a, .pager strong {
  min-width: 40px; text-align: center; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 500;
}
.pager strong { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager a:hover { background: var(--bg-soft); }

.related { margin: 40px 0 0; padding: 22px 0 0; border-top: 1px solid var(--line); }
.related h2 { margin: 0 0 14px; font-size: 20px; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.related a { color: var(--text); text-decoration: none; }
.related a:hover { color: var(--accent); text-decoration: underline; }

/* ── формы и служебные страницы ────────────────────────── */
form { max-width: 520px; display: grid; gap: 12px; }
label { font-size: 14px; color: var(--text-soft); }
textarea, input[type="text"], input[type="email"], input[type="search"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
textarea { min-height: 130px; resize: vertical; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: 12px 18px; background: var(--accent); color: #fff;
  transition: filter .15s ease;
}
button:hover { filter: brightness(1.08); }
.hidden { display: none !important; }
.note { font-size: 14px; color: var(--text-soft); }

/* Раскрытие партнёрских отношений в подвале. Самый мелкий шрифт, но НЕ меньше
   11 px и с сохранённым контрастом: нечитаемо мелкий или замаскированный под
   фон текст Google считает скрытым, а это уже нарушение, а не раскрытие. */
.fine-print { font-size: 11px; line-height: 1.45; color: var(--text-soft); opacity: .75; margin: 0 0 6px; }

/* Почта картинкой: выделять и копировать нечего — в разметке буквы
   перемешаны, а выделение мышью отключено. */
.mail-svg {
  max-width: 100%; height: auto; display: block; margin: 4px 0 6px;
  user-select: none; -webkit-user-select: none; pointer-events: none;
}

/* ── подвал ────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--line); background: var(--bg-soft);
  padding: 30px 0; margin-top: 40px; font-size: 14px; color: var(--text-soft);
}
footer .cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
footer a { color: var(--text-soft); text-decoration: none; }
footer a:hover { color: var(--accent); }
footer b { display: block; color: var(--text); margin-bottom: 8px; }
footer .fine { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ── мобильные ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .ad[style] { min-height: var(--adh-m, 0); }
  /* на телефоне — две карточки в ряд */
  .grid, .grid-sm { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-sm .card { padding: 12px 13px; }
  .grid-sm .card b { font-size: 14.5px; }
  body { font-size: 16px; }
  .wrap { padding: 0 14px; }
  .list { columns: 1; }
  .menu { position: fixed; left: 14px; right: 14px; top: 68px; min-width: 0; }
  .top-in { min-height: 54px; }
}

/* ── планшеты: между телефоном и ПК три колонки уже тесны ── */
@media (min-width: 641px) and (max-width: 900px) {
  .grid, .grid-sm { grid-template-columns: repeat(2, 1fr); }
}

/* ── переключатель темы в шапке ────────────────────────── */
.theme {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--bg-card);
}
.theme button {
  all: unset; cursor: pointer; display: grid; place-items: center;
  width: 30px; height: 28px; border-radius: 8px; color: var(--text-soft);
  transition: background .15s ease, color .15s ease;
}
.theme button:hover { background: var(--bg-soft); color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.theme svg { width: 17px; height: 17px; }

/* ── кнопка «наверх» с кольцом прогресса чтения ─────────── */
.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 30;
  width: 48px; height: 48px; border: 0; padding: 0; cursor: pointer;
  border-radius: 50%; background: var(--bg-card);
  box-shadow: 0 4px 14px rgba(16, 24, 40, .18);
  display: grid; place-items: center;
  opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2, .9, .3, 1.3);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--accent-soft); }
.to-top:active { transform: scale(.94); }
.to-top .arrow {
  width: 17px; height: 17px; color: var(--accent);
  transition: transform .2s ease;
}
.to-top:hover .arrow { transform: translateY(-2px); }
/* кольцо: обводка круга, закрашенная на долю прочитанного */
.to-top .ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.to-top .ring circle { fill: none; stroke-width: 3; }
.to-top .ring .track { stroke: var(--line); }
.to-top .ring .bar {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 135; stroke-dashoffset: calc(135 - 135 * var(--p, 0));
  transition: stroke-dashoffset .1s linear;
}
@media (max-width: 640px) {
  .to-top { right: 12px; bottom: 12px; width: 44px; height: 44px; }
}

/* ── сообщение под формой обратной связи ───────────────── */
.form-msg { font-size: 14.5px; margin: 10px 0 0; min-height: 21px; }
.form-msg.ok { color: var(--good); font-weight: 600; }
.form-msg.err { color: #d23b3b; font-weight: 600; }
:root[data-theme="dark"] .form-msg.err { color: #ff8a8a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-msg.err { color: #ff8a8a; }
}
