/*
 * Тема Prism на токенах дизайн-системы — для рабочего портала (в прототипе Prism нет).
 * Подключается ВМЕСТО prism.css / prism-custom.css, после components.css.
 *
 * Отдельная контрастная палитра синтаксиса для светлого фона блока кода.
 *
 * Разметка Prism остаётся как есть: <pre class="language-xml line-numbers"><code>…
 * Обёртка блока — компонент Code block (.p-code-block), см. docs/04-COMPONENTS.md.
 */

code[class*="language-"], pre[class*="language-"] {
  font: var(--c-text-body-2);
  font-family: var(--p-font-family-mono);
  color: var(--c-text-color-primary);
  background: none;
  text-shadow: none;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  hyphens: none;
}
pre[class*="language-"] {
  margin: 0;
  padding: var(--c-gap-3);
  overflow: auto;
  background: var(--c-fill-color-light);
  border-radius: 0;
}
:not(pre) > code[class*="language-"] {
  padding: var(--c-gap-025) var(--c-gap-1);
  background: var(--c-fill-color);
  border-radius: var(--c-border-radius-sm);
}
pre[class*="language-"] ::selection, code[class*="language-"] ::selection { background: var(--c-color-primary-100); }

.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--c-text-color-regular); font-style: italic; }
.token.punctuation, .token.operator { color: var(--c-text-color-regular); }
.token.tag, .token.selector, .token.property { color: #0550ae; }
.token.keyword, .token.boolean, .token.constant, .token.symbol { color: #8250df; }
.token.namespace, .token.attr-name, .token.number { color: #953800; }
.token.function, .token.class-name { color: #6639ba; }
.token.string, .token.attr-value, .token.entity, .token.url { color: #116329; }
.token.important, .token.bold { font-weight: var(--c-font-weight-bold); }
.token.italic { font-style: italic; }
.token.deleted { color: var(--c-color-error-600); }
.token.inserted { color: var(--c-color-success-600); }

/* плагин line-numbers */
pre[class*="language-"].line-numbers { position: relative; counter-reset: linenumber; }
pre[class*="language-"].line-numbers:has(.line-numbers-rows) { padding-left: calc(var(--c-gap-3) + var(--c-gap-9)); }
pre[class*="language-"].line-numbers > code { position: relative; white-space: inherit; }
.line-numbers .line-numbers-rows {
  position: absolute; pointer-events: none; top: 0; left: calc(var(--c-gap-9) * -1 - var(--c-gap-3));
  width: var(--c-gap-9); letter-spacing: normal; user-select: none;
  border-right: var(--c-border-width) solid var(--c-border-color-light);
  background: var(--c-fill-color);
}
.line-numbers-rows > span { display: block; counter-increment: linenumber; }
.line-numbers-rows > span::before {
  content: counter(linenumber); display: block;
  padding-right: var(--c-gap-3); text-align: right;
  color: var(--c-text-color-placeholder);
}

/* плагин toolbar + copy-to-clipboard: кнопка оформлена как .p-btn--text.p-btn--sm.
   Подписи задаются атрибутами на <pre>:
   data-prismjs-copy="Копировать" data-prismjs-copy-success="Скопировано"
   data-prismjs-copy-error="Не удалось скопировать" */
div.code-toolbar { position: relative; }
div.code-toolbar > .toolbar { position: absolute; top: var(--c-gap-1); right: var(--c-gap-2); z-index: 1; opacity: 1; display: flex; gap: var(--c-gap-1); }
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > span {
  display: inline-flex; align-items: center; gap: var(--c-gap-2);
  height: var(--c-control-size-sm); padding: 0 var(--c-gap-3);
  border: var(--c-border-width) solid transparent; border-radius: var(--c-border-radius-base);
  background: transparent; box-shadow: none; cursor: pointer;
  font: var(--c-text-controls); font-weight: var(--c-font-weight-semi-bold);
  color: var(--c-text-color-regular);
  transition: background-color var(--c-transition-duration), color var(--c-transition-duration);
}
div.code-toolbar > .toolbar > .toolbar-item > button:hover { background: var(--c-fill-color-light); color: var(--c-text-color-primary); }
div.code-toolbar > .toolbar > .toolbar-item > button:focus-visible { outline: var(--c-focus-outline); outline-offset: var(--c-focus-outline-offset); }
