/*
  site.css — сайт и документация (php-site, ТЗ §8.2–8.3). Подключается после base.css (php-core) и берёт его переменные
  и классы (.wrap, .topbar, .brand, .btn, .card, .footer). Системный шрифт, без внешних ресурсов, вёрстка от 360 px,
  страницы читаются без JavaScript.

  Классы: .skip-link, .site-nav, .hero, .section (--reports, --recordings, --audience, --network, --developers,
  --products), .features, .feature, .prose (--doc), .note, .more, .actions, .source (--own, --network), .soon, .article,
  .onpage, .docs, .toc, .toc-mobile, .doc, .basics, .doc-cards, .doc-card, .callout, .pager, .btn--large.
*/

:root {
  --site-ink: #111827;
  --site-code-bg: #0f172a;
  --site-code-text: #e2e8f0;
  --site-hero-from: #eef2ff;
  --site-hero-to: #f7f5ff;
  --site-radius-large: 16px;
}

.site { background: var(--c-surface); }
.site-main { min-height: 60vh; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 10; padding: 8px 14px;
  border-radius: var(--radius-small); background: var(--c-accent); color: #fff;
}
.skip-link:focus { top: 8px; }
.tag-pixel { position: absolute; width: 1px; height: 1px; }

/* ---------- шапка ---------- */

.site-topbar { position: relative; }
.site-nav__link { padding: 4px 0; border-bottom: 2px solid transparent; }
.site-nav__link:hover { text-decoration: none; border-bottom-color: var(--c-border); }
.site-nav__link.is-active { border-bottom-color: var(--c-accent); color: var(--c-accent-dark); }

.btn--large { min-height: 46px; padding: 12px 22px; font-size: 16px; }

/* ---------- главная: первый экран ---------- */

