/*
  Текст страниц (markdown) — как статьи во фронте: entities/post/ui/PostBody.tsx
  и RichTextView (shared/ui/RichTextEditor.tsx). Заголовки и жирное — основным цветом
  (чёрный / белый), текст — мягче (--liner-text, в tokens.css).
  Размеры в px: rem в Material — 20px, а не 16px, как во фронте.
  Кнопки — без подчёркивания: это не ссылки в тексте.
*/

.md-typeset {
  font-size: 14px;
  line-height: 1.625;
}

/* ---------- Заголовки ---------- */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  color: var(--liner-foreground);
  font-weight: var(--liner-font-weight-semibold);
  letter-spacing: normal;
}

/* Размеры и отступы — как у документа в «Рабочих инструкциях» (DocumentView → RichTextView):
   h1 — название записи (RecordPageHeader: text-lg font-medium), в тексте заголовки
   на ступень крупнее текста (h2 — text-base, h3/h4 — размером текста), абзацы — my-1 */
.md-typeset h1 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: var(--liner-font-weight-medium);
  line-height: 1.5;
}

.md-typeset h2 {
  margin: 16px 0 4px;
  font-size: 16px;
  line-height: 1.5;
}

.md-typeset h3 {
  margin: 12px 0 4px;
  font-size: 14px;
  line-height: 1.625;
}

.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  margin: 8px 0 4px;
  font-size: 14px;
  line-height: 1.625;
}

.md-typeset p {
  margin: 4px 0;
}

.md-typeset strong,
.md-typeset b {
  color: var(--liner-foreground);
  font-weight: var(--liner-font-weight-semibold);
}

/* ---------- Ссылки — акцентные и подчёркнутые, как в RichTextView ---------- */
.md-typeset a {
  text-decoration: underline;
}

.md-typeset a.md-button {
  text-decoration: none;
}

/* ---------- Код ---------- */
/* Строчный — на серой подложке со скруглением (bg-default rounded-md px-1.5 py-0.5) */
.md-typeset :not(pre) > code {
  padding: 2px 6px;
  border-radius: 6px;
}

/* Блок — как в мессенджерах (Telegram): лёгкий тон акцента, полоса слева и подпись языка
   сверху. Скругление и фон — у всего блока, у pre и code своих нет: иначе углы расходились */
.md-typeset .highlight {
  margin: 16px 0;
  overflow: hidden;
  border-left: 3px solid var(--liner-accent);
  border-radius: 8px;
  --liner-code-block: color-mix(in oklab, var(--liner-accent) 6%, var(--liner-surface));
  background-color: var(--liner-code-block);
}

.md-typeset .highlight pre,
.md-typeset .highlight pre > code {
  margin: 0;
  border-radius: 0;
  background: none;
}

.md-typeset .highlight pre > code {
  padding: 4px 16px 12px;
}

/* Кнопки «скопировать» и «выделить строки» — в углу всего блока, а не pre под подписью:
   ровно 8px сверху и справа. Видны при наведении на блок (или фокусе с клавиатуры).
   Подложка панели — цвет самого блока: закрывает код под кнопками, но не выделяется */
.md-typeset .highlight {
  position: relative;
}

.md-typeset .highlight pre {
  position: static;
}

.md-typeset .md-code__nav {
  top: 6px;
  right: 6px;
  z-index: 1;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background-color: var(--liner-code-block);
  opacity: 0;
  transition: opacity 150ms ease;
}

.md-typeset .highlight:hover .md-code__nav,
.md-typeset .highlight:focus-within .md-code__nav {
  opacity: 1;
}

/* На сенсорных экранах наведения нет — кнопки видны всегда */
@media (hover: none) {
  .md-typeset .md-code__nav {
    opacity: 1;
  }
}

.md-typeset .md-code__button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--liner-muted);
  transition: color 150ms ease, background-color 150ms ease;
}

.md-typeset .md-code__button:hover,
.md-typeset .md-code__button.focus-visible {
  background-color: var(--liner-default);
  color: var(--liner-foreground);
}

.md-typeset .md-code__button::after {
  width: 16px;
  height: 16px;
}

/* Подпись языка — мелко, акцентным полужирным, над кодом */
.md-typeset .highlight::before {
  display: block;
  padding: 8px 16px 0;
  color: var(--liner-accent);
  font-size: 12px;
  font-weight: var(--liner-font-weight-semibold);
  line-height: 16px;
  content: "Code";
}

