/* =========================================================================
   Lingua Bona — дополнения к вёрстке для работы на MODX

   Основные стили — style.css (вёрстка без изменений). Здесь только то,
   что нужно для динамического контента: произвольное количество карточек,
   текст из визуального редактора, карта-виджет, видео, поиск, пагинация.
   ========================================================================= */

/* ------------- «Что беспокоит»: любое количество карточек -------------
   В style.css порядок и скрытие карточек на планшете и мобиле заданы
   под ровно 9 штук. Для списка из админки порядок — как в админке,
   на мобиле видны первые 4 карточки, остальные раскрываются кнопкой. */

/* !important — чтобы перебить правила style.css с :nth-child под 9 карточек */
@media (max-width: 1199.98px) {
  .diagnostics__cards--dynamic {
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .diagnostics__cards--dynamic .diagnosis-card {
    display: block !important;
    order: 0 !important;
  }
}

@media (max-width: 759.98px) {
  .diagnostics__cards--dynamic .diagnosis-card.diagnosis-card--more {
    display: none !important;
  }

  .diagnostics__cards--dynamic.is-expanded .diagnosis-card.diagnosis-card--more {
    display: block !important;
  }
}

/* ------------------------- Карта из Яндекс Карт ------------------------- */

.map-bar__img--embed {
  position: relative;
}

.map-bar__img--embed > *,
.map-bar__img--embed iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/* ------------------------------ Видео ------------------------------ */

.video-modal .modal-content {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: var(--lb-radius-md);
  background: #000;
}

.video-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  opacity: 0.9;
}

.video-modal__frame iframe,
.video-modal__frame video {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* --------------- Текст из визуального редактора (статьи) --------------- */

.article__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
  font-family: var(--lb-font-text);
  font-size: 16px;
  font-weight: 300;
  line-height: 22px;
  color: var(--lb-graphite);
}

.article__content > * {
  max-width: 100%;
  margin: 0;
}

.article__content h2 {
  width: 100%;
  margin-top: 10px;
  font-family: var(--lb-font-title);
  font-size: 30px;
  font-weight: 700;
  line-height: 30px;
  color: var(--lb-graphite);
}

.article__content > h2:first-child {
  margin-top: 0;
}

.article__content h3,
.article__content h4 {
  width: 100%;
  font-family: var(--lb-font-title);
  font-size: 24px;
  font-weight: 500;
  line-height: 29px;
  color: var(--lb-graphite);
}

.article__content p {
  width: 100%;
  margin: 0;
}

.article__content a:not(.btn-50) {
  color: var(--lb-orange);
  text-decoration: underline;
}

.article__content strong,
.article__content b {
  font-weight: 600;
}

.article__content ul:not([class]),
.article__content ol:not([class]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 958px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.article__content ul:not([class]) > li,
.article__content ol:not([class]) > li {
  position: relative;
  padding-left: 12px;
}

.article__content ul:not([class]) > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 10px;
  background: var(--lb-orange);
}

.article__content ol:not([class]) {
  counter-reset: lb-ol;
}

.article__content ol:not([class]) > li {
  padding-left: 22px;
  counter-increment: lb-ol;
}

.article__content ol:not([class]) > li::before {
  content: counter(lb-ol) ".";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
  color: var(--lb-orange);
}

.article__content blockquote:not([class]) {
  width: 100%;
  margin: 0;
  padding-left: 22px;
  border-left: 2px solid var(--lb-orange);
  font-family: var(--lb-font-title);
  font-size: 20px;
  font-weight: 400;
  line-height: 28px;
}

.article__content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--lb-radius-sm);
}

/* Таблица в тексте статьи оформлена как карточка прайса из макета:
   первая строка (заголовок таблицы) — название, дальше «услуга — цена» */
.article__content table {
  display: block;
  width: 100%;
  padding: 30px;
  border-collapse: collapse;
  border-radius: var(--lb-radius-lg);
  background: var(--lb-white);
}

.article__content table thead,
.article__content table tbody {
  display: block;
  width: 100%;
}

.article__content table tr {
  display: flex;
  gap: 14px;
  width: 100%;
  padding: 16px 0;
  border-bottom: 2px solid var(--lb-sand-border);
}

.article__content table thead tr {
  padding-top: 0;
  border-bottom: 0;
}

