/*
Theme Name: MCM Wiki
Theme URI: https://wiki.mcm.ru/
Author: Мультиком
Description: Фирменная тема базы знаний Платформы Мультиком. Компактный хэдер, адаптивная мобильная версия, правая колонка с оглавлением.
Version: 1.3
License: GPL v2 or later
Text Domain: mcm-wiki
*/

:root {
  --brand: #ff7a00;
  --brand-h: #e66a00;
  --brand-soft: #fff3e6;
  --brand-softer: #fff8f0;
  --dark: #1e1e1e;
  --darker: #121212;
  --text: #2a2a2a;
  --muted: #6b7280;
  --border: #e6e6e6;
  --surface: #ffffff;
  --bg: #f7f7f8;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
  --header-h: 50px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: underline; text-decoration-color: rgba(255,122,0,.35); text-underline-offset: 3px; }
a:hover { color: var(--brand-h); text-decoration-color: currentColor; }

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

/* ===== Header (компактный) ===== */
.mcm-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--dark);
  border-bottom: 2px solid var(--brand);
  color: #fff;
}
.mcm-header-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 20px;
  display: flex; align-items: center; gap: 20px;
  min-height: var(--header-h);
}
.mcm-logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none; min-width: 0; flex-shrink: 0;
}
.mcm-logo:hover { color: #fff; }
.mcm-logo img { height: 30px; width: auto; display: block; }
.mcm-logo-sub {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--brand); font-weight: 700;
  padding-left: 10px; border-left: 1px solid rgba(255,255,255,.18);
  white-space: nowrap;
}
.mcm-search { flex: 1; max-width: 560px; margin-left: auto; position: relative; }
.mcm-search input {
  width: 100%; padding: 7px 14px 7px 36px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fff;
  font-size: .9rem; line-height: 1.3;
}
.mcm-search input::placeholder { color: rgba(255,255,255,.55); }
.mcm-search input:focus { outline: none; border-color: var(--brand); background: rgba(255,255,255,.12); }
.mcm-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: rgba(255,255,255,.55);
}

/* ===== Mobile menu toggle ===== */
.mcm-menu-toggle {
  display: none; align-items: center; gap: 6px;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: .82rem;
}
.mcm-menu-toggle svg { width: 18px; height: 18px; }
.mcm-menu-toggle:hover { background: rgba(255,255,255,.08); }

/* ===== Hero ===== */
.mcm-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  color: #fff; padding: 72px 24px;
}
.mcm-hero::before, .mcm-hero::after {
  content: ""; position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,122,0,.3) 0%, transparent 70%);
  pointer-events: none;
}
.mcm-hero::before { top: -20%; right: -10%; width: 500px; height: 500px; }
.mcm-hero::after  { bottom: -30%; left: -10%; width: 400px; height: 400px; }
.mcm-hero-inner { max-width: 900px; margin: 0 auto; position: relative; z-index: 1; text-align: center; }
.mcm-hero h1 { font-size: 2.4rem; margin: 0 0 14px; font-weight: 800; letter-spacing: -0.02em; }
.mcm-hero p { font-size: 1.1rem; color: rgba(255,255,255,.78); margin: 0 0 28px; }
.mcm-hero-search {
  display: flex; gap: 8px; background: #fff; padding: 6px; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25); max-width: 620px; margin: 0 auto;
}
.mcm-hero-search svg { width: 20px; height: 20px; color: var(--muted); margin-left: 14px; align-self: center; flex-shrink: 0; }
.mcm-hero-search input {
  flex: 1; border: 0; padding: 10px 12px; font-size: 1rem; outline: none;
  color: var(--text); background: transparent; min-width: 0;
}
.mcm-hero-search button {
  border: 0; padding: 10px 22px; border-radius: 8px; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; font-size: 1rem;
}
.mcm-hero-search button:hover { background: var(--brand-h); }

/* ===== Containers ===== */
.mcm-container { max-width: 1280px; margin: 0 auto; padding: 48px 24px; }
.mcm-container-narrow { max-width: 780px; margin: 0 auto; padding: 48px 24px; }
.mcm-section-title { font-size: 1.7rem; margin: 0 0 28px; font-weight: 700; }

/* ===== Category grid (home) ===== */
.mcm-cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.mcm-cat-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; text-decoration: none; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.mcm-cat-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
  border-color: var(--brand); color: var(--text);
}
.mcm-cat-icon {
  width: 44px; height: 44px; border-radius: 10px; background: var(--brand-soft);
  color: var(--brand); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.mcm-cat-icon svg { width: 24px; height: 24px; }
.mcm-cat-card h3 { font-size: 1.1rem; margin: 0 0 6px; font-weight: 700; }
.mcm-cat-desc { color: var(--muted); margin: 0 0 10px; font-size: .9rem; }
.mcm-cat-count {
  display: inline-block; font-size: .75rem; color: var(--brand); font-weight: 600;
  background: var(--brand-soft); padding: 2px 10px; border-radius: 10px; margin-bottom: 10px;
}
.mcm-cat-topdocs { margin: 8px 0 0; padding: 0; list-style: none; }
.mcm-cat-topdocs li {
  font-size: .85rem; color: var(--muted); padding: 5px 0;
  border-top: 1px dashed var(--border);
}

/* ===== Article layout (3-col) ===== */
.mcm-article-shell {
  max-width: 1280px; margin: 0 auto; padding: 24px;
  display: grid; grid-template-columns: 260px minmax(0,1fr) 220px; gap: 28px; align-items: start;
}
.mcm-article-shell.no-toc { grid-template-columns: 260px minmax(0,1fr); }

.mcm-sidebar { position: sticky; top: calc(var(--header-h) + 12px); }
.mcm-sidebar-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px; max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
}
.mcm-sidebar-cat { margin: 2px 0; }
.mcm-sidebar-cat summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-weight: 600; color: var(--text); font-size: .9rem;
}
.mcm-sidebar-cat summary::-webkit-details-marker { display: none; }
.mcm-sidebar-cat summary:hover { background: var(--brand-softer); color: var(--brand); }
.mcm-sidebar-cat[open] > summary { background: var(--brand-soft); color: var(--brand); }
.mcm-sidebar-ico { width: 18px; height: 18px; color: var(--brand); display: inline-flex; flex-shrink: 0; }
.mcm-sidebar-ico svg { width: 18px; height: 18px; }
.mcm-sidebar-name { flex: 1; min-width: 0; }
.mcm-sidebar-chev { color: var(--muted); font-weight: 400; transition: transform .2s ease; }
.mcm-sidebar-cat[open] > summary .mcm-sidebar-chev { transform: rotate(90deg); color: var(--brand); }
.mcm-sidebar-cat ul { list-style: none; padding: 4px 0 8px 34px; margin: 0; }
.mcm-sidebar-cat ul li { padding: 1px 0; }
.mcm-sidebar-cat ul li a {
  display: block; padding: 6px 10px; border-radius: 6px;
  font-size: .86rem; color: var(--muted); text-decoration: none; line-height: 1.35;
}
.mcm-sidebar-cat ul li a:hover { background: var(--brand-softer); color: var(--brand); }
.mcm-sidebar-cat ul li.is-current > a {
  background: var(--brand); color: #fff; font-weight: 600;
}

/* ===== Article body ===== */
.mcm-article {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 36px 44px; min-width: 0;
}
.mcm-breadcrumbs { font-size: .82rem; color: var(--muted); margin: 0 0 14px; }
.mcm-breadcrumbs a { color: var(--muted); text-decoration: none; }
.mcm-breadcrumbs a:hover { color: var(--brand); }
.mcm-breadcrumbs span { margin: 0 6px; }
.mcm-article-title { font-size: 1.9rem; margin: 0 0 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.mcm-article-content { font-size: 1rem; line-height: 1.7; }
.mcm-article-content h2 {
  font-size: 1.4rem; margin: 32px 0 12px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.mcm-article-content h2:first-child { border: 0; padding-top: 0; margin-top: 0; }
.mcm-article-content h3 { font-size: 1.1rem; margin: 24px 0 8px; font-weight: 700; }
.mcm-article-content p { margin: 0 0 12px; }
.mcm-article-content ul, .mcm-article-content ol { padding-left: 22px; margin: 0 0 12px; }
.mcm-article-content li { margin: 4px 0; }
.mcm-article-content code {
  background: var(--brand-soft); color: #a04b00; padding: 2px 6px;
  border-radius: 4px; font-size: .9em; font-family: "SF Mono", Consolas, Monaco, monospace;
}
.mcm-article-content pre {
  background: #1e1e1e; color: #e6e6e6; padding: 14px 18px; border-radius: 10px;
  overflow-x: auto; font-size: .86rem; line-height: 1.5;
}
.mcm-article-content pre code { background: transparent; color: inherit; padding: 0; }
.mcm-article-content blockquote {
  border-left: 4px solid var(--brand); background: var(--brand-softer);
  margin: 16px 0; padding: 12px 16px; border-radius: 0 8px 8px 0; color: var(--text);
}
.mcm-article-content blockquote p:last-child { margin: 0; }
.mcm-article-content table {
  border-collapse: collapse; width: 100%; margin: 14px 0; font-size: .93rem;
}
.mcm-article-content th, .mcm-article-content td {
  border: 1px solid var(--border); padding: 9px 12px; text-align: left; vertical-align: top;
}
.mcm-article-content th { background: var(--brand-softer); font-weight: 600; }

.mcm-article-content kbd {
  background: #fafafa; border: 1px solid var(--border); border-bottom-width: 2px;
  padding: 1px 6px; border-radius: 4px; font-size: .85em; font-family: inherit;
}

/* ===== Prev/Next ===== */
.mcm-prevnext {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 44px;
  padding-top: 22px; border-top: 1px solid var(--border);
}
.mcm-prevnext a {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; text-decoration: none; color: var(--text); transition: all .15s ease;
}
.mcm-prevnext a:hover { border-color: var(--brand); background: var(--brand-softer); }
.mcm-next { text-align: right; }
.mcm-pn-label { font-size: .78rem; color: var(--brand); font-weight: 600; }
.mcm-pn-title { font-size: .93rem; font-weight: 500; }

/* ===== Right TOC ===== */
.mcm-toc { position: sticky; top: calc(var(--header-h) + 12px); }
.mcm-toc-inner {
  background: transparent; padding: 4px 0;
  max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
  border-left: 1px solid var(--border); padding-left: 18px;
}
.mcm-toc h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 0 0 10px; font-weight: 700;
}
.mcm-toc ol { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.mcm-toc li { margin: 0; padding: 0; }
.mcm-toc li.lvl-h3 { padding-left: 14px; }
.mcm-toc a {
  display: block; padding: 5px 0; color: var(--muted); text-decoration: none;
  border-left: 2px solid transparent; padding-left: 10px; margin-left: -12px;
  transition: all .15s ease; line-height: 1.35;
}
.mcm-toc a:hover { color: var(--brand); }
.mcm-toc a.is-active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }

/* ===== Category archive page ===== */
.mcm-cat-head {
  display: flex; gap: 18px; align-items: center; margin-bottom: 24px;
  padding: 22px; background: var(--brand-softer); border-radius: 12px; border: 1px solid var(--brand-soft);
}
.mcm-cat-head-ico {
  width: 56px; height: 56px; flex: 0 0 56px; border-radius: 12px;
  background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
}
.mcm-cat-head-ico svg { width: 28px; height: 28px; }
.mcm-cat-head h1 { margin: 0 0 4px; font-size: 1.55rem; font-weight: 800; }
.mcm-cat-intro { color: var(--muted); margin: 0; font-size: .95rem; }
.mcm-cat-articles { display: grid; gap: 10px; }
.mcm-cat-article {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 22px; text-decoration: none; color: var(--text); transition: all .15s ease;
}
.mcm-cat-article:hover { border-color: var(--brand); box-shadow: var(--shadow); color: var(--text); }
.mcm-cat-article h3 { margin: 0 0 4px; font-size: 1.05rem; color: var(--text); font-weight: 700; }
.mcm-cat-article p { margin: 0 0 6px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.mcm-cat-article-more { color: var(--brand); font-weight: 600; font-size: .85rem; }

/* ===== Search results ===== */
.mcm-back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.mcm-back:hover { color: var(--brand); }
.mcm-search-results { display: grid; gap: 14px; }
.mcm-search-results article {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 22px;
}
.mcm-search-results h2 { margin: 0 0 6px; font-size: 1.05rem; }
.mcm-search-results .excerpt { color: var(--muted); font-size: .9rem; margin: 0; }

/* ===== Footer ===== */
.mcm-footer {
  background: var(--dark); color: #fff; padding: 32px 24px;
  border-top: 2px solid var(--brand); margin-top: 56px;
}
.mcm-footer-inner {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; align-items: center;
}
.mcm-footer-brand strong { display: block; color: var(--brand); font-size: 1rem; margin-bottom: 4px; }
.mcm-footer-brand span { color: rgba(255,255,255,.7); font-size: .88rem; }
.mcm-footer-links { display: flex; gap: 20px; justify-content: center; }
.mcm-footer-links a { color: rgba(255,255,255,.8); text-decoration: none; font-size: .9rem; }
.mcm-footer-links a:hover { color: var(--brand); }
.mcm-footer-copy { color: rgba(255,255,255,.5); font-size: .8rem; text-align: right; }

/* ===== Sidebar backdrop (mobile) ===== */
.mcm-sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150;
}
.mcm-sidebar-close { display: none; justify-content: flex-end; margin-bottom: 8px; }
.mcm-sidebar-close button {
  background: var(--bg); border: 0; border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 1.2rem; color: var(--muted);
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .mcm-article-shell { grid-template-columns: 240px minmax(0,1fr); gap: 24px; }
  .mcm-toc { display: none; }
}
@media (max-width: 900px) {
  .mcm-article { padding: 28px 32px; }
}
@media (max-width: 820px) {
  .mcm-header-inner { padding: 6px 14px; gap: 10px; }
  .mcm-logo img { height: 26px; }
  .mcm-logo-sub { display: none; }
  .mcm-menu-toggle { display: inline-flex; }
  .mcm-search { order: 3; flex-basis: 100%; max-width: none; margin: 6px 0 0; }
  .mcm-search input { font-size: .85rem; padding: 6px 12px 6px 32px; }

  .mcm-hero { padding: 44px 20px; }
  .mcm-hero::before { width: 280px; height: 280px; }
  .mcm-hero::after  { width: 240px; height: 240px; }
  .mcm-hero h1 { font-size: 1.7rem; }
  .mcm-hero p { font-size: .95rem; margin-bottom: 20px; }
  .mcm-hero-search { flex-direction: column; padding: 10px; gap: 10px; }
  .mcm-hero-search svg { display: none; }
  .mcm-hero-search input {
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; width: 100%;
    background: var(--bg);
  }
  .mcm-hero-search button { width: 100%; padding: 11px; }

  .mcm-container { padding: 32px 16px; }
  .mcm-container-narrow { padding: 32px 16px; }
  .mcm-section-title { font-size: 1.35rem; margin-bottom: 18px; }
  .mcm-cat-grid { grid-template-columns: 1fr; gap: 12px; }
  .mcm-cat-card { padding: 18px; }

  .mcm-article-shell {
    grid-template-columns: 1fr; padding: 14px; gap: 14px;
  }
  .mcm-sidebar {
    position: fixed; top: 0; left: -100%; z-index: 200;
    width: 88%; max-width: 340px; height: 100dvh; padding: 12px;
    background: var(--surface); box-shadow: 8px 0 40px rgba(0,0,0,.15);
    transition: left .25s ease; overflow-y: auto;
  }
  .mcm-sidebar.is-open { left: 0; }
  .mcm-sidebar-inner { border: 0; padding: 4px; max-height: none; overflow: visible; }
  .mcm-sidebar-close { display: flex; }
  .mcm-sidebar-backdrop.is-open { display: block; }

  .mcm-article { padding: 18px 16px; border-radius: 10px; }
  .mcm-article-title { font-size: 1.3rem; }
  .mcm-article-content { font-size: .95rem; }
  .mcm-article-content h2 { font-size: 1.15rem; padding-top: 16px; margin-top: 26px; }
  .mcm-article-content h3 { font-size: 1rem; margin-top: 18px; }
  .mcm-article-content pre { padding: 10px 12px; font-size: .78rem; }
  .mcm-article-content table { display: block; overflow-x: auto; white-space: nowrap; }
  .mcm-article-content table th, .mcm-article-content table td { white-space: normal; }

  .mcm-breadcrumbs { font-size: .76rem; }
  .mcm-prevnext { grid-template-columns: 1fr; gap: 8px; margin-top: 28px; }
  .mcm-next { text-align: left; }

  .mcm-cat-head { padding: 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .mcm-cat-head-ico { width: 44px; height: 44px; flex-basis: auto; }
  .mcm-cat-head-ico svg { width: 22px; height: 22px; }
  .mcm-cat-head h1 { font-size: 1.3rem; }
  .mcm-cat-article { padding: 14px 16px; }

  .mcm-footer { padding: 24px 16px; margin-top: 32px; }
  .mcm-footer-inner { grid-template-columns: 1fr; gap: 14px; text-align: center; }
  .mcm-footer-links { justify-content: center; }
  .mcm-footer-copy { text-align: center; font-size: .78rem; }
}

@media (max-width: 480px) {
  .mcm-header-inner { padding: 6px 10px; gap: 8px; }
  .mcm-search input { font-size: .82rem; }
  .mcm-menu-toggle { padding: 5px 8px; }
  .mcm-menu-toggle span { display: none; }
  .mcm-hero { padding: 32px 16px; }
  .mcm-hero h1 { font-size: 1.35rem; }
  .mcm-hero p { font-size: .9rem; }
  .mcm-article { padding: 16px 14px; }
  .mcm-article-title { font-size: 1.15rem; margin-bottom: 16px; }
}
