/* noosphere-web — стиль публичной энциклопедии.
   Сдержанно: системный шрифт, читаемая колонка, минимум декора.
   Тёмная тема — по prefers-color-scheme. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-header: rgba(255, 255, 255, 0.92);
  --fg: #1b1b1f;
  --fg-muted: #5a5a66;
  --fg-faint: #8a8a96;
  --border: #e6e6ea;
  --border-strong: #d2d2d8;
  --accent: #2b5bd7;
  --accent-hover: #1f47a8;
  --btn-bg: #2b5bd7;
  --btn-fg: #ffffff;
  --btn-hover-bg: #1f47a8;
  --badge-group-bg: #eef1fb;
  --badge-group-fg: #3a52b0;
  --badge-article-bg: #eef0f2;
  --badge-article-fg: #555861;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06);
  --radius: 6px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16161a;
    --bg-soft: #1e1e24;
    --bg-header: rgba(22, 22, 26, 0.92);
    --fg: #e8e8ec;
    --fg-muted: #a0a0ac;
    --fg-faint: #70707c;
    --border: #2a2a32;
    --border-strong: #3a3a44;
    --accent: #aac8ff;
    --accent-hover: #8db4ff;
    --btn-bg: #aac8ff;
    --btn-fg: #0b1a3a;
    --btn-hover-bg: #c4d8ff;
    --badge-group-bg: #20243a;
    --badge-group-fg: #a8c0ff;
    --badge-article-bg: #262630;
    --badge-article-fg: #b0b0bc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
}
@supports not ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) {
  .site-header { background: var(--bg); }
}

.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.search-form {
  display: flex;
  flex: 1 1 auto;
  max-width: 380px;
  margin-left: auto;
  gap: 0;
}
.search-form input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 11px;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  outline: none;
}
.search-form input[type="search"]:focus {
  border-color: var(--accent);
  background: var(--bg);
}
.search-form button {
  padding: 7px 14px;
  font-size: 14px;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  white-space: nowrap;
}
.search-form button:hover { background: var(--btn-hover-bg); border-color: var(--btn-hover-bg); }

/* --- main --- */
.main {
  padding-top: 28px;
  padding-bottom: 64px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.lead {
  font-size: 18px;
  line-height: 1.55;
  color: var(--fg);
  margin: 0 0 20px;
  font-weight: 400;
}

/* --- breadcrumbs --- */
.breadcrumbs {
  margin-bottom: 20px;
  font-size: 14px;
}
.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.breadcrumbs li {
  display: flex;
  align-items: center;
  color: var(--fg-faint);
}
.breadcrumbs li::after {
  content: "›";
  margin: 0 7px;
  color: var(--fg-faint);
  font-size: 15px;
}
.breadcrumbs li:last-child::after { content: ""; }
.breadcrumbs a {
  color: var(--fg-muted);
  text-decoration: none;
}
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .crumb-current {
  color: var(--fg);
  font-weight: 500;
}

/* --- child list (browse) --- */
.child-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.child-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 12px;
  margin: 0 -12px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background-color 0.12s ease;
}
.child-item:hover { background: var(--bg-soft); }
.child-link {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-decoration: none;
  color: var(--fg);
  min-width: 0;
}
.child-title {
  font-weight: 600;
  font-size: 16px;
}
.child-link:hover .child-title { color: var(--accent); }
.child-summary {
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-group { background: var(--badge-group-bg); color: var(--badge-group-fg); }
.badge-article { background: var(--badge-article-bg); color: var(--badge-article-fg); }

/* --- article body (goldmark output) --- */
.article-body {
  font-size: 17px;
  line-height: 1.7;
  color: var(--fg);
}
.article-body p { margin: 0 0 18px; }
.article-body h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 12px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.article-body h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 26px 0 10px;
}
.article-body ul, .article-body ol { margin: 0 0 18px; padding-left: 26px; }
.article-body li { margin-bottom: 6px; }
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.article-body a:hover { color: var(--accent-hover); }
.article-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
}
.article-body pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}
.article-body pre code { background: none; padding: 0; }
.article-body blockquote {
  margin: 0 0 18px;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--border-strong);
  color: var(--fg-muted);
}
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* --- sources / related --- */
.sources, .related {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.source-list, .related-list {
  margin: 0;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.7;
}
.source-list a, .related-list a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.updated {
  margin-top: 32px;
  font-size: 13px;
  color: var(--fg-faint);
}

/* --- search page --- */
.search-form-page {
  max-width: 100%;
  margin: 0 0 24px;
}
.search-form-page input[type="search"] {
  padding: 10px 14px;
  font-size: 16px;
}
.search-form-page button { padding: 10px 20px; font-size: 16px; }

.result-count {
  font-size: 14px;
  color: var(--fg-muted);
  margin: 0 0 16px;
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}
.search-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.search-title {
  flex: 1 1 auto;
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 4px;
}
.search-title:hover { color: var(--accent); }
.search-summary {
  flex: 1 1 100%;
  font-size: 14px;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.5;
}
.search-badge {
  flex: 0 0 auto;
  margin-top: 3px;
}

/* --- pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  font-size: 14px;
}
.pagination a {
  color: var(--accent);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pagination a:hover { background: var(--bg-soft); border-color: var(--border-strong); }
.pg-current {
  color: var(--btn-fg);
  background: var(--btn-bg);
  padding: 6px 14px;
  border: 1px solid var(--btn-bg);
  border-radius: var(--radius);
  font-weight: 500;
}

/* --- empty / error states --- */
.empty-note {
  color: var(--fg-muted);
  font-size: 15px;
  padding: 24px 0;
}
.empty-base, .error-block {
  padding: 16px 0;
}
.error-block .lead { color: var(--fg-muted); }
.error-block a { color: var(--accent); }

/* --- footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  font-size: 13px;
  color: var(--fg-faint);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.footer-nav {
  display: flex;
  gap: 18px;
}
.site-footer a {
  color: var(--fg-muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent); }

/* --- responsive --- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .page-title { font-size: 23px; }
  .lead { font-size: 16px; }
  .article-body { font-size: 16px; line-height: 1.65; }
  .article-body h2 { font-size: 20px; }
  .header-row { min-height: 48px; gap: 10px; }
  .brand { font-size: 16px; }
  .search-form { max-width: none; }
  .search-form button { padding: 7px 10px; }
  .child-item { flex-direction: row; }
  .badge { order: 2; }
  .site-footer .container { flex-direction: column; align-items: flex-start; gap: 6px; }
}

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