/* ---------------------------------------------------------------
   Страница «Прогнозы»: список файлов + отрендеренный markdown.
   Токены (цвета, радиусы, шрифт) берутся из styles.css — здесь только
   раскладка страницы и типографика текста.
   --------------------------------------------------------------- */

:root {
  --kind-month: #6d55b8;
  --kind-daily: var(--lv-p1);
  --kind-event: #b8791f;
  --kind-doc:   var(--ink-muted);
  --prose: 74ch;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --kind-event: #d9a441;
    --kind-month: #9b86e8;
  }
}
:root[data-theme="dark"] { --kind-event: #d9a441; --kind-month: #9b86e8; }

/* ---------- прогресс чтения ---------- */

.read-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 30;
  pointer-events: none;
}
.read-bar span {
  display: block;
  height: 100%;
  background: var(--lv-p1);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

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

.docs-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 60px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 220px;
  gap: 26px;
  align-items: start;
}

/* ---------- боковой список ---------- */

.doc-side__inner {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Нужна только на узком экране: там панель списка закрывает собой текст. */
.doc-side__close { display: none; align-self: flex-start; }

.doc-search input {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  color: inherit;
}
.doc-search input::placeholder { color: var(--ink-muted); }

.doc-search__count {
  margin: 6px 2px 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.chips--filter .chip { font-size: 12.5px; padding: 5px 11px; }

.doc-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
  margin-right: -4px;
}

.doc-list__empty {
  font-size: 13px;
  color: var(--ink-muted);
  padding: 12px 2px;
  margin: 0;
}

.doc-group {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 12px 0 2px;
  padding: 6px 2px 5px;
  background: var(--page);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.doc-group:first-child { margin-top: 0; }

.doc-item {
  display: flex;
  gap: 10px;
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 9px 11px 10px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .12s, background .12s;
}
.doc-item:hover { border-color: var(--ink-muted); }
.doc-item.is-active {
  border-color: var(--ink);
  box-shadow: inset 3px 0 0 var(--ink);
  background: var(--surface-2);
}

.doc-item__day {
  flex: 0 0 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--hairline);
  padding-right: 8px;
  color: var(--ink-2);
}
.doc-item__day b { font-size: 17px; font-weight: 640; font-variant-numeric: tabular-nums; }
.doc-item__day small { font-size: 10px; letter-spacing: 0.04em; color: var(--ink-muted); }
.doc-item__day--file { font-size: 17px; color: var(--ink-muted); }
/* «июл 2026» вместо числа — три буквы в 34px влезают только помельче. */
.doc-item__day--month b { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.02em; }

.doc-item__body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.doc-item__title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-item__meta {
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.doc-item__sum {
  font-size: 11.5px;
  line-height: 1.38;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Тип файла — точка + подпись: цвет здесь не единственный носитель смысла. */
.dot-kind {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--kind-doc);
  flex: none;
}
.dot-kind--daily { background: var(--kind-daily); }
.dot-kind--event { background: var(--kind-event); }
.dot-kind--month { background: var(--kind-month); }

/* ---------- карточка текста ---------- */

.doc-main { min-width: 0; }

.doc-side-toggle { display: none; margin-bottom: 12px; }

.doc-article {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 30px 36px 36px;
}
.doc-article:focus { outline: none; }

.doc-head { border-bottom: 1px solid var(--hairline); padding-bottom: 18px; }

.doc-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-muted);
}
.doc-head__sep { color: var(--hairline); }
.doc-head__file code { font-size: 11.5px; }

.doc-head h1 {
  font-size: 30px;
  line-height: 1.18;
  margin: 12px 0 0;
  max-width: 24ch;
  text-wrap: balance;
}

.doc-head__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.doc-head__actions .btn {
  font-size: 13px;
  text-decoration: none;
  color: inherit;
}
.doc-head__stamp { font-size: 11.5px; color: var(--ink-muted); margin-left: auto; }

.tag--month, .tag--daily, .tag--event, .tag--doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.tag--month::before, .tag--daily::before, .tag--event::before, .tag--doc::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--kind-doc);
}
.tag--daily::before { background: var(--kind-daily); }
.tag--event::before { background: var(--kind-event); }
.tag--month::before { background: var(--kind-month); }

.doc-empty { color: var(--ink-muted); font-size: 14px; }

/* ---------- типографика markdown ---------- */

.md-body {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  max-width: var(--prose);
}

.md-body > * { margin-top: 0; }
.md-body p { margin: 0 0 1em; }
.md-body p:last-child { margin-bottom: 0; }

.md-body h2, .md-body h3, .md-body h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  scroll-margin-top: 84px;
}

.md-body h2 {
  font-size: 21px;
  font-weight: 640;
  margin: 2.1em 0 .7em;
  padding-top: .85em;
  border-top: 1px solid var(--hairline);
}
.md-body h2:first-child { margin-top: .4em; border-top: none; padding-top: 0; }
/* В прогнозах разделы часто отбиты «---» — вторая линия подряд не нужна. */
.md-body hr + h2 { border-top: none; padding-top: 0; margin-top: 1.1em; }