.hero {
  background: linear-gradient(160deg, var(--site-hero-from) 0%, var(--site-hero-to) 55%, var(--c-surface) 100%);
  border-bottom: 1px solid var(--c-border);
}
.hero__inner {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 48px; align-items: center;
  padding-top: 64px; padding-bottom: 64px;
}
.hero__title {
  margin: 0 0 20px; font-size: clamp(28px, 4.4vw, 46px); line-height: 1.12; letter-spacing: -0.01em; color: var(--site-ink);
}
.hero .prose { font-size: 17px; }
.hero .prose > p:first-child { font-size: clamp(16px, 1.8vw, 19px); color: #374151; }
.hero .prose ul { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.hero .prose li {
  position: relative; padding: 10px 14px 10px 40px; border: 1px solid var(--c-border); border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
}
.hero .prose li::before {
  content: ""; position: absolute; left: 14px; top: 15px; width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--c-accent) 0%, #7c4dff 100%);
}
.hero .actions { margin-top: 24px; }
.hero__art img { display: block; width: 100%; height: auto; filter: drop-shadow(0 18px 40px rgba(59, 91, 219, .18)); }

/* ---------- главная: блоки ---------- */

.section { padding: 64px 0; }
.section:nth-of-type(odd) { background: var(--c-bg); }
.section__title { font-size: clamp(24px, 3.2vw, 34px); letter-spacing: -0.01em; color: var(--site-ink); margin-bottom: 16px; }
.section__intro { max-width: 820px; margin-bottom: 28px; font-size: 16px; color: #374151; }
.section__intro .prose > :last-child { margin-bottom: 0; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.features--1 { grid-template-columns: minmax(0, 820px); }
.features--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.feature {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
}
.feature__title { font-size: 18px; margin-bottom: 10px; color: var(--site-ink); }
.feature .prose { color: #374151; }
.feature .prose > :last-child { margin-bottom: 0; }
.feature .more { margin-top: 14px; }

.section--reports .feature:first-child { grid-column: span 2; }

.section--audience .feature { padding: 0; overflow: hidden; }
.section--audience .feature__title { margin: 0; padding: 16px 22px; border-bottom: 1px solid var(--c-border); background: #fafbff; font-size: 16px; }
.section--audience .feature .prose { padding: 0; }
.section--audience .feature .table-wrap { margin: 0; border: 0; border-radius: 0; }
.section--audience .feature .note { margin: 0; padding: 12px 22px 16px; }

.section.section--network { background: linear-gradient(160deg, #1f2a5c 0%, #2f3f8f 100%); color: #eef2ff; }
.section--network .section__title { color: #fff; }
.section--network .section__intro { max-width: none; color: #dfe5ff; }
.section--network .prose ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.section--network .prose li {
  margin: 0; padding: 20px; border-radius: var(--radius); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
}
.section--network .prose strong { display: block; margin-bottom: 6px; color: #fff; font-size: 17px; }
.section--network .more__link { color: #fff; }
.section--network .more { margin-top: 24px; }

.section--developers .section__intro { max-width: 900px; }
.section--developers .prose pre { margin: 16px 0 20px; }

/* ---------- части страниц ---------- */

.note { margin: 10px 0 0; color: var(--c-muted); font-size: 13px; }
.more { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 16px 0 0; }
.more__link { font-weight: 600; }
.more__link::after { content: " →"; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 0; }

.source { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.source--own { background: var(--c-success-soft); color: var(--c-success); }
.source--network { background: var(--c-accent-soft); color: var(--c-accent-dark); }

/* Метка «скоро» — функция следующего этапа ({{soon:N}} в content/site, SitePages). Текст в метке, а не только цвет;
   размер один в заголовках и тексте. */
.soon {
  display: inline-block; padding: 1px 8px; border: 1px solid #e9c46a; border-radius: 999px; background: var(--c-warn-soft);
  color: var(--c-warn); font-size: 12px; font-weight: 600; line-height: 1.5; letter-spacing: .02em; vertical-align: middle;
  white-space: nowrap;
}
.section--network .soon { border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- текст из Markdown ---------- */

.prose { line-height: 1.65; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 24px; margin: 40px 0 14px; scroll-margin-top: 16px; color: var(--site-ink); }
.prose h3 { font-size: 19px; margin: 28px 0 10px; scroll-margin-top: 16px; color: var(--site-ink); }
.prose h4 { font-size: 16px; margin: 22px 0 8px; }
.prose p, .prose ul, .prose ol, .prose pre, .prose .table-wrap, .prose blockquote { margin: 0 0 16px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose li > ul, .prose li > ol { margin: 4px 0; }
.prose a.anchor { margin-left: 8px; color: var(--c-border); font-weight: 400; text-decoration: none; visibility: hidden; }
.prose h2:hover a.anchor, .prose h3:hover a.anchor, .prose h4:hover a.anchor, .prose a.anchor:focus { visibility: visible; }
.prose a.external::after { content: "\2009\2197"; font-size: .85em; }
.prose code {
  padding: 1px 5px; border-radius: 4px; background: #f1f3f9; color: #2b3350; font-size: .9em; overflow-wrap: anywhere;
}
.prose pre {
  padding: 16px 18px; border-radius: var(--radius); background: var(--site-code-bg); color: var(--site-code-text);
  overflow-x: auto; -webkit-overflow-scrolling: touch; line-height: 1.55; font-size: 13.5px; tab-size: 4;
}
.prose pre code { padding: 0; background: transparent; color: inherit; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.prose blockquote { padding: 10px 16px; border-left: 3px solid var(--c-accent); background: var(--c-accent-soft); border-radius: 0 var(--radius-small) var(--radius-small) 0; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--c-border); margin: 32px 0; }

.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface);
}
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.prose th, .prose td { padding: 9px 12px; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.prose th { background: #f7f8fb; font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; }
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }

/* ---------- статья (/network) ---------- */

.article { padding-top: 40px; padding-bottom: 24px; }
.article__head { max-width: 860px; margin-bottom: 28px; }
.article__title { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.01em; color: var(--site-ink); }
.article__lead { font-size: 18px; color: var(--c-muted); margin: 0; }
.article__grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start; }
.article__body { max-width: 820px; min-width: 0; }
.article__body .actions { margin-top: 32px; }
.onpage { position: sticky; top: 16px; padding: 14px 0; border-left: 2px solid var(--c-border); }
.onpage__title { margin: 0 0 8px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.onpage__list { list-style: none; margin: 0; padding: 0; }
.onpage__list a { display: block; padding: 5px 16px; color: var(--c-text); font-size: 14px; line-height: 1.35; }
.onpage__list a:hover { color: var(--c-accent); text-decoration: none; }

/* ---------- документация ---------- */

.docs { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 32px; padding-bottom: 24px; }
.docs__side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 4px; }
.docs__main { min-width: 0; max-width: 860px; }

.toc { font-size: 14px; }
.toc__group { margin: 18px 0 6px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.toc__list { list-style: none; margin: 6px 0 0; padding: 0; }
.toc__link { display: block; padding: 7px 12px; border-radius: var(--radius-small); color: var(--c-text); line-height: 1.35; }
.toc__link:hover { background: var(--c-bg); text-decoration: none; }
.toc__link.is-active { background: var(--c-accent-soft); color: var(--c-accent-dark); font-weight: 600; }
.toc__link--home { font-weight: 600; }
.toc__sub { list-style: none; margin: 4px 0 8px; padding: 0 0 0 12px; border-left: 2px solid var(--c-accent-soft); margin-left: 14px; }
.toc__anchor { display: block; padding: 4px 10px; color: var(--c-muted); font-size: 13px; line-height: 1.35; }
.toc__anchor:hover { color: var(--c-accent); text-decoration: none; }

.toc-mobile { display: none; margin-bottom: 20px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); }
.toc-mobile__summary { padding: 12px 16px; font-weight: 600; cursor: pointer; }
.toc-mobile .toc { padding: 0 8px 12px; }

.doc__crumbs { margin: 0 0 6px; font-size: 14px; color: var(--c-muted); }
.doc__title { font-size: clamp(28px, 3.6vw, 38px); letter-spacing: -0.01em; color: var(--site-ink); margin-bottom: 10px; }
.doc__lead { font-size: 17px; color: var(--c-muted); margin-bottom: 24px; }
.doc__onpage { display: none; margin: 0 0 24px; padding: 14px 18px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); }
.doc__onpage-title { margin: 0 0 6px; font-weight: 700; font-size: 14px; }
.doc__onpage ul { margin: 0; padding-left: 18px; font-size: 14px; }
.doc__onpage li { margin: 3px 0; }
.prose--doc { font-size: 15.5px; }

.basics { margin: 0 0 32px; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.basics__row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--c-border); }
.basics__row:last-child { border-bottom: 0; }
.basics dt { margin: 0; font-weight: 600; }
.basics dd { margin: 0; overflow-wrap: anywhere; }
.basics code { padding: 1px 5px; border-radius: 4px; background: #f1f3f9; font-size: .9em; }

.doc-group { margin-bottom: 28px; }
.doc-group__title { font-size: 20px; }
.doc-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.doc-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow);
}
.doc-card:hover { text-decoration: none; border-color: var(--c-accent); }
.doc-card__title { font-weight: 700; font-size: 17px; color: var(--site-ink); }
.doc-card__text { color: var(--c-muted); font-size: 14px; line-height: 1.5; }

.callout { margin: 24px 0; padding: 14px 18px; border-radius: var(--radius); background: var(--c-info-soft); color: #173e6e; border: 1px solid #c3d9f2; }
.callout p { margin: 0; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin: 40px 0 0; padding-top: 24px; border-top: 1px solid var(--c-border); }
.pager__link { display: flex; flex-direction: column; gap: 2px; max-width: 48%; padding: 12px 16px; border: 1px solid var(--c-border); border-radius: var(--radius); font-weight: 600; }
.pager__link:hover { text-decoration: none; border-color: var(--c-accent); }
.pager__link--next { margin-left: auto; text-align: right; }
.pager__dir { font-size: 12px; font-weight: 500; color: var(--c-muted); }

/* ---------- подвал ---------- */

.site-footer { margin-top: 0; }
.site-footer__links { display: grid; grid-template-columns: repeat(2, minmax(0, auto)); gap: 6px 32px; }
.site-footer__contact { font-weight: 600; }

/* ---------- узкие экраны ---------- */

@media (max-width: 1023px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 20px; }
  .docs__side { display: none; }
  .toc-mobile { display: block; }
  .doc__onpage { display: block; }
  .article__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .onpage { position: static; margin-bottom: 24px; border-left: 0; padding: 14px 0; border-top: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); }
  .onpage__title { margin-left: 0; }
  .onpage__list a { padding: 4px 0; }
}

@media (max-width: 900px) {
  .hero__inner { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 40px; padding-bottom: 40px; }
  .hero__art { max-width: 480px; }
  .features, .features--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section--reports .feature:first-child { grid-column: auto; }
  .section--network .prose ul { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

/* base.css прячет основную кнопку шапки уже на 560 px; на сайте обе кнопки ТЗ §8.2 остаются — отдельной строкой под логотипом */
@media (max-width: 560px) {
  .site-topbar .topbar__inner { row-gap: 10px; padding-top: 10px; }
  .site-topbar .topbar__actions { order: 2; flex-basis: 100%; margin-left: 0; }
  .site-topbar .topbar__actions .btn { display: inline-flex; flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
  .site-topbar .topbar__actions .btn--primary { flex: 1 1 auto; }
}

@media (max-width: 640px) {
  .site .wrap { padding-left: 16px; padding-right: 16px; }
  .hero__art { display: none; }
  .section { padding: 44px 0; }
  .features, .features--1, .features--2 { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .feature { padding: 18px; }
  .doc-cards { grid-template-columns: minmax(0, 1fr); }
  .basics__row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pager { flex-direction: column; }
  .pager__link { max-width: none; }
  .pager__link--next { margin-left: 0; }
  .site-footer__links { grid-template-columns: minmax(0, 1fr); }
  .prose pre { margin-left: -16px; margin-right: -16px; border-radius: 0; padding: 14px 16px; }
  .prose th { white-space: normal; }
  .btn--large { width: 100%; }
  .actions { flex-direction: column; }
}

@media (max-width: 400px) {
  .brand { font-size: 14px; letter-spacing: .02em; }
  .topbar__actions .btn { padding: 6px 12px; font-size: 14px; }
  .site-nav { gap: 4px 10px; font-size: 14px; }
}
