/* ========================================================================
   Тема и токены
   ===================================================================== */
:root {
  --accent: #f6821f;
  --accent-soft: rgba(246, 130, 31, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1080px;
  --wrap-wide: 1280px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 32px -18px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] {
  --bg: #0b0d11;
  --bg-soft: #0f1218;
  --surface: #14181f;
  --surface-2: #1a1f28;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9edf2;
  --muted: #98a2b0;
  --code-bg: #0d1017;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #fbfaf8;
  --bg-soft: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --border: rgba(15, 20, 30, 0.1);
  --border-strong: rgba(15, 20, 30, 0.2);
  --text: #171b21;
  --muted: #5f6a78;
  --code-bg: #f5f5f2;
  color-scheme: light;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(80% 100% at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

a { color: inherit; }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.22; font-weight: 660; letter-spacing: -0.02em; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
main { flex: 1 0 auto; padding: 40px 0 72px; }
main.wide .wrap { max-width: var(--wrap-wide); }
.icon { flex: none; }
.icon-dim { opacity: 0.5; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ========================================================================
   Шапка
   ===================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
/* Знак в шапке. Вариант выбирается полем brand в content/site.yml:
   dot (по умолчанию) · avatar · terminal · initials */
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  font-size: 1.02rem; font-weight: 560; letter-spacing: -0.015em;
}
.brand-name { white-space: nowrap; }
.brand-soft { color: var(--muted); font-weight: 460; transition: color 0.15s; }
.brand:hover .brand-soft { color: var(--text); }

/* dot — имя и акцентная точка */
.brand-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  margin-left: -4px; align-self: flex-end; margin-bottom: 6px; transition: transform 0.15s;
}
.brand:hover .brand-dot { transform: scale(1.5); }

/* avatar — фото вместо плашки */
.brand-avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-2);
}

/* terminal — моноширинный путь с курсором */
.brand-mono { font-family: var(--mono); font-size: 0.94rem; font-weight: 500; }
.brand-mono .caret {
  display: inline-block; width: 7px; height: 1em; margin-left: 3px; vertical-align: -0.14em;
  background: var(--accent); animation: caret-blink 1.2s step-end infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* initials — прежняя плашка с монограммой */
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #1b1206; font-size: 0.76rem; font-weight: 700;
}
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a {
  padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-size: 0.94rem; transition: color 0.15s, background 0.15s;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a.is-active { color: var(--text); background: var(--surface-2); }
.header-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--muted); cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.only-mobile { display: none; }
html[data-theme="dark"] .theme-sun { display: none; }
html[data-theme="light"] .theme-moon { display: none; }
.icon-btn span { display: grid; place-items: center; }

