/* MediaStat: светлая тема по умолчанию, тёмная по настройке системы */
:root {
  --paper: #f2f4f8;
  --surface: #ffffff;
  --ink: #141b3d;
  --ink-2: #444c6e;
  --ink-3: #5f6687;
  --rule: #d8dde9;
  --marker: #ffe04a;
  --on-marker: #141b3d;
  --link: #2341bd;
  --code-bg: #e8ebf3;
  --footer-bg: #141b3d;
  --footer-ink: #e9ecf8;
  --footer-ink-2: #aab1cf;

  --c-svyaz: #04707a;
  --c-gadzhety: #6a3dbf;
  --c-bezopasnost: #b82b3a;
  --c-poryadok: #3a7427;

  --hl-h: 64%;
  --hl-y: 88%;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --serif: "PT Serif", Georgia, Cambria, "Noto Serif", "DejaVu Serif", "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: 16px;
  --max: 74rem;
  color-scheme: light dark;
}

@media (min-width: 40rem) { :root { --gutter: 28px; } }
@media (min-width: 64rem) { :root { --gutter: 40px; } }

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1430;
    --surface: #171d3e;
    --ink: #eaedf8;
    --ink-2: #b6bcd6;
    --ink-3: #959cbb;
    --rule: #2a3259;
    --marker: #f3d43e;
    --on-marker: #141b3d;
    --link: #a3b6ff;
    --code-bg: #232a52;
    --footer-bg: #0a0e24;
    --footer-ink: #e9ecf8;
    --footer-ink-2: #9aa1c2;

    --c-svyaz: #57c6cc;
    --c-gadzhety: #b8a0ff;
    --c-bezopasnost: #ff8f98;
    --c-poryadok: #8fd273;

    --hl-h: 100%;
    --hl-y: 50%;
  }
}

/* База */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}
svg { display: block; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.lead, .hero-intro, .featured-teaser, .card p { text-wrap: pretty; }
::selection { background: var(--marker); color: var(--on-marker); }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; border-radius: 4px; }

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

.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 20;
  background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: 8px;
  font-weight: 600;
}
.skip:focus { top: 12px; }

/* Шапка */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 28px; padding-block: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 800; font-size: 1.375rem; letter-spacing: -0.03em; line-height: 1;
}
.brand svg { width: 30px; height: 30px; flex: none; }
.logo-bg { fill: var(--ink); }
.logo-a { fill: none; stroke: var(--paper); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.logo-hl { fill: var(--marker); }

.nav ul { display: flex; flex-wrap: wrap; gap: 4px 22px; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: inline-block; padding: 6px 0; text-decoration: none;
  font-weight: 600; font-size: 0.9375rem; color: var(--ink-2);
}
.nav a:hover, .nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--marker);
  text-decoration-thickness: 4px; text-underline-offset: 7px;
}

/* Маркер — главный приём сайта */
.hl {
  color: var(--on-marker);
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-size: 100% var(--hl-h);
  background-position: 0 var(--hl-y);
  padding: 0.02em 0.16em;
  border-radius: 0.22em 0.08em 0.28em 0.1em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Главная: первый экран */
.hero { padding-block: clamp(36px, 7vw, 96px) clamp(40px, 6vw, 80px); }
.hero h1 {
  margin: 0 0 clamp(28px, 4vw, 48px);
  font-size: clamp(2.375rem, 1.1rem + 6.6vw, 6.25rem);
  font-weight: 800; line-height: 0.95; letter-spacing: -0.045em;
  max-width: 11ch;
}
.hero-grid { display: grid; gap: 32px; }
@media (min-width: 56rem) {
  .hero-grid { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 64px; align-items: start; }
}
.hero-intro {
  margin: 0; font-family: var(--serif); font-size: 1.1875rem; line-height: 1.6;
  color: var(--ink-2); max-width: 34ch;
}
.glossary { border-top: 3px solid var(--ink); padding-top: 18px; }
.glossary-note { margin: 0 0 18px; font-size: 0.9375rem; color: var(--ink-3); }
.glossary-term {
  margin: 0 0 6px; font-weight: 700; font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  letter-spacing: -0.01em;
}
.glossary-plain {
  margin: 0 0 26px; font-family: var(--serif);
  font-size: clamp(1.625rem, 1.15rem + 2vw, 2.625rem); line-height: 1.32;
}
.glossary-plain .hl {
  -webkit-box-decoration-break: slice; box-decoration-break: slice;
}
.glossary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.glossary-actions a { color: var(--ink-2); font-size: 0.9375rem; text-underline-offset: 3px; }
.glossary-actions a:hover { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .glossary-plain .hl { animation: marker-draw 0.9s cubic-bezier(0.65, 0.05, 0.3, 1) 0.2s both; }
}
@keyframes marker-draw {
  from { background-size: 0% var(--hl-h); }
  to { background-size: 100% var(--hl-h); }
}

/* Кнопки */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  border: 2px solid var(--ink); border-radius: 8px;
  background: transparent; color: var(--ink);
  font: 600 0.9375rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--ink); color: var(--paper); }