.article__content table td,
.article__content table th {
  flex: 1 0 0;
  min-width: 0;
  padding: 0;
  border: 0;
  text-align: left;
  font-family: var(--lb-font-title);
  font-size: 20px;
  font-weight: 300;
  line-height: 28px;
  color: #000;
}

.article__content table th {
  font-size: 24px;
  font-weight: 500;
  line-height: 29px;
}

.article__content table thead th + th {
  visibility: hidden;
}

.article__content table td + td {
  font-weight: 400;
  color: var(--lb-orange);
}

@media (max-width: 759.98px) {
  .article__content table {
    padding: 20px;
  }

  .article__content table td,
  .article__content table th {
    font-size: 16px;
    line-height: 22px;
  }
}

.article__content iframe,
.article__content video {
  max-width: 100%;
  border: 0;
  border-radius: var(--lb-radius-sm);
}

/* Якоря разделов не прячутся под шапку */
.article__content [id],
.article [id] {
  scroll-margin-top: 110px;
}

/* Статья без картинки в шапке: меню статьи занимает строку целиком */
.article-hero__row--no-image .article-toc {
  flex: 0 1 958px;
}

/* Простая страница (новость, документы) */
.page-simple .article {
  max-width: 958px;
}

/* ------------------------------ Пагинация ------------------------------ */

.lb-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 40px;
}

.lb-pager__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--lb-sand-border);
  border-radius: 1000px;
  background: var(--lb-white);
  font-family: var(--lb-font-text);
  font-size: 16px;
  font-weight: 600;
  color: var(--lb-graphite);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.lb-pager__item:hover,
.lb-pager__item.is-active {
  border-color: var(--lb-orange);
  color: var(--lb-orange);
}

/* --------------------------- Результаты поиска --------------------------- */

.search-results {
  gap: 30px;
}

.search-results .search-bar {
  width: 100%;
  max-width: 958px;
}

.search-results__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.search-results__type {
  font-family: var(--lb-font-text);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--lb-muted);
}

.search-results__text {
  font-family: var(--lb-font-text);
  font-size: 14px;
  font-weight: 300;
  line-height: 20px;
  color: var(--lb-muted);
}

.search-results__price {
  flex: 0 0 auto;
  margin: 0 16px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--lb-graphite);
}

.search-results .related__link {
  gap: 10px;
  text-decoration: none;
}

.search-results__empty,
.promos__empty {
  font-family: var(--lb-font-text);
  font-size: 16px;
  font-weight: 300;
  line-height: 22px;
  color: var(--lb-muted);
}

/* Поле поиска на странице цен — форма (переход к результатам по Enter) */
form.search-bar {
  margin: 0;
}

/* Скрытые отзывы до нажатия «Показать больше» */
.reviews-page__item[hidden] {
  display: none !important;
}

.reviews-page__item {
  display: contents;
}

/* Отзывы в ряду: подпись автора выравнивается по нижнему краю,
   даже если тексты разной длины (в вёрстке подгонялось пустой строкой) */
.reviews__row .review-card__body {
  flex: 1 1 auto;
}

.reviews__row .review-card__text {
  flex: 1 1 auto;
}

/* --------------------------- Онлайн-запись (Медфлекс) ---------------------------
   Плавающая круглая кнопка виджета не нужна: запись открывают кнопки сайта.
   Кнопка остаётся в разметке — через неё cms.js открывает окно Медфлекс. */

body[data-mf-round="0"] .medflex-round-widget__button {
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Блок записи на странице (чанк lb.bookingFrame) */
.booking-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Пока запись не открыта, блок не занимает места: иначе в колонке с карточками
   остаётся лишний отступ. Открывает его кнопка в карточке. */
.booking-frame:not(.is-open) {
  display: contents;
}

.booking-frame__btn {
  align-self: flex-start;
  min-width: 260px;
}

.booking-frame__box {
  position: relative;
  width: 100%;
  min-height: 620px;
  border-radius: var(--lb-radius-lg);
  background: var(--lb-white);
  box-shadow: var(--lb-shadow-small);
  overflow: hidden;
}

.booking-frame__box[hidden] {
  display: none;
}

.booking-frame__iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  border: 0;
}

.booking-frame__loader {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
  text-align: center;
  font-family: var(--lb-font-text);
  font-size: 16px;
  font-weight: 300;
  color: var(--lb-muted);
}

.booking-frame__box.is-loaded .booking-frame__loader {
  display: none;
}

