/* Руководство пользователя justwriting. Статика: без JS (CSP script-src 'self',
   inline-скриптов нет), шрифты со своего домена (/fonts/fonts.css). */
@import url('/fonts/fonts.css');

:root {
  --bg: #FAF8F5;
  --bg-soft: #F0EDE6;
  --card: #FFFFFF;
  --text: #1A1412;
  --muted: #6B625E;
  --border: rgba(26, 20, 18, 0.10);
  --accent: #6A3FC0;
  --accent-soft: rgba(106, 63, 192, 0.08);
  --tip: #15803D;
  --tip-soft: rgba(21, 128, 61, 0.07);
  --warn: #B45309;
  --warn-soft: rgba(180, 83, 9, 0.08);
  --kbd-bg: #F0EDE6;
  --shadow: 0 1px 2px rgba(26, 20, 18, 0.06), 0 8px 24px rgba(26, 20, 18, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0A18;
    --bg-soft: #1a1030;
    --card: #1B1231;
    --text: #F0EBFF;
    --muted: #9B89CC;
    --border: rgba(165, 131, 232, 0.16);
    --accent: #B89AF0;
    --accent-soft: rgba(165, 131, 232, 0.12);
    --tip: #34D399;
    --tip-soft: rgba(52, 211, 153, 0.08);
    --warn: #FBBF24;
    --warn-soft: rgba(251, 191, 36, 0.08);
    --kbd-bg: #231542;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 20; background: var(--card); padding: 8px 12px; }

/* ── Шапка ───────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--text); text-decoration: none; }
.brand b { font: 600 19px/1 'Lora', Georgia, serif; letter-spacing: -0.01em; }
.brand span { font-size: 14px; color: var(--muted); }
.app-link {
  font-size: 14px; font-weight: 500; text-decoration: none;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text); background: var(--card);
}
.app-link:hover { border-color: var(--accent); }

/* ── Раскладка ───────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr);
  gap: 48px; max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px;
}

.sidenav { position: sticky; top: 88px; align-self: start; font-size: 15px; }
/* Без JS: список на широком экране и тот же список в <details> на узком. */
.sidenav .mnav { display: none; }
.sidenav ol { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.sidenav li { counter-increment: ch; }
.sidenav a {
  display: flex; gap: 10px; padding: 7px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; line-height: 1.35;
}
.sidenav a::before { content: counter(ch); font: 500 12px/1.9 'JetBrains Mono', monospace; opacity: 0.7; min-width: 12px; }
.sidenav a:hover { color: var(--text); background: var(--accent-soft); }
.sidenav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ── Статья ──────────────────────────────────────── */
.doc { max-width: 720px; min-width: 0; }
.doc h1 { font: 600 40px/1.15 'Lora', Georgia, serif; letter-spacing: -0.015em; margin: 8px 0 12px; }
.doc h2 {
  font: 600 27px/1.25 'Lora', Georgia, serif; margin: 56px 0 12px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.doc h3 { font: 600 19px/1.35 'Inter', system-ui, sans-serif; margin: 32px 0 8px; }
.doc p, .doc ul, .doc ol { margin: 0 0 14px; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li::marker { color: var(--muted); }
.lead { font-size: 19px; color: var(--muted); margin-bottom: 24px !important; }

.toc {
  background: var(--bg-soft); border-radius: 12px; padding: 16px 20px; margin: 0 0 8px; font-size: 15px;
}
.toc::before { content: 'На этой странице'; display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.toc ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.toc li { break-inside: avoid; margin: 3px 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Название элемента интерфейса */
.ui { font-weight: 600; }
.ui::before { content: '«'; font-weight: 400; color: var(--muted); }
.ui::after { content: '»'; font-weight: 400; color: var(--muted); }

kbd {
  font: 500 0.82em/1 'JetBrains Mono', ui-monospace, monospace;
  padding: 3px 6px; border-radius: 6px; white-space: nowrap;
  background: var(--kbd-bg); border: 1px solid var(--border); border-bottom-width: 2px;
}

/* Пошаговые инструкции */
ol.steps { list-style: none; padding: 0; counter-reset: step; }
ol.steps > li {
  counter-increment: step; position: relative; padding: 2px 0 2px 44px; margin: 0 0 12px;
}
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 1px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 14px/1 'Inter', sans-serif; color: var(--accent); background: var(--accent-soft);
}

/* Врезки */
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 10px 10px 0; padding: 14px 18px; margin: 20px 0;
}
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.tip { border-color: var(--tip); background: var(--tip-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout strong:first-child { color: var(--text); }

/* Скриншоты */
figure.shot { margin: 24px 0 28px; }
figure.shot img {
  display: block; width: 100%; height: auto;
  border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow);
  background: var(--bg-soft);
}
figure.shot figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; text-align: center; }
figure.shot.narrow img { max-width: 520px; margin: 0 auto; }

/* Таблицы */
.table-wrap { overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { font-weight: 600; background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }

/* Карточки разделов на главной */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 24px; padding: 0; list-style: none; }
.cards a {
  display: block; height: 100%; padding: 16px 18px; border-radius: 12px; text-decoration: none;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.cards a:hover { border-color: var(--accent); }
.cards b { display: block; font-weight: 600; margin-bottom: 4px; }
.cards span { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* Листалка */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--border); text-decoration: none; color: var(--text); max-width: 48%;
}
.pager a:hover { border-color: var(--accent); }
.pager a small { color: var(--muted); font-size: 13px; }
.pager .next { margin-left: auto; text-align: right; }

.footer { max-width: 1120px; margin: 0 auto; padding: 24px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--border); }
.footer a { color: var(--muted); }

/* ── Узкий экран ─────────────────────────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px 16px 64px; }
  .topbar { padding: 0 16px; }
  .brand span { display: none; }
  .sidenav { position: static; }
  .sidenav .dnav { display: none; }
  .sidenav .mnav { display: block; }
  .sidenav summary {
    display: flex; justify-content: space-between; align-items: center; cursor: pointer;
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card);
    font-weight: 500; list-style: none;
  }
  .sidenav summary::-webkit-details-marker { display: none; }
  .sidenav summary::after { content: '▾'; color: var(--muted); }
  .sidenav details[open] summary::after { content: '▴'; }
  .sidenav ol { margin-top: 8px; }
  .doc h1 { font-size: 31px; }
  .doc h2 { font-size: 23px; margin-top: 44px; }
  .toc ul { columns: 1; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}

@media print {
  .topbar, .sidenav, .pager, .toc { display: none; }
  .layout { display: block; padding: 0; }
  figure.shot img { box-shadow: none; }
}

/* Мелкие кадры (иконки, небольшие окна) — в натуральную величину, без растяжения. */
figure.shot.fit img { width: auto; max-width: 100%; margin: 0 auto; }
