/* ==========================================================================
   AMUR Web — общая тема. Токены из brief/00-common-tz.md §5.
   Тёмная — основная, светлая — через prefers-color-scheme и переключатель.
   ========================================================================== */

:root {
  --bg: #0B0F14;
  --surface: #121821;
  --surface-2: #1A2230;
  --text: #E6EDF3;
  --muted: #9AA7B4;
  --accent: #E8A33D;
  --accent-2: #4FB3A8;
  --danger: #E05C5C;
  --ok: #5FBF7F;
  --line: #243040;
  --code-bg: #0F1620;
  --shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.35);
  --radius: 10px;
  --max-text: 74ch;
  --font-sans: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #F7F9FB;
  --surface: #FFFFFF;
  --surface-2: #EEF2F6;
  --text: #17202A;
  --muted: #4B5764;
  --accent: #B87512;
  --accent-2: #1A6E66;
  --danger: #B83C3C;
  --ok: #2E7D4F;
  --line: #CCD6E0;
  --code-bg: #F1F4F8;
  --shadow: 0 1px 2px rgba(16,24,32,.06), 0 8px 20px rgba(16,24,32,.06);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #10171F;
  padding: 10px 16px; z-index: 100; font-weight: 600; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- раскладка ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }
.wrap--narrow { max-width: 900px; }

header.site {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.head-in {
  display: flex; align-items: center; gap: 18px;
  min-height: 62px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 650; letter-spacing: -.01em; color: var(--text);
  font-size: 17px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-2) 100%);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px;
  border-radius: 3px; background: var(--bg);
}
.brand small { color: var(--muted); font-weight: 400; font-size: 13px; }

