/* ---------------------------------------------------------
 * Оформление inline-code и многострочных блоков кода
 * внутри статей Grav CMS / Mundana.
 *
 * Файл отвечает за:
 * - короткие вставки кода внутри текста: `inline code`;
 * - многострочные блоки кода: ```bash, ```yaml, ```css;
 * - фон, рамку, внутренние отступы и моноширинный шрифт кода;
 * - читаемость длинных команд и конфигурационных файлов.
 *
 * Не используется для обычных цитат <blockquote>,
 * сетевых схем, таблиц или карточек.
 * --------------------------------------------------------- */


/* ---------------------------------------------------------
 * 1. Inline code
 * --------------------------------------------------------- */

.article-post :not(pre) > code,
.post-content :not(pre) > code,
.page-content :not(pre) > code,
.item-content :not(pre) > code {
  color: #7a2331;
  background: #f3f5f7;
  border: 1px solid #d9e0e6;
  border-radius: 4px;
  padding: 0.14em 0.4em;
  font-size: 0.92em;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  white-space: break-spaces;
}

.article-post a code,
.post-content a code,
.page-content a code,
.item-content a code {
  color: inherit;
}


/* ---------------------------------------------------------
 * 2. Code blocks
 * --------------------------------------------------------- */

.article-post pre,
.post-content pre,
.page-content pre,
.item-content pre,
.article-post .highlight pre,
.post-content .highlight pre,
.page-content .highlight pre,
.item-content .highlight pre {
  background: #f6f8fa;
  border: 1px solid #d8e0e7;
  border-left: 4px solid #9db1c3;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
  line-height: 1.68;
  box-shadow: none;
  tab-size: 2;
}

.article-post pre code,
.post-content pre code,
.page-content pre code,
.item-content pre code,
.article-post .highlight pre code,
.post-content .highlight pre code,
.page-content .highlight pre code,
.item-content .highlight pre code {
  display: block;
  background: transparent !important;
  border: 0 !important;
  padding: 0;
  color: #1f2933;
  font-size: 0.94em;
  line-height: 1.68;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.article-post figure.highlight,
.post-content figure.highlight,
.page-content figure.highlight,
.item-content figure.highlight {
  margin: 1.25rem 0;
}

.article-post figure.highlight pre,
.post-content figure.highlight pre,
.page-content figure.highlight pre,
.item-content figure.highlight pre {
  margin: 0;
}
/* =========================================================
 * 3. Отдельный скроллбар для блоков кода
 * Не трогает горизонтальные линии <hr>
 * ========================================================= */

/* Блок кода: добавляем небольшой внутренний отступ снизу,
   чтобы горизонтальный скроллбар не лип к тексту */
.article-post pre,
.post-content pre,
.page-content pre,
.item-content pre,
.article-post .highlight pre,
.post-content .highlight pre,
.page-content .highlight pre,
.item-content .highlight pre {
  padding-bottom: 1.35rem !important;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #9db1c3 #eef3f7;
}


/* На мобильных ограничиваем высоту блока кода сильнее */
@media (max-width: 768px) {
  .article-post pre,
  .post-content pre,
  .page-content pre,
  .item-content pre,
  .article-post .highlight pre,
  .post-content .highlight pre,
  .page-content .highlight pre,
  .item-content .highlight pre {
    max-height: 320px;
  }
}

/* Chrome / Edge / Safari — скроллбар только внутри блоков кода */
.article-post pre::-webkit-scrollbar,
.post-content pre::-webkit-scrollbar,
.page-content pre::-webkit-scrollbar,
.item-content pre::-webkit-scrollbar,
.article-post .highlight pre::-webkit-scrollbar,
.post-content .highlight pre::-webkit-scrollbar,
.page-content .highlight pre::-webkit-scrollbar,
.item-content .highlight pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

/* Фон дорожки скроллбара в коде */
.article-post pre::-webkit-scrollbar-track,
.post-content pre::-webkit-scrollbar-track,
.page-content pre::-webkit-scrollbar-track,
.item-content pre::-webkit-scrollbar-track,
.article-post .highlight pre::-webkit-scrollbar-track,
.post-content .highlight pre::-webkit-scrollbar-track,
.page-content .highlight pre::-webkit-scrollbar-track,
.item-content .highlight pre::-webkit-scrollbar-track {
  background: #eef3f7 !important;
  border-radius: 999px;
}

/* Ползунок скроллбара в коде */
.article-post pre::-webkit-scrollbar-thumb,
.post-content pre::-webkit-scrollbar-thumb,
.page-content pre::-webkit-scrollbar-thumb,
.item-content pre::-webkit-scrollbar-thumb,
.article-post .highlight pre::-webkit-scrollbar-thumb,
.post-content .highlight pre::-webkit-scrollbar-thumb,
.page-content .highlight pre::-webkit-scrollbar-thumb,
.item-content .highlight pre::-webkit-scrollbar-thumb {
  background: #9db1c3 !important;
  border-radius: 999px;
  border: 2px solid #eef3f7 !important;
  box-shadow: none !important;
}

/* Наведение на скроллбар кода */
.article-post pre::-webkit-scrollbar-thumb:hover,
.post-content pre::-webkit-scrollbar-thumb:hover,
.page-content pre::-webkit-scrollbar-thumb:hover,
.item-content pre::-webkit-scrollbar-thumb:hover,
.article-post .highlight pre::-webkit-scrollbar-thumb:hover,
.post-content .highlight pre::-webkit-scrollbar-thumb:hover,
.page-content .highlight pre::-webkit-scrollbar-thumb:hover,
.item-content .highlight pre::-webkit-scrollbar-thumb:hover {
  background: #7f97aa !important;
}

/* Уголок скроллбара внутри блока кода */
.article-post pre::-webkit-scrollbar-corner,
.post-content pre::-webkit-scrollbar-corner,
.page-content pre::-webkit-scrollbar-corner,
.item-content pre::-webkit-scrollbar-corner,
.article-post .highlight pre::-webkit-scrollbar-corner,
.post-content .highlight pre::-webkit-scrollbar-corner,
.page-content .highlight pre::-webkit-scrollbar-corner,
.item-content .highlight pre::-webkit-scrollbar-corner {
  background: #eef3f7 !important;
}
