/* Оформление вики под интерфейс Nexus.
 *
 * Diplodoc собран на Gravity UI, поэтому тему не нужно переписывать
 * селекторами: достаточно подменить его переменные --g-color-* значениями
 * из frontend/src/styles/theme.css. Палитра здесь повторена намеренно —
 * вики собирается отдельно от фронта и его CSS не видит. Меняете тему
 * интерфейса — поправьте и эти значения.
 */

/* --- палитра: светлая тема --- */

.g-root_theme_light {
  --nexus-bg: #f4f1ec;
  --nexus-rail: #ebe5dd;
  --nexus-surface: #ffffff;
  --nexus-surface-2: #f7f4f0;
  --nexus-line: #ded5ca;
  --nexus-line-soft: #ebe4db;
  --nexus-text: #191512;
  --nexus-text-2: #675d54;
  --nexus-text-3: #968a7e;
  --nexus-accent: #b6592f;
  --nexus-accent-hover: #a24e28;
  --nexus-accent-soft: #f6e7de;
  --nexus-ok: #4c8659;
  --nexus-warn: #c08a2e;
  --nexus-err: #bc4a33;
}

/* --- палитра: тёмная тема --- */

.g-root_theme_dark {
  --nexus-bg: #131110;
  --nexus-rail: #191615;
  --nexus-surface: #1c1918;
  --nexus-surface-2: #221e1c;
  --nexus-line: #322c29;
  --nexus-line-soft: #272220;
  --nexus-text: #f0eae5;
  --nexus-text-2: #a4988f;
  --nexus-text-3: #776c65;
  --nexus-accent: #d97b4a;
  --nexus-accent-hover: #e78a58;
  --nexus-accent-soft: #33200f;
  --nexus-ok: #6aa878;
  --nexus-warn: #d3a44b;
  --nexus-err: #d96a52;
}

/* --- подмена токенов Gravity --- */

.g-root {
  --g-font-family-sans:
    -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, 'Helvetica Neue', sans-serif;

  --g-color-base-background: var(--nexus-bg);
  --g-color-base-float: var(--nexus-surface);
  --g-color-base-float-hover: var(--nexus-surface-2);
  --g-color-base-generic: var(--nexus-surface-2);
  --g-color-base-generic-hover: var(--nexus-accent-soft);
  --g-color-base-generic-ultralight: var(--nexus-surface-2);
  --g-color-base-simple-hover: var(--nexus-accent-soft);
  --g-color-base-misc-light: var(--nexus-accent-soft);

  --g-color-base-brand: var(--nexus-accent);
  --g-color-base-brand-hover: var(--nexus-accent-hover);
  --g-color-line-brand: var(--nexus-accent);
  --g-color-text-brand: var(--nexus-accent);
  --g-color-text-brand-heavy: var(--nexus-accent-hover);
  --g-color-text-link: var(--nexus-accent);
  --g-color-text-link-hover: var(--nexus-accent-hover);
  --g-color-text-link-visited: var(--nexus-accent);

  --g-color-text-primary: var(--nexus-text);
  --g-color-text-complementary: var(--nexus-text-2);
  --g-color-text-secondary: var(--nexus-text-2);
  --g-color-text-hint: var(--nexus-text-3);

  --g-color-line-generic: var(--nexus-line);
  --g-color-line-generic-hover: var(--nexus-line);
  --g-color-line-generic-active: var(--nexus-accent);
  --g-color-line-generic-solid: var(--nexus-line);
  --g-color-line-focus: var(--nexus-accent);

  --g-color-text-positive: var(--nexus-ok);
  --g-color-text-warning: var(--nexus-warn);
  --g-color-text-danger: var(--nexus-err);
  --g-color-line-positive: var(--nexus-ok);
  --g-color-line-warning: var(--nexus-warn);
  --g-color-line-danger: var(--nexus-err);
}

body.g-root {
  background: var(--nexus-bg);
}

/* --- логотип в шапке оглавления ---
 * Знак тот же, что в интерфейсе и на вкладке: шесть лучей из центра.
 * Вшит в CSS данными, а не отдельным файлом: сборка вики копирует только
 * перечисленные в .yfm ресурсы, и картинка рядом с ними бы потерялась.
 */

.dc-toc__top-header {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dc-toc__top-header::before {
  content: '';
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background-color: var(--nexus-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg stroke='white' stroke-width='1.9' stroke-linecap='round'%3E%3Cline x1='12' y1='12' x2='12' y2='3.4'/%3E%3Cline x1='12' y1='12' x2='18.8' y2='7.4'/%3E%3Cline x1='12' y1='12' x2='18.8' y2='16.6'/%3E%3Cline x1='12' y1='12' x2='12' y2='20.6'/%3E%3Cline x1='12' y1='12' x2='5.2' y2='16.6'/%3E%3Cline x1='12' y1='12' x2='5.2' y2='7.4'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='1.9' fill='white'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* --- оглавление сбоку --- */

.dc-toc {
  background: var(--nexus-rail);
  border-right: 1px solid var(--nexus-line);
}

.dc-toc__item_active > .dc-toc__list-item,
.dc-toc__list-item_active {
  color: var(--nexus-accent);
  font-weight: 500;
}

/* --- текст статьи --- */

.dc-doc-page__body,
.yfm {
  color: var(--nexus-text);
}

.yfm h1,
.yfm h2,
.yfm h3,
.dc-doc-page-title {
  letter-spacing: -0.015em;
  color: var(--nexus-text);
}

/* Тонкая линия под разделами: в длинных страницах она заменяет отбивку
   и держит ритм тот же, что в настройках интерфейса. */
.yfm h2 {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--nexus-line-soft);
}

.yfm a {
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* --- код --- */

.yfm code,
.yfm pre {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, 'Menlo', monospace;
}

.yfm :not(pre) > code {
  background: var(--nexus-accent-soft);
  color: var(--nexus-accent-hover);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.92em;
}

.yfm pre {
  background: var(--nexus-surface-2);
  border: 1px solid var(--nexus-line-soft);
  border-radius: 10px;
}

.yfm-clipboard-button {
  border-radius: 7px;
}

/* --- таблицы --- */

.yfm table {
  border-color: var(--nexus-line);
  border-radius: 10px;
  overflow: hidden;
}

.yfm table th {
  background: var(--nexus-surface-2);
  color: var(--nexus-text-2);
  font-weight: 600;
  text-align: left;
}

.yfm table th,
.yfm table td {
  border-color: var(--nexus-line-soft);
}

.yfm table tr:hover td {
  background: var(--nexus-surface-2);
}

/* --- заметки --- */

.yfm-note {
  border-radius: 12px;
  border: 1px solid var(--nexus-line);
  background: var(--nexus-surface-2);
}

.yfm-note_info {
  border-left: 3px solid var(--nexus-accent);
}

.yfm-note_tip {
  border-left: 3px solid var(--nexus-ok);
}

.yfm-note_warning {
  border-left: 3px solid var(--nexus-warn);
}

/* --- мелочи --- */

.dc-doc-page__content-mini-toc,
.dc-mini-toc {
  border-color: var(--nexus-line-soft);
}

.g-button_view_flat:hover {
  background: var(--nexus-accent-soft);
}