nav.main { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav.main a {
  color: var(--muted); padding: 8px 11px; border-radius: 8px;
  font-size: 15px; line-height: 1;
}
nav.main a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
nav.main a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.theme-toggle {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; flex: none;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

.menu-toggle {
  display: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 14px;
}

/* ---------- типографика ---------- */
h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -.018em; margin: 0 0 .5em; font-weight: 650; text-wrap: balance; }
h1 { font-size: clamp(1.85rem, 1.1rem + 2.6vw, 2.9rem); letter-spacing: -.026em; }
p { text-wrap: pretty; }
h2 { font-size: clamp(1.32rem, 1.05rem + 1vw, 1.72rem); margin-top: 2.1em; }
h3 { font-size: 1.16rem; margin-top: 1.7em; }
h4 { font-size: 1.03rem; margin-top: 1.4em; color: var(--muted); }
p { margin: 0 0 1.05em; }
ul, ol { margin: 0 0 1.1em; padding-left: 1.4em; }
li { margin-bottom: .38em; }
li::marker { color: var(--accent); }
strong { font-weight: 640; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
small { font-size: .87rem; }

.lede { font-size: 1.12rem; color: var(--muted); max-width: 68ch; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- шапка статьи ---------- */
.page-head { padding: 42px 0 8px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin-bottom: .35em; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "→"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent-2); }
.meta-line {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  font-size: 13px; color: var(--muted); padding: 4px 0 18px;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted);
  font-family: var(--font-mono); letter-spacing: -.01em;
}

/* ---------- тело статьи ---------- */
article.body { padding: 26px 0 10px; max-width: var(--max-text); }
article.body > p:first-of-type { font-size: 1.04rem; }

/* TL;DR / callout */
.tldr, .callout {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: 15px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0 0 1.6em;
  font-size: .97rem;
}
.tldr { border-left-color: var(--accent-2); }
.tldr strong:first-child { color: var(--accent-2); }
.callout.warn { border-left-color: var(--accent); }
.callout.danger { border-left-color: var(--danger); }
.callout.ok { border-left-color: var(--ok); }

/* ---------- код ---------- */
code {
  font-family: var(--font-mono); font-size: .875em;
  background: color-mix(in srgb, var(--accent) 12%, var(--code-bg));
  padding: .12em .38em; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  color: color-mix(in srgb, var(--text) 92%, var(--accent));
  word-break: break-word;
}
.tldr code, .callout code { background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
pre {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  overflow-x: auto; overflow-y: hidden;
  margin: 0 0 1.4em; position: relative;
  white-space: pre; -webkit-overflow-scrolling: touch;
}
pre code {
  background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6;
  white-space: pre; color: var(--text); word-break: normal;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 11px; padding: 4px 8px; cursor: pointer; opacity: 0;
  transition: opacity .15s ease;
  font-family: var(--font-mono);
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- таблицы ---------- */
.table-scroll { overflow-x: auto; margin: 0 0 1.5em; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
caption { text-align: left; color: var(--muted); font-size: 13px; padding: 10px 14px 0; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 620; font-size: 13px; letter-spacing: .01em; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface) 55%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td code { font-size: .86em; }

/* ---------- связи / CTA ---------- */
.related {
  margin: 2.6em 0 0; padding: 20px 0 0; border-top: 1px solid var(--line);
  max-width: var(--max-text);
}
.related h2 { font-size: 1.05rem; margin: 0 0 .7em; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 620; }
.related ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.related li { margin: 0; }
.related a { display: inline-flex; gap: 8px; align-items: baseline; }
.related a::before { content: "→"; color: var(--accent); flex: none; }

.cta-band {
  margin: 3em 0 0; padding: 22px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
}
.cta-band p { margin: 0; color: var(--muted); }
.cta-band strong { color: var(--text); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 8px;
  font-weight: 600; font-size: 15px; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer;
  min-height: 44px;
  transition: transform .12s ease, background-color .12s ease, border-color .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn--primary { background: var(--accent); color: #10171F; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn--ghost { border-color: color-mix(in srgb, var(--line) 60%, var(--text)); color: var(--text); background: transparent; }
.btn--ghost:hover { border-color: var(--accent); }

/* ---------- карточки / сетки ---------- */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 8px;
}
.card h3 { margin: 0; font-size: 1.06rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card .more { margin-top: auto; padding-top: 10px; font-size: .93rem; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

a.card { color: inherit; }
a.card:hover { text-decoration: none; }

/* ---------- герой ---------- */
.hero { padding: 56px 0 44px; border-bottom: 1px solid var(--line); }
.hero h1 { max-width: 20ch; margin-bottom: .45em; }
.hero .lede { font-size: 1.16rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-top: 40px;
}
.hero-facts div { background: var(--surface); padding: 16px 18px; }
.hero-facts dt { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.hero-facts dd { margin: 0; font-size: 1.12rem; font-weight: 640; font-variant-numeric: tabular-nums; }

/* ---------- секции ---------- */
section.band { padding: 52px 0; border-bottom: 1px solid var(--line); }
section.band:last-of-type { border-bottom: 0; }
.section-head { margin-bottom: 26px; }
.section-head h2 { margin: 0 0 .3em; }
.section-head p { color: var(--muted); margin: 0; max-width: 62ch; }

/* ---------- список статей ---------- */
ul.post-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
ul.post-list li { margin: 0; background: var(--surface); }
ul.post-list a { display: block; padding: 15px 18px; color: inherit; }
ul.post-list a:hover { background: var(--surface-2); text-decoration: none; }
ul.post-list .t { font-weight: 600; }
ul.post-list .d { color: var(--muted); font-size: .91rem; margin-top: 3px; }
ul.post-list .m { color: var(--muted); font-size: 12px; margin-top: 6px; font-family: var(--font-mono); }

/* ---------- FAQ ---------- */
.faq { max-width: var(--max-text); }
.faq details {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 8px; overflow: hidden;
}
.faq summary {
  cursor: pointer; padding: 14px 18px; font-weight: 600; font-size: .98rem;
  list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-family: var(--font-mono); font-size: 1.1rem; flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq .a { padding: 0 18px 16px; color: var(--muted); font-size: .96rem; }
.faq .a p { margin: 0; }

/* ---------- подвал ---------- */
footer.site {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 40px 0 34px; margin-top: 20px; font-size: 14.5px;
}
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 30px; }
.foot-grid h4 { margin: 0 0 10px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.foot-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.foot-grid a { color: var(--muted); }
.foot-grid a:hover { color: var(--text); }
.foot-legal {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 8px 20px;
}

/* ---------- поиск ---------- */
.search-box { position: relative; margin: 22px 0; }
.search-box input {
  width: 100%; padding: 13px 16px; font-size: 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit;
}
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search-results { margin-top: 18px; }
.search-results .hit { padding: 14px 0; border-bottom: 1px solid var(--line); }
.search-results .hit a { font-weight: 600; font-size: 1.02rem; }
.search-results .hit p { margin: 4px 0 0; color: var(--muted); font-size: .93rem; }
.search-results mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); padding: 0 2px; border-radius: 2px; }

/* ---------- служебные страницы ---------- */
.error-page { padding: 100px 0; text-align: center; }
.error-code { font-family: var(--font-mono); font-size: clamp(3rem, 12vw, 7rem); color: var(--surface-2); font-weight: 700; line-height: 1; margin-bottom: 8px; }

/* ---------- адаптив ---------- */
@media (max-width: 860px) {
  body { font-size: 16.5px; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .head-in { min-height: 56px; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  nav.main {
    display: none; width: 100%; margin: 0 0 12px;
    flex-direction: column; align-items: stretch; gap: 2px;
  }
  nav.main.open { display: flex; }
  nav.main a { padding: 12px; font-size: 16px; }
  .theme-toggle { order: 2; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 30px; }
  section.band { padding: 36px 0; }
  .foot-grid { grid-template-columns: 1fr; gap: 22px; }
  .page-head { padding: 28px 0 4px; }
  pre { padding: 12px; border-radius: 8px; }
  .cta-band { flex-direction: column; align-items: flex-start; }
  .cta-band .btn { width: 100%; justify-content: center; }
}

/* скроллбар в тон теме */
html { scrollbar-color: #2C3A4A var(--bg); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2C3A4A; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3D4F63; }
html[data-theme="light"] { scrollbar-color: #C3CBD5 var(--bg); }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #C3CBD5; }

/* схема: не сжимать до нечитаемого, а прокручивать */
figure { margin: 0; }
figure > svg, figure > .schema-scroll > svg { min-width: 640px; }
.schema-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.schema-scroll::after {
  content: "← схема прокручивается по горизонтали →";
  display: block; text-align: center; color: var(--muted);
  font-size: 12px; margin-top: 6px;
}
@media (min-width: 700px) {
  figure > svg, figure > .schema-scroll > svg { min-width: 0; }
  .schema-scroll { overflow: visible; }
  .schema-scroll::after { display: none; }
}

/* ---------- печать ---------- */
@media print {
  header.site, footer.site, .cta-band, .copy-btn, .theme-toggle, .menu-toggle, nav.main { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; text-decoration: underline; }
  pre, .card, table { border-color: #ccc; }
  h1, h2, h3 { page-break-after: avoid; }
}