.md-body h3 {
  font-size: 16.5px;
  font-weight: 640;
  margin: 1.7em 0 .5em;
  color: var(--ink);
}
.md-body h4 {
  font-size: 14px;
  font-weight: 640;
  margin: 1.4em 0 .4em;
  color: var(--ink-2);
}

/* Якорь у заголовка — для ссылки на конкретный раздел. */
.md-anchor {
  margin-left: 8px;
  font-weight: 400;
  color: var(--ink-muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity .12s;
}
.md-body :is(h1, h2, h3, h4):hover .md-anchor,
.md-anchor:focus-visible { opacity: 1; }

.md-body a { color: inherit; text-decoration-color: var(--ink-muted); text-underline-offset: 2px; }
.md-body a:hover { text-decoration-color: currentColor; }
.md-link--doc { text-decoration-style: dotted; }
.md-link--missing { color: var(--ink-muted); text-decoration-style: dashed; }

.md-body strong { font-weight: 650; }

.md-body ul, .md-body ol { margin: 0 0 1em; padding-left: 1.35em; }
.md-body li { margin: .3em 0; }
.md-body li > ul, .md-body li > ol { margin: .3em 0 .4em; }
.md-body li::marker { color: var(--ink-muted); }

.md-body hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 1.8em 0;
}

.md-body blockquote {
  margin: 1.2em 0;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--hairline);
  color: var(--ink-2);
}
.md-body blockquote p:last-child { margin-bottom: 0; }

.md-body code {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .87em;
}

.md-body pre {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow-x: auto;
  margin: 0 0 1.2em;
  font-size: 13px;
  line-height: 1.5;
}
.md-body pre code { background: none; border: none; padding: 0; font-size: inherit; }

.md-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* Таблицы в прогнозах широкие (дом/знак/сфера/описание) — им можно выйти
   за колонку текста, а на узком экране они прокручиваются вбок. */
.md-table {
  overflow-x: auto;
  margin: 0 0 1.3em;
  max-width: min(100%, 1000px);
  width: max-content;
  min-width: min(100%, 1000px);
}
.md-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.md-table th, .md-table td {
  border-bottom: 1px solid var(--hairline);
  padding: 8px 12px 8px 0;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}
.md-table th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  border-bottom-color: var(--ink-muted);
  white-space: nowrap;
}
.md-table tbody tr:hover { background: var(--surface-2); }
.md-table td:first-child { font-weight: 600; white-space: nowrap; }

/* ---------- содержание ---------- */

.doc-toc {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 12.5px;
}

.doc-toc__title {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.doc-toc__list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--hairline); }

.toc-item a {
  display: block;
  padding: 5px 10px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.35;
}
.toc-item a:hover { color: var(--ink); }
.toc-item a.is-active {
  color: var(--ink);
  border-left-color: var(--ink);
  font-weight: 600;
}
.toc-item--h3 a { padding-left: 22px; font-size: 12px; color: var(--ink-muted); }

/* ---------- соседние файлы ---------- */

.doc-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.doc-nav__link {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .12s;
}
.doc-nav__link:hover { border-color: var(--ink-muted); }
.doc-nav__link--next { text-align: right; grid-column: 2; }

.doc-nav__dir {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.doc-nav__title { font-size: 13px; font-weight: 600; line-height: 1.3; }

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

@media (max-width: 1240px) {
  .docs-wrap { grid-template-columns: 280px minmax(0, 1fr); }
  .doc-toc { display: none; }
}

@media (max-width: 1080px) {
  .docs-wrap { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 48px; }
  .doc-side-toggle { display: inline-flex; }

  /* Список на узком экране — выпадающая панель, чтобы текст начинался сразу. */
  .doc-side { display: none; }
  body.side-open .doc-side { display: block; }
  .doc-side__close { display: inline-flex; }
  body.side-open .doc-main { display: none; }
  .doc-side__inner { position: static; max-height: none; }
  .doc-list { max-height: none; overflow: visible; }

  .doc-article { padding: 20px 18px 26px; }
  .doc-head h1 { font-size: 24px; max-width: none; }
  .doc-head__stamp { margin-left: 0; }
  .md-body { font-size: 15.5px; }
  .md-table { min-width: 0; width: 100%; }
}

@media (max-width: 620px) {
  .doc-nav { grid-template-columns: minmax(0, 1fr); }
  .doc-nav__link--next { grid-column: 1; text-align: left; }
}

@media print {
  .doc-side, .doc-toc, .doc-nav, .read-bar, .page-nav,
  .doc-side-toggle, .doc-head__actions, .head-controls { display: none !important; }
  .docs-wrap { display: block; padding: 0; }
  .doc-article { border: none; padding: 0; background: none; }
  .md-body { max-width: none; font-size: 12pt; }
  .md-body h2, .md-table, .md-body li { break-inside: avoid; }
}