.button[hidden] { display: none; }

/* Метки рубрик и метаданные */
.cat-svyaz { --cat: var(--c-svyaz); }
.cat-gadzhety { --cat: var(--c-gadzhety); }
.cat-bezopasnost { --cat: var(--c-bezopasnost); }
.cat-tsifrovoy-poryadok { --cat: var(--c-poryadok); }

.tag {
  display: inline-block; align-self: flex-start;
  padding: 3px 9px; border-radius: 5px;
  font-size: 0.8125rem; font-weight: 650; line-height: 1.4; text-decoration: none;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 12%, transparent);
}
a.tag:hover { background: color-mix(in srgb, var(--cat) 20%, transparent); }

.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  margin: 0; font-size: 0.875rem; color: var(--ink-3);
}
.meta .rt { display: inline-flex; align-items: center; gap: 6px; }
.meta .rt svg { width: 14px; height: 14px; }

/* Секции главной */
.section { padding-top: clamp(48px, 7vw, 88px); }
.section-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 8px 24px; margin-bottom: 22px;
}
.section-head h2 {
  margin: 0; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
  font-weight: 800; letter-spacing: -0.025em; line-height: 1.1;
}
.section-head a { font-size: 0.9375rem; color: var(--ink-2); text-underline-offset: 3px; }
.section-head a:hover { color: var(--ink); }