@media (max-width: 759.98px) {
  .booking-frame__btn {
    min-width: 0;
    width: 100%;
  }

  .booking-frame__box,
  .booking-frame__iframe {
    min-height: 560px;
  }
}

/* ------------- «Как мы помогаем»: раскрытие во всю ширину -------------
   Панели вынесены из карточек (шаблон «Главная»), поэтому текст пункта
   занимает всю ширину блока, а не колонку. */

.help__acc {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.help__panel .help-card__body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 25px 30px 0 30px;
}

.help__panel-num {
  flex: 0 0 auto;
  font-family: var(--lb-font-title);
  font-size: 30px;
  font-weight: 200;
  line-height: 22px;
  color: var(--lb-orange);
}

.help__panel-text {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 958px;
}

@media (max-width: 1199.98px) {
  .help__panel .help-card__body {
    padding-inline: 0;
  }
}

@media (max-width: 759.98px) {
  .help__panel .help-card__body {
    gap: 12px;
    padding: 20px 20px 0 20px;
  }
}

/* ---------- Услуга: карточки врачей по три в ряд, фиксированной ширины ----------
   В вёрстке карточки растягивались на всю ширину, если врач один или два,
   и фото деформировалось. */

@media (min-width: 1200px) {
  .page-product .team__track {
    flex-wrap: wrap;
  }

  .page-product .team__track .doctor-card {
    flex: 0 0 calc((100% - 20px) / 3);
    max-width: calc((100% - 20px) / 3);
  }
}

/* ---- Простая страница: текст по левому краю, вровень с заголовком ---- */

.page-simple .diagnostics-cont {
  align-items: flex-start;
}

/* ---- Услуга: кнопка «Записаться …» в шапке ----
   Текст кнопки — один элемент, поэтому между словами обычный пробел.
   На узком экране длинная подпись переносится, кнопка растёт по высоте. */

.phero__btn-label {
  display: inline;
}

@media (max-width: 759.98px) {
  .page-product .phero__buttons .btn-big {
    height: auto;
    min-height: 60px;
    padding-block: 12px;
  }
}

/* ---- Страница врача: шапка и «Мой подход» растут под длину текста ----
   В вёрстке десктопный макет собран на абсолютных координатах с фиксированной
   высотой, поэтому длинный текст заезжал на плашку со временем приёма и на
   заголовок следующего блока. Ниже тот же макет переложен на поток: отступы
   повторяют координаты из вёрстки, но блок растягивается по содержимому.
   Планшет и мобильный в style.css уже сделаны потоком — их не трогаем. */

@media (min-width: 1200px) {

  /* Шапка врача */
  .page-doctor .doc-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    min-height: 610px;
    padding: 20px 0 83px;
  }

  .page-doctor .doc-hero > * {
    position: static;
  }

  .page-doctor .doc-hero__photo {
    position: absolute;
    top: 0;
    bottom: 0;
    height: auto;
  }

  .page-doctor .doc-hero__practice { margin-top: 43px; }
  .page-doctor .doc-hero__name     { margin-top: 12px; }
  .page-doctor .doc-hero__degree   { margin-top: 18px; }
  .page-doctor .doc-hero__lead     { margin-top: 20px; }
  .page-doctor .doc-hero__pill     { margin-top: 48px; }
  .page-doctor .doc-hero__btn      { margin-top: 30px; }

  /* «Как врач помогает»: слева список, справа видео и «Мой подход» */
  .page-doctor .doc-help__grid {
    display: grid;
    grid-template-columns: 313px 1fr;
    grid-template-rows: auto 1fr auto auto;
    column-gap: 10px;
    height: auto;
  }

  .page-doctor .doc-help__grid > * {
    position: static;
  }

  .page-doctor .doc-help__subtitle--cases    { grid-area: 1 / 1; }
  .page-doctor .doc-help__list               { grid-area: 2 / 1 / 5 / 2; margin-top: 30px; }
  /* position: relative — чтобы кнопка «плей» считалась от видео, а не от сетки;
     left/right из вёрстки при этом нужно сбросить */
  .page-doctor .doc-help__media              { grid-area: 1 / 2 / 3 / 3; position: relative; left: 0; right: auto; }
  .page-doctor .doc-help__subtitle--approach { grid-area: 3 / 2; margin-top: 20px; }
  .page-doctor .doc-help__text               { grid-area: 4 / 2; margin-top: 20px; }
}