.md-typeset .language-bash.highlight::before { content: "Bash"; }
.md-typeset .language-js.highlight::before { content: "JavaScript"; }
.md-typeset .language-json.highlight::before { content: "JSON"; }
.md-typeset .language-php.highlight::before { content: "PHP"; }

/* Под вкладками подпись дублировала бы название вкладки (CURL, PHP …) */
.md-typeset .tabbed-block > .highlight::before {
  display: none;
}

.md-typeset .tabbed-block > .highlight pre > code {
  padding-top: 12px;
}

/* ---------- Цитаты ---------- */
.md-typeset blockquote {
  border-left: 4px solid var(--liner-separator);
  color: var(--liner-muted);
}

/* ---------- Параметры API — строками, как ValueRow / DetailSection фронта ---------- */
/* В страницах API параметр размечен цитатой: `> **`name`** `type` <span style="float:right">*необязательный*</span>`
   и описание строкой ниже. Такие цитаты (начинаются с жирного кода) — не цитаты, а список:
   строки через разделитель, имя основным цветом, тип и «необязательный» — серыми плашками */
.md-typeset blockquote:has(> p:first-child > strong:first-child > code) {
  margin: 0;
  padding: 12px 0;
  border-left: none;
  border-bottom: 1px solid var(--liner-separator);
  color: var(--liner-text);
}

/* Первая строка списка — с чертой сверху: группа параметров отделена от текста над ней */
.md-typeset :not(blockquote) + blockquote:has(> p:first-child > strong:first-child > code),
.md-typeset blockquote:first-child:has(> p:first-child > strong:first-child > code) {
  margin-top: 8px;
  border-top: 1px solid var(--liner-separator);
}

.md-typeset blockquote:has(> p:first-child > strong:first-child > code) > p {
  margin: 0;
}

/* Имя параметра — моноширинным основным цветом, без подложки строчного кода */
.md-typeset blockquote > p:first-child > strong:first-child > code {
  padding: 0;
  background: none;
  color: var(--liner-foreground);
  font-size: 14px;
  font-weight: var(--liner-font-weight-semibold);
}

/* Тип — серой плашкой */
.md-typeset blockquote:has(> p:first-child > strong:first-child > code) > p:first-child > strong:first-child + code {
  margin-left: 4px;
  color: var(--liner-muted);
  font-size: 12px;
}

/* «необязательный» — пилюлей справа (pill фронта: bg-default rounded-full text-xs) */
.md-typeset blockquote:has(> p:first-child > strong:first-child > code) span[style*="float"] {
  padding: 0 8px;
  border-radius: 9999px;
  background-color: var(--liner-default);
  color: var(--liner-muted);
  font-size: 12px;
  line-height: 20px;
}

.md-typeset blockquote:has(> p:first-child > strong:first-child > code) span[style*="float"] em {
  font-style: normal;
}

/* ---------- Вкладки с примерами кода (=== "CURL") — как Tabs HeroUI ---------- */
/* Переключатель на серой подложке (tabs__list-container: bg-default, radius × 2.5, p-1),
   вкладки h-8 px-4 text-sm font-medium, выбранная — «таблетка» bg-segment с тенью.
   Таблетка — полоска-индикатор Material (::before): её положение и ширину он считает сам
   (--md-indicator-x/width) и двигает при переключении */
.md-typeset .tabbed-set {
  margin: 16px 0;
}

.md-typeset .tabbed-labels {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border-radius: 20px;
  background-color: var(--liner-default);
  box-shadow: none;
}

.md-typeset .tabbed-labels > label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border: none;
  border-radius: 9999px;
  color: var(--liner-muted);
  font-size: 14px;
  font-weight: var(--liner-font-weight-medium);
  transition: color 150ms ease, opacity 150ms ease;
}

/* С content.tabs.link Material оборачивает подпись вкладки в ссылку и отступы переносит на неё:
   подчёркивания ссылок в тексте у неё нет, отступы — те же, что у вкладки */
.md-typeset .tabbed-labels--linked > label {
  padding: 0;
}

.md-typeset .tabbed-labels--linked > label > a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  color: inherit;
  text-decoration: none;
}

.js .md-typeset .tabbed-labels::before {
  top: 4px;
  bottom: 4px;
  height: auto;
  border-radius: 9999px;
  background: var(--liner-segment);
  box-shadow: var(--liner-surface-shadow);
  transition: width 250ms cubic-bezier(0.32, 0.72, 0, 1), transform 250ms cubic-bezier(0.32, 0.72, 0, 1);
}