/* ========================================================================
   Главная
   ===================================================================== */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 36px; align-items: center;
  padding: 26px 0 46px;
}
.hero-kicker { color: var(--accent); font-weight: 600; margin: 0 0 6px; letter-spacing: 0.02em; }
.hero h1 { margin-bottom: 10px; }
.hero-tagline { color: var(--muted); font-size: 1.1rem; max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.avatar {
  width: 168px; height: 168px; border-radius: 26px; object-fit: cover;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.avatar-empty {
  display: grid; place-items: center; font-size: 3rem; font-weight: 700; color: #1b1206;
  background: linear-gradient(140deg, var(--accent), #ffc078);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 0.94rem; font-weight: 520;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: 620; }
.btn-accent:hover { filter: brightness(1.06); }

.section { margin: 56px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; }
.section-sub { color: var(--muted); margin: 4px 0 0; font-size: 0.92rem; }
.more {
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  text-decoration: none; font-size: 0.92rem; white-space: nowrap;
}
.more:hover { color: var(--accent); }

/* ========================================================================
   Карточки
   ===================================================================== */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.grid-albums { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.list { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-link { position: absolute; inset: 0; z-index: 3; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.card-body h3 { margin: 0; }
.card-body p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.card-row .card-body { padding: 18px 20px; }
.card-row:hover h3 { color: var(--accent); }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.card-badges:empty { display: none; }

.cover { width: 100%; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.card:hover .cover img { transform: scale(1.035); }
.cover-empty {
  display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; color: var(--muted);
  background: linear-gradient(140deg, var(--surface-2), var(--surface));
}

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.76rem; font-weight: 600;
}
.badge-soft { background: var(--surface-2); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem;
}
.meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 0.86rem; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta a { color: inherit; }

/* ========================================================================
   Списковые страницы
   ===================================================================== */
.page-head { margin-bottom: 28px; }
.page-head h1 { margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 65ch; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: 600; }
.empty {
  grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ========================================================================
   Документация проектов / статьи
   ===================================================================== */
.doc-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) 200px; gap: 36px; align-items: start; }
.doc-layout > .doc-main { min-width: 0; }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 40px; align-items: start; }
.article { min-width: 0; max-width: 76ch; }

.sidebar { position: sticky; top: 84px; }
.sidebar-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 10px; }
.doc-nav { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); }
.doc-nav a {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: 0.92rem;
}
.doc-nav a:hover { color: var(--text); }
.doc-nav a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 560; }

.toc { position: sticky; top: 84px; font-size: 0.87rem; }
.toc-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
.toc a:hover, .toc a.is-active { color: var(--accent); }
.toc .toc-l3 { padding-left: 12px; font-size: 0.84rem; }

.post-cover { margin: 8px 0 28px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

/* ========================================================================
   Типографика контента
   ===================================================================== */
.prose { font-size: 1.02rem; }
.prose > *:first-child { margin-top: 0; }
.prose h2 { margin-top: 2em; padding-top: 0.2em; }
.prose h3 { margin-top: 1.6em; }
.prose a { color: var(--accent); text-decoration-color: var(--accent-soft); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: 0.3em 0; }
.prose li::marker { color: var(--muted); }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 1.2em 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }
.prose blockquote {
  margin: 1.4em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--accent);
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.anchor { margin-left: 8px; color: var(--muted); opacity: 0; text-decoration: none; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 0.6; }

code {
  font-family: var(--mono); font-size: 0.88em; padding: 0.15em 0.4em;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
}
pre {
  position: relative; margin: 1.3em 0; padding: 16px 18px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
pre code { padding: 0; background: none; border: none; font-size: 0.86rem; line-height: 1.6; }
pre[data-lang]::after {
  content: attr(data-lang); position: absolute; top: 8px; right: 12px;
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px; padding: 4px 9px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 0.72rem; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }

.table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 620; }
tbody tr:last-child td { border-bottom: none; }

.alert {
  margin: 1.4em 0; padding: 14px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--surface);
}
.alert-title { margin: 0 0 6px; font-weight: 640; color: var(--accent); font-size: 0.9rem; }
.alert p:last-child { margin-bottom: 0; }
.alert-warning, .alert-caution { border-left-color: #e5534b; }
.alert-warning .alert-title, .alert-caution .alert-title { color: #e5534b; }
.alert-tip { border-left-color: #3fb950; }
.alert-tip .alert-title { color: #3fb950; }
.alert-important { border-left-color: #a371f7; }
.alert-important .alert-title { color: #a371f7; }

.task-list { list-style: none; padding-left: 0.2em; }
.task-item { display: inline-flex; gap: 8px; align-items: baseline; }

.downloads { margin-top: 44px; }
.download-list { display: flex; flex-direction: column; gap: 10px; }
.download {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color 0.15s, transform 0.12s;
}
.download:hover { border-color: var(--accent); transform: translateY(-1px); }
.download span { display: flex; flex-direction: column; margin-right: auto; }
.download em { font-style: normal; color: var(--muted); font-size: 0.82rem; }

.pager { display: flex; gap: 12px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager:empty { display: none; }
.pager-item {
  display: flex; align-items: center; gap: 10px; flex: 1; padding: 12px 16px; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted);
}
.pager-item:hover { border-color: var(--accent); color: var(--text); }
.pager-item span { display: flex; flex-direction: column; }
.pager-item em { font-style: normal; font-size: 0.76rem; }
.pager-item strong { color: var(--text); font-weight: 560; font-size: 0.94rem; }
.pager-next { justify-content: flex-end; text-align: right; }

/* ========================================================================
   Галерея и лайтбокс
   ===================================================================== */
.album-intro { margin-bottom: 28px; max-width: 70ch; }
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tile { margin: 0; cursor: zoom-in; }
.tile-media {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
}
.tile-media img, .tile-media video { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s; }
.tile:hover .tile-media img, .tile:hover .tile-media video { transform: scale(1.05); }
.tile .play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; backdrop-filter: blur(2px);
}
.tile figcaption { margin-top: 6px; font-size: 0.82rem; color: var(--muted); }

.lightbox {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 12, 0.94); padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img, .lightbox video { max-width: min(1200px, 92vw); max-height: 84vh; border-radius: 10px; }
.lb-caption {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); color: #e9edf2;
  font-size: 0.9rem; text-align: center; max-width: 80vw;
}
.lb-btn {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(20, 24, 31, 0.7); color: #fff; cursor: pointer;
}
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lb-close { top: 18px; right: 18px; transform: none; }
.lb-count { position: absolute; top: 26px; left: 24px; color: var(--muted); font-size: 0.85rem; }

/* ========================================================================
   Поиск
   ===================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(6, 8, 12, 0.6);
  backdrop-filter: blur(3px); padding: 14vh 20px 20px; display: flex; justify-content: center;
}
.overlay[hidden] { display: none; }
.search-panel {
  width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
.search-box { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-box input { flex: 1; border: none; background: none; color: var(--text); font: inherit; font-size: 1rem; outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.search-results li a {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: var(--radius-sm);
  text-decoration: none;
}
.search-results li.is-active a, .search-results li a:hover { background: var(--surface-2); }
.search-results .r-kind { font-size: 0.74rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.search-results .r-title { font-weight: 560; }
.search-results .r-sum { font-size: 0.85rem; color: var(--muted); }
.search-hint { margin: 0; padding: 9px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; }

/* ========================================================================
   Подвал, 404
   ===================================================================== */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 28px 0; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.footer-socials { display: flex; flex-wrap: wrap; gap: 8px; }
.social {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: 0.86rem;
}
.social:hover { color: var(--text); border-color: var(--accent); }
.footer-note { margin: 0; color: var(--muted); font-size: 0.85rem; }
.footer-note a { color: var(--muted); }
.footer-note a:hover { color: var(--accent); }

.notfound { text-align: center; padding: 80px 0; }
.code404 { font-family: var(--mono); font-size: 4rem; color: var(--accent); margin: 0; line-height: 1; }
.notfound .btn { margin-top: 18px; }

/* ========================================================================
   Адаптив
   ===================================================================== */
@media (max-width: 1080px) {
  .doc-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .doc-layout > .toc, .article-layout > .toc { display: none; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  main { padding: 24px 0 56px; }
  .only-mobile { display: grid; }
  .site-nav {
    position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; gap: 0; padding: 8px;
    background: var(--bg); border-bottom: 1px solid var(--border); display: none;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: 11px 14px; border-radius: var(--radius-sm); }
  .hero { grid-template-columns: 1fr; gap: 22px; padding-bottom: 30px; }
  .hero-side { order: -1; }
  .avatar { width: 104px; height: 104px; border-radius: 20px; }
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
  .doc-nav { flex-direction: row; overflow-x: auto; border-left: none; border-bottom: 1px solid var(--border); }
  .doc-nav a { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .doc-nav a.is-active { border-bottom-color: var(--accent); }
  .section { margin: 40px 0; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pager { flex-direction: column; }
  .overlay { padding-top: 8vh; }
}

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