/* Портал документации РОБОСТЭК — режим «карточки + чтение».
   Загружается ПОВЕРХ robostack.css (токены, шапка, кнопки оттуда).
   Только светлая тема — как у главной страницы. */

/* ---------- каркас ---------- */

.docs-main { padding: 48px 0 96px; min-height: 60vh; }

.view { animation: dview 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes dview {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- стартовая: карточки разделов ---------- */

.docs-home-head { max-width: 680px; margin-bottom: 40px; }
.docs-home-head .lede { font-size: 17.5px; color: var(--muted); }

.doc-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.doc-card {
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 24px; text-decoration: none; color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.doc-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-m); border-color: #cddcf5; }
.doc-card .num-chapters {
  font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px;
  padding: 6px 10px; align-self: flex-start;
}
.doc-card h2 { font-size: 22px; margin: 0; }
.doc-card p { margin: 0; font-size: 14px; color: var(--muted); }
.doc-card .go { margin-top: auto; font-weight: 700; font-size: 14px; color: var(--accent); }

/* ---------- поиск ---------- */

.docs-search { position: relative; margin: 34px 0 8px; max-width: 560px; }
.docs-search input {
  width: 100%; font: 400 15px/1 var(--font); color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px 13px 40px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.docs-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.docs-search::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 15px; height: 15px;
  transform: translateY(-50%);
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .8;
}
.search-hint { font: 500 12px/1.4 var(--mono); color: var(--muted); margin: 10px 0 0; }

/* ---------- список глав (режим раздела) ---------- */

.sec-head-block { margin: 8px 0 30px; }
.sec-crumb { font: 600 12px/1 var(--mono); letter-spacing: 0.06em; margin-bottom: 14px; }
.sec-crumb a { color: var(--muted); text-decoration: none; }
.sec-crumb a:hover { color: var(--accent); }
.sec-crumb span { color: var(--ink); }

.chapter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chapter-card {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: #fff; padding: 18px; text-decoration: none; color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.chapter-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-m); border-color: #cddcf5; }
.chapter-card .n {
  flex: none; min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font: 700 13px/1 var(--mono);
}
.chapter-card b { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.chapter-card .d { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.chapter-card.ext .n { background: var(--paper-2); color: var(--muted); }

/* ---------- режим чтения ---------- */

.read-top {
  position: sticky; top: 66px; z-index: 30;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.read-top .wrap { display: flex; align-items: center; gap: 14px; }
.read-top .sec-crumb { margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.read-actions { display: flex; gap: 8px; flex: none; }
.read-actions button, .read-actions a {
  font: 600 12px/1 var(--mono); color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; cursor: pointer; text-decoration: none;
}
.read-actions button:hover, .read-actions a:hover { color: var(--accent); border-color: var(--accent); }

.chapters-menu { position: relative; }
.chapters-menu > ul {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 320px; max-height: 60vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-m); padding: 8px; margin: 0; list-style: none;
}
.chapters-menu summary {
  list-style: none; cursor: pointer;
  font: 600 12px/1 var(--mono); color: var(--muted);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px;
  display: inline-block;
}
.chapters-menu summary::-webkit-details-marker { display: none; }
.chapters-menu[open] summary { color: var(--accent); border-color: var(--accent); }
.chapters-menu li a {
  display: flex; gap: 10px; align-items: baseline; border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; color: var(--ink); text-decoration: none;
}
.chapters-menu li a:hover { background: var(--accent-soft); }
.chapters-menu li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chapters-menu li a i { font: 700 11px/1 var(--mono); font-style: normal; color: var(--accent); min-width: 18px; }

/* мобильный: меню глав на всю ширину экрана с отступами — не вылезает */
@media (max-width: 760px) {
  .chapters-menu > ul {
    position: fixed;
    left: 12px; right: 12px; top: 122px;
    min-width: 0; width: auto;
    max-height: 62vh;
  }
}

/* статья */
.read { max-width: 780px; margin: 34px auto 0; padding: 0 24px; }
.toc-box { margin: 0 0 26px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); }
.toc-box summary {
  cursor: pointer; list-style: none; padding: 12px 16px;
  font: 600 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.toc-box summary::-webkit-details-marker { display: none; }
.toc-box .toc-list { padding: 0 16px 14px; display: grid; gap: 4px; }
.toc-box .toc-list a { font-size: 13.5px; color: var(--ink); text-decoration: none; }
.toc-box .toc-list a:hover { color: var(--accent); }
.toc-box .toc-list a.lvl-3 { padding-left: 16px; color: var(--muted); font-size: 13px; }

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
}
.pager a {
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 14px 18px; text-decoration: none; color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.pager a:hover { transform: translateY(-2px); box-shadow: var(--shadow-m); border-color: #cddcf5; }
.pager .dir { font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 6px; }
.pager .t { font-weight: 700; font-size: 14.5px; }
.pager a.next { text-align: right; }

/* ---------- markdown ---------- */

.md { font-size: 16.5px; color: var(--body, #2b3340); }
.md :is(h1,h2,h3,h4) { font-family: var(--font); color: var(--ink); letter-spacing: -0.01em; scroll-margin-top: 130px; }
.md h1 { font-size: 30px; font-weight: 900; margin: 0 0 18px; line-height: 1.15; }
.md h2 { font-size: 23px; font-weight: 900; margin: 36px 0 12px; }
.md h3 { font-size: 18px; font-weight: 700; margin: 26px 0 8px; }
.md p { margin: 0 0 14px; }
.md img {
  display: block; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-s); margin: 18px 0; max-width: 100%;
}
.md table { border-collapse: collapse; margin: 16px 0; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; }
.md th { background: var(--paper-2); }
.md code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}
.md pre { background: #0e1e35; color: #dbe7f8; border-radius: 12px; padding: 16px 18px; overflow-x: auto; }
.md pre code { border: none; background: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.6; }
.md blockquote {
  margin: 16px 0; padding: 10px 18px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--ink);
}
.md ol, .md ul { padding-left: 24px; margin: 0 0 14px; }
.md li { margin-bottom: 5px; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

/* критический блок руководства (красный — только безопасность) */
.stage-critical {
  border: 2px solid #c62828; border-radius: 10px;
  background: rgba(198, 40, 40, 0.06);
  padding: 6px 16px 10px; margin: 18px 0;
}
.stage-critical > :first-child { margin-top: 10px; }
.stage-critical > :last-child { margin-bottom: 4px; }

.callout {
  background: #fff; border: 1px dashed var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 14px 16px; font-size: 14.5px; color: var(--muted); margin: 16px 0;
}

/* ---------- адаптив ---------- */

@media (max-width: 900px) {
  .doc-cards { grid-template-columns: 1fr; }
  .chapter-grid { grid-template-columns: 1fr; }
  .read-top { top: 66px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}

@media print {
  .head, .foot, .read-top, .pager, .toc-box { display: none !important; }
  .read { max-width: none; margin: 0; padding: 0; }
}