.md-typeset .tabbed-content {
  margin-top: 8px;
}

/* ---------- Таблицы: строками, без рамки; шапка приглушённая ---------- */
.md-typeset table:not([class]) {
  font-size: 14px;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.md-typeset table:not([class]) th {
  border-bottom: 1px solid var(--liner-separator);
  background: none;
  color: var(--liner-muted);
  font-weight: var(--liner-font-weight-medium);
}

.md-typeset table:not([class]) td {
  border-top: none;
  border-bottom: 1px solid var(--liner-separator);
}

.md-typeset table:not([class]) tbody tr:hover {
  background-color: transparent;
  box-shadow: none;
}

/* ---------- Примечания (!!! Note, !!! Рекомендация …) — как Banner фронта ---------- */
/* shared/ui/Banner.tsx поверх Alert HeroUI: подложка как у вложенной карточки, скругление
   rounded-2xl, полоса цвета статуса слева (border-s-3), значок статуса во весь рост двух строк
   (2.5rem, globals.css), заголовок text-sm font-semibold основным цветом, текст text-sm.
   Значки — китовые (Alert.Indicator). `[class]` — чтобы перебить цвета типов Material */
.md-typeset .admonition[class] {
  --liner-status: var(--liner-accent);
  --liner-status-icon: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-9.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0m-.25 3a.75.75 0 0 0-1.5 0V11a.75.75 0 0 0 1.5 0z'/></svg>");

  position: relative;
  display: flow-root;
  min-height: 72px;
  margin: 16px 0;
  padding: 16px 20px 16px 72px;
  border: none;
  border-left: 3px solid var(--liner-status);
  border-radius: 16px;
  background-color: var(--liner-surface-secondary);
  box-shadow: none;
  /* Текст — цветом текста страницы, а не muted, как у баннера: на серой подложке
     приглушённый читался плохо, а жирное в нём выглядело контрастным пятном */
  color: var(--liner-text);
  font-size: 14px;
}

.md-typeset .admonition[class] > .admonition-title {
  position: static;
  margin: 0 0 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--liner-foreground);
  font-weight: var(--liner-font-weight-semibold);
  line-height: 24px;
}

/* Значок — слева по центру плашки, как items-center у баннера */
.md-typeset .admonition[class] > .admonition-title::before {
  top: 50%;
  left: 20px;
  width: 40px;
  height: 40px;
  background-color: var(--liner-status);
  mask-image: var(--liner-status-icon);
  -webkit-mask-image: var(--liner-status-icon);
  transform: translateY(-50%);
}

.md-typeset .admonition[class] > p {
  margin: 0;
}

.md-typeset .admonition[class] > p + p {
  margin-top: 4px;
}

/* Типы → статусы Banner: accent (сведения), success (совет), warning, danger.
   Свои типы документации — note/recommendation и их русские варианты */
.md-typeset .admonition.recommendation,
.md-typeset .admonition.рекомендация,
.md-typeset .admonition.tip,
.md-typeset .admonition.hint,
.md-typeset .admonition.success,
.md-typeset .admonition.check,
.md-typeset .admonition.done {
  --liner-status: var(--liner-success);
  --liner-status-icon: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M13.5 8a5.5 5.5 0 1 1-11 0a5.5 5.5 0 0 1 11 0M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0m-3.9-1.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z'/></svg>");
}

.md-typeset .admonition.warning,
.md-typeset .admonition.caution,
.md-typeset .admonition.attention,
.md-typeset .admonition.важно,
.md-typeset .admonition.внимание {
  --liner-status: var(--liner-warning);
  --liner-status-icon: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M7.134 2.994L2.217 11.5a1 1 0 0 0 .866 1.5h9.834a1 1 0 0 0 .866-1.5L8.866 2.993a1 1 0 0 0-1.732 0m3.03-.75c-.962-1.665-3.366-1.665-4.329 0L.918 10.749c-.963 1.666.24 3.751 2.165 3.751h9.834c1.925 0 3.128-2.085 2.164-3.751zM8 5a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0v-2A.75.75 0 0 1 8 5m1 5.75a1 1 0 1 1-2 0a1 1 0 0 1 2 0'/></svg>");
}

.md-typeset .admonition.danger,
.md-typeset .admonition.error,
.md-typeset .admonition.failure,
.md-typeset .admonition.fail,
.md-typeset .admonition.missing,
.md-typeset .admonition.bug {
  --liner-status: var(--liner-danger);
  --liner-status-icon: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0M8.75 5a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0z'/></svg>");
}