/* Главная статья */
.featured {
  display: grid; gap: 28px;
  background: var(--surface); border-radius: 18px;
  padding: clamp(22px, 4vw, 52px);
}
@media (min-width: 56rem) {
  .featured { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; }
}
.featured-main { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.featured h2 {
  margin: 4px 0 0; font-size: clamp(1.75rem, 1.15rem + 2.4vw, 3rem);
  font-weight: 800; line-height: 1.06; letter-spacing: -0.03em;
}
.featured h2 a { text-decoration: none; }
.featured h2 a:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.featured-teaser { margin: 0; font-family: var(--serif); font-size: 1.1875rem; line-height: 1.55; color: var(--ink-2); max-width: 36em; }
.featured .button { margin-top: 8px; }
.featured-summary { align-self: center; border-left: 3px solid var(--cat); padding: 4px 0 4px 22px; }
.featured-summary h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.featured-summary ul { margin: 0; padding-left: 1.1em; font-family: var(--serif); font-size: 1.0625rem; line-height: 1.55; color: var(--ink-2); }
.featured-summary li { margin-bottom: 0.55em; }
.featured-summary li::marker { color: var(--cat); }

/* Карточки статей */
.cards {
  display: grid; gap: 16px; list-style: none; margin: 0; padding: 0;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border-radius: 12px; padding: 20px 22px 18px;
}
.card .tag { position: relative; z-index: 1; }
.card :is(h2, h3) { margin: 2px 0 0; font-size: 1.25rem; font-weight: 750; line-height: 1.22; letter-spacing: -0.015em; }
.card :is(h2, h3) a { text-decoration: none; }
.card :is(h2, h3) a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card :is(h2, h3) a:focus-visible { outline: none; }
.card:has(:is(h2, h3) a:focus-visible) { outline: 3px solid var(--link); outline-offset: 3px; }
.card:hover :is(h2, h3) a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.card p { margin: 0; font-family: var(--serif); font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
.card .meta { margin-top: auto; padding-top: 8px; font-size: 0.8125rem; }

/* На главной семь карточек: ряд из двух, ряд из трёх, ряд из двух */
@media (min-width: 40rem) and (max-width: 63.99rem) {
  .cards--home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards--home > :first-child { grid-column: span 2; }
}
@media (min-width: 64rem) {
  .cards--home { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cards--home > * { grid-column: span 2; }
  .cards--home > :nth-child(1), .cards--home > :nth-child(2),
  .cards--home > :nth-child(6), .cards--home > :nth-child(7) { grid-column: span 3; }
  .cards--home > :nth-child(-n+2) h3 { font-size: 1.5rem; }
}

/* Рубрики на главной */
.rubrics {
  display: grid; gap: 32px 32px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.rubric { border-top: 4px solid var(--cat); padding-top: 14px; }
.rubric h3 { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.015em; }
.rubric h3 a { text-decoration: none; }
.rubric h3 a:hover { text-decoration: underline; text-decoration-color: var(--cat); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.rubric-count { margin: 2px 0 10px; font-size: 0.875rem; color: var(--ink-3); }
.rubric > p:not(.rubric-count) { margin: 0 0 14px; font-family: var(--serif); color: var(--ink-2); line-height: 1.5; }
.rubric ul { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.rubric li a {
  font-weight: 600; line-height: 1.35; text-decoration-color: var(--rule);
  text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.rubric li a:hover { text-decoration-color: var(--cat); }

/* Шапка статьи и страниц */
.page-head { padding-block: clamp(22px, 4vw, 40px) clamp(22px, 3vw, 34px); max-width: 54rem; }
.crumbs ol {
  display: flex; flex-wrap: wrap; gap: 2px 8px; list-style: none;
  margin: 0 0 clamp(22px, 3vw, 32px); padding: 0; font-size: 0.875rem; color: var(--ink-3);
}
.crumbs li { min-width: 0; }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { display: inline-block; max-width: min(30ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.page-head h1 {
  margin: 14px 0 18px; font-size: clamp(2.125rem, 1.35rem + 3.4vw, 3.75rem);
  font-weight: 800; line-height: 1.04; letter-spacing: -0.035em;
}
.page-head h1:first-child { margin-top: 0; }
.lead {
  margin: 0 0 20px; font-family: var(--serif);
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem); line-height: 1.55;
  color: var(--ink-2); max-width: 40em;
}
.cat-title { display: flex; align-items: baseline; gap: 0.35em; }
.cat-title::before { content: ""; flex: none; width: 0.5em; height: 0.5em; border-radius: 0.1em; background: var(--cat); }

/* Раскладка статьи */
.article-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) {
  .article-layout { grid-template-columns: minmax(0, 43rem) 15rem; justify-content: space-between; gap: 64px; }
  .article-layout > .toc { grid-column: 2; grid-row: 1; position: sticky; top: 24px; align-self: start; border: 0; padding: 0; background: none; }
  .article-layout > .prose { grid-column: 1; grid-row: 1; }
}

.toc { border: 1px solid var(--rule); border-radius: 10px; padding: 12px 16px; background: var(--surface); }
.toc summary { cursor: pointer; font-weight: 700; font-size: 0.9375rem; }
.toc ol { list-style: none; margin: 12px 0 4px; padding: 0 0 0 14px; border-left: 2px solid var(--rule); display: grid; gap: 8px; }
.toc a { color: var(--ink-2); font-size: 0.9375rem; line-height: 1.35; text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; }

/* Текст статьи */
.prose { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.72; }
@media (min-width: 40rem) { .prose { font-size: 1.1875rem; } }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h2 {
  margin: 1.9em 0 0.55em; font-family: var(--sans);
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  font-weight: 780; line-height: 1.2; letter-spacing: -0.02em;
  scroll-margin-top: 20px;
}
.prose ul, .prose ol { margin: 0 0 1.2em; }
.prose ul { padding-left: 1.3em; list-style-type: square; }
.prose li { margin-bottom: 0.55em; padding-left: 0.15em; }
.prose ul li::marker { color: var(--cat, var(--ink-3)); }
.prose ol { list-style: none; padding-left: 0; counter-reset: step; }
.prose ol > li { counter-increment: step; position: relative; padding-left: 2.5em; }
.prose ol > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.12em;
  display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%;
  font: 800 0.82em/1 var(--sans);
  color: var(--cat, var(--ink));
  background: color-mix(in srgb, var(--cat, var(--ink)) 13%, transparent);
}
.prose a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose strong { font-weight: 700; }
.prose code {
  font-family: var(--mono); font-size: 0.84em;
  background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px;
  overflow-wrap: anywhere;
}
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.9375rem; line-height: 1.4; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 10px 14px 10px 0; border-bottom: 1px solid var(--rule); }
.prose th { font-size: 0.8125rem; font-weight: 700; color: var(--ink-3); border-bottom-width: 2px; }
.prose td:nth-child(2), .prose th:nth-child(2) { white-space: nowrap; }

.tldr { background: var(--surface); border-radius: 14px; padding: 20px 24px 8px; margin: 0 0 2.2em; }
.prose .tldr-title { margin: 0 0 0.7em; font-size: 1.0625rem; letter-spacing: 0; }
.tldr ul { padding-left: 1.2em; }

.article-note {
  margin-top: 2.4em !important; padding-top: 1.2em; border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.9375rem; line-height: 1.55; color: var(--ink-3);
}

.related { padding-top: clamp(44px, 6vw, 72px); }

/* Статичные страницы */
.page-body { max-width: 43rem; }
.email-big {
  margin: 0.4em 0 1em; font-family: var(--sans);
  font-size: clamp(1.625rem, 1.1rem + 2.6vw, 2.75rem); font-weight: 800; letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.prose .email-big a { color: var(--ink); text-decoration: none; }
.prose .email-big a:hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 5px; text-underline-offset: 8px; }

.rubric-links { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0; padding: 0; }

/* 404 */
.notfound { padding-block: clamp(40px, 8vw, 110px) 0; max-width: 50rem; }
.notfound h1 { margin: 0 0 24px; font-size: clamp(2.5rem, 1.3rem + 5vw, 5rem); font-weight: 800; line-height: 0.98; letter-spacing: -0.04em; }
.notfound .glossary-plain { min-height: 0; }
.notfound ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notfound li a { font-weight: 600; text-underline-offset: 4px; }

/* Подвал */
.site-footer { margin-top: clamp(64px, 9vw, 120px); background: var(--footer-bg); color: var(--footer-ink); }
.site-footer :focus-visible { outline-color: var(--marker); }
.footer-grid { display: grid; gap: 32px; padding-block: 48px 32px; }
@media (min-width: 48rem) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; gap: 48px; } }
.site-footer .logo-bg { fill: var(--footer-ink); }
.site-footer .logo-a { stroke: var(--footer-bg); }
.footer-brand p { margin: 14px 0 0; max-width: 32ch; color: var(--footer-ink-2); font-family: var(--serif); line-height: 1.55; }
.site-footer h2 { margin: 0 0 12px; font-size: 0.9375rem; font-weight: 700; color: var(--footer-ink); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-footer ul a, .footer-bottom a { color: var(--footer-ink-2); text-decoration: none; font-size: 0.9375rem; }
.site-footer ul a:hover, .footer-bottom a:hover { color: var(--footer-ink); text-decoration: underline; text-decoration-color: var(--marker); text-underline-offset: 4px; }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding-block: 18px 28px; box-shadow: inset 0 1px color-mix(in srgb, var(--footer-ink) 16%, transparent);
  font-size: 0.875rem; color: var(--footer-ink-2);
}
.footer-bottom p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .site-header nav, .toc, .related, .site-footer, .glossary-actions { display: none; }
  body { background: #fff; color: #000; }
}
