/* ==========================================================================
   Раздел «База знаний»: список, карточки, блок вопросов, таблицы в теле статьи.
   Подключается из inc/kb.php после news.css. Токены --c-* объявлены на
   .nd-chrome в chrome.css, поэтому селекторы начинаются с него: без этого
   правила темы (a::after, p { margin-bottom: 24px }) перебивают наши.
   ========================================================================== */

.nd-chrome .nd-kb-hidden { display: none !important; }

/* ---------- поиск по заголовкам ---------- */

.nd-chrome .nd-kb-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 1 320px;
  max-width: 100%;
}
.nd-chrome .nd-kb-search__label {
  font-size: 0.78125rem;
  font-weight: 500;
  color: var(--c-ink-3);
}
.nd-chrome .nd-kb-search__input {
  width: 100%;
  border: 1px solid var(--c-line-2);
  border-radius: 4px;
  background-color: #fff;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 16px;      /* меньше 16px — iOS зумит форму */
  line-height: 1.3;
  color: var(--c-ink);
}
.nd-chrome .nd-kb-search__input::placeholder { color: var(--c-ink-3); }
.nd-chrome .nd-kb-search__input:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
  border-color: var(--c-accent);
}

/* ---------- группы и сетка карточек ---------- */

.nd-chrome .nd-kb-groups { margin-top: 30px; }

.nd-chrome .nd-kb-group + .nd-kb-group { margin-top: 38px; }

.nd-chrome .nd-kb-group__title {
  margin: 0 0 16px;
  border-bottom: 1px solid var(--c-line);
  padding-bottom: 10px;
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 700;
  color: var(--c-ink);
}

.nd-chrome .nd-kb-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nd-chrome .nd-kb-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background-color: #fff;
  padding: 18px 18px 16px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.nd-chrome .nd-kb-card:hover {
  border-color: var(--c-line-2);
  box-shadow: 0 8px 22px rgba(26, 25, 25, 0.07);
}
.nd-chrome .nd-kb-card::before { content: none; }

.nd-chrome .nd-kb-card__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--c-ink);
}
.nd-chrome .nd-kb-card__title a { color: inherit; }
.nd-chrome .nd-kb-card:hover .nd-kb-card__title a { color: var(--c-accent-ink); }

/* Карточка кликабельна целиком. Три ловушки темы разом:
   1) a { position: relative } — из-за неё ::after растянулся бы по самой
      ссылке, а не по карточке, поэтому позиционирование у ссылки снимаем;
   2) a:after в main.css — анимированное подчёркивание, схлопнутое не шириной,
      а `max-width: 0`; без max-width: none наш оверлей имеет нулевую ширину;
   3) overflow: hidden и transition оттуда же — тоже снимаем. */
.nd-chrome .nd-kb-card__title a { position: static !important; }
.nd-chrome .nd-kb-card__title a::after {
  content: "";
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  overflow: visible !important;
  transition: none !important;
  background: none !important;
  border: 0 !important;
  z-index: 1;
}

.nd-chrome .nd-kb-card__text {
  margin: 0 !important;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--c-ink-2);
}

.nd-chrome .nd-kb-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: auto 0 0 !important;
  padding-top: 4px;
  font-size: 0.78125rem;
  color: var(--c-ink-3);
}
.nd-chrome .nd-kb-card__flag {
  border-radius: 100px;
  background-color: var(--c-surface);
  padding: 2px 8px;
  font-weight: 600;
  color: var(--c-accent-ink);
}

.nd-chrome .nd-kb-empty {
  margin: 24px 0 0 !important;
  border: 1px dashed var(--c-line-2);
  border-radius: 6px;
  padding: 18px;
  font-size: 0.9375rem;
  color: var(--c-ink-2);
}

/* ---------- блок «Вопросы и ответы» на статье ---------- */

.nd-chrome .nd-kb-faq {
  margin-top: 34px;
  border-top: 1px solid var(--c-line);
  padding-top: 24px;
}
.nd-chrome .nd-kb-faq__title {
  margin: 0 0 16px;
  font-size: 1.375rem;
  line-height: 1.25;
  font-weight: 700;
  color: var(--c-ink);
}
.nd-chrome .nd-kb-faq__q {
  margin: 20px 0 6px;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--c-ink);
}
.nd-chrome .nd-kb-faq__q:first-of-type { margin-top: 0; }
.nd-chrome .nd-kb-faq__a {
  margin: 0 !important;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--c-ink-2);
}

/* ---------- таблицы в теле статьи ---------- */

.nd-chrome .nd-kb-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 24px;
}

.nd-chrome .nd-art__body table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.nd-chrome .nd-art__body table th,
.nd-chrome .nd-art__body table td {
  border: 1px solid var(--c-line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.nd-chrome .nd-art__body table th {
  background-color: var(--color-gray-bg, #f4f4f4);
  font-weight: 600;
  color: var(--c-ink);
}
.nd-chrome .nd-art__body table p { margin-bottom: 0 !important; }

/* блок «Ещё по теме» карточками базы */
.nd-chrome .nd-kb-grid--rel { margin-top: 16px; }

/* ---------- брейкпоинты темы ---------- */

@media (max-width: 1024px) {
  .nd-chrome .nd-kb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.9px) {
  .nd-chrome .nd-kb-grid { grid-template-columns: minmax(0, 1fr); }
  .nd-chrome .nd-kb-search { flex-basis: auto; }
  .nd-chrome .nd-kb-groups { margin-top: 22px; }
  .nd-chrome .nd-kb-group + .nd-kb-group { margin-top: 28px; }
  .nd-chrome .nd-art__body table { min-width: 420px; }
}

/* Лид и служебные подписи раздела — на всю ширину контейнера (владелец, 18.09.2026):
   news.css ограничивает .nd-head__sub по ширине; kb.css грузится только в базе знаний. */
.nd-head p.nd-head__sub,
p.nd-head__sub,
p.nd-kb-empty {
  max-width: none !important;
}

/* Шапка раздела: у новостей сетка в две колонки (текст + поиск), здесь колонка одна. */
.nd-kb-page .nd-head {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Обложка в карточке (владелец, 18.09.2026). Картинка выходит к краям карточки,
   пропорции 16:9 как у обложек автопостера (1200x675). Статья без обложки — карточка без картинки. */
.nd-chrome .nd-kb-card { overflow: hidden; }
.nd-chrome .nd-kb-card__pic {
  margin: -18px -18px 6px;
  aspect-ratio: 16 / 9;
  background-color: var(--c-line);
  overflow: hidden;
}
.nd-chrome .nd-kb-card__pic img.nd-kb-card__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.nd-chrome .nd-kb-card:hover .nd-kb-card__pic img.nd-kb-card__img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) {
  .nd-chrome .nd-kb-card__pic img.nd-kb-card__img { transition: none; transform: none !important; }
}
