@use '../../abstracts' as *;

// Вертикальный стек блоков под героем
.doctor-detail__stack {
  display: flex;
  flex-direction: column;
  gap: 30px;

  // Узкая полоса до 768 (≤576 — sm; 576–767 — экран как в 27:2657 между моб. и планшетом): шаг 20px как у карточек
  @include sm {
    gap: $gap-mobile;
  }

  @include viewport-mobile {
    gap: $gap-mobile;
  }
}

// Секции в виде карточек (фон, внутренние поля, скругление)
.doctor-card {
  display: flex;
  flex-direction: column;
  gap: $gap;
  padding: 0;
  border-radius: $radius-md;
  // секции не интерактивные карточки — без «подъёма» и лишних transition
  transition: none;

  @include sm {
    padding: $gap-mobile;
    gap: $gap-mobile;
  }

  &--muted {
    background: $color-doctor-card-bg;
  }

  &--accent {
    background: $color-doctor-hero-bg;
  }

  &__title {
    font-family: $font-heading;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    color: $color-text;
    margin: 0;

    // xs = только ≤359; артборд 360 (Figma 27:2763) и 576 — через sm (≤576)
    @include sm {
      font-size: 24px;
      line-height: 1.2; // моб. карточки: Raleway 24 bold, межстрочный как в 27-2765
    }
  }
}

// Секции без подложки-карточки
.doctor-block {
  display: flex;
  flex-direction: column;
  gap: 30px;

  @include sm {
    gap: 20px;
  }

  &__title {
    font-family: $font-heading;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    color: $color-text;
    margin: 0;

    @include sm {
      font-size: 24px;
    }

    &--lg {
      font-size: 36px;

      @include sm {
        font-size: 30px;
      }
    }
  }
}

// Универсальная контентная типографика для HTML из CMS.
// Использование: добавляйте класс .bitrix-content на контейнер с текстом из админки.
.bitrix-content {
  color: $color-text;

  > *:first-child {
    margin-top: 0;
  }

  > *:last-child {
    margin-bottom: 0;
  }

  p {
    font-size: 18px;
    font-weight: 400;
    line-height: 1.2;
    color: $color-text;
    margin: 0 0 18px;

    &:last-child {
      margin-bottom: 0;
    }
  }

  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 24px 0 12px;
    font-family: $font-heading;
    font-weight: 700;
    line-height: 1.2;
    color: $color-text;
  }

  h2 {
    font-size: 28px;
  }

  h3 {
    font-size: 24px;
  }

  h4 {
    font-size: 20px;
  }

  h5,
  h6 {
    font-size: 18px;
  }

  ul,
  ol {
    margin: 0 0 18px;
    padding-left: 1.4em;
    font-size: 18px;
    line-height: 1.3;
  }

  li + li {
    margin-top: 6px;
  }

  ul li::marker {
    color: $color-text;
  }

  a {
    color: $color-blue;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;

    &:hover {
      color: $color-dark-blue;
    }
  }

  strong,
  b {
    font-weight: 700;
  }

  em,
  i {
    font-style: italic;
  }

  blockquote {
    margin: 0 0 18px;
    padding: 12px 16px;
    border-left: 3px solid $color-blue;
    background: rgba($color-blue, 0.06);
    border-radius: $radius-sm;
    font-size: 18px;
    line-height: 1.3;
  }

  hr {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid rgba($color-text-secondary, 0.35);
  }

  img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0 0 18px;
    border-radius: $radius-sm;
  }

  figure {
    margin: 0 0 18px;
  }

  figcaption {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.35;
    color: $color-text-secondary;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 18px;
    font-size: 16px;
    line-height: 1.35;
  }

  th,
  td {
    padding: 10px 12px;
    border: 1px solid rgba($color-text-secondary, 0.35);
    text-align: left;
    vertical-align: top;
  }

  th {
    font-weight: 600;
    background: rgba($color-blue, 0.06);
  }

  @include sm {
    p,
    ul,
    ol,
    blockquote {
      font-size: 16px;
      line-height: 1.3;
    }

    h2 {
      font-size: 24px;
    }

    h3 {
      font-size: 20px;
    }

    h4 {
      font-size: 18px;
    }

    h5,
    h6 {
      font-size: 16px;
    }
  }
}

// 1920+ — отдельная калибровка блока «О специалисте» по макету; «Профессиональные навыки» (Figma 95:1439) — те же поля карточки.
@include viewport-desktop-xl {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: 30px;
    gap: 30px;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 20px;
  }
}

// 1440+ — калибровка блока «О специалисте» по макету.
@include viewport-desktop {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: 30px;
    gap: 30px;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 20px;
  }
}

// 992+ — калибровка блока «О специалисте» по макету.
@include viewport-laptop {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: 30px;
    gap: 30px;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 20px;
  }
}

// 768–991 — карточки текста на полосе планшета (страница Figma 27:2498).
@include viewport-tablet {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: 30px;
    gap: 30px;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 20px;
  }
}

// 576–767 — узкая полоса (Figma 27:2657 и соседние кадры): те же поля карточек, что на ≤576.
@include viewport-mobile {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: $gap-mobile;
    gap: $gap-mobile;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 18px;
  }
}

// 360+ — самый узкий макет телефона.
@include viewport-mobile-sm {
  .doctor-card.doctor-about,
  .doctor-card.doctor-services,
  .doctor-card.doctor-education,
  .doctor-card.doctor-courses {
    padding: $gap-mobile;
    gap: $gap-mobile;
  }

  .doctor-about .bitrix-content p {
    margin-bottom: 18px;
  }
}

.doctor-list {
  margin: 0;
  padding-left: 0;
  font-family: $font-body;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.2;
  color: $color-text;

  @include sm {
    font-size: 16px;
    line-height: 1.3; // моб.: как .bitrix-content sm / Figma 27-2765 (Roboto 16 / 130%)
  }

  li {
    margin-bottom: 0;
    position: relative;
    padding-left: 1.5em; // отступ под маркер, как в Figma
    line-height: 1.2;

    @include sm {
      line-height: 1.3;
    }
    &::before {
      content: '•';
      position: absolute;
      left: 0;
      color: $color-text;
    }
  }

  li + li {
    margin-top: 0;
  }
}

// Услуги / навыки: десктоп — Roboto 18 (95:1438/1439). Мобилка — [27-2765]: Roboto 16 / 400 / 130%, заголовок секции — Raleway 24 / 700 / 120% (.doctor-card__title), «Показать ещё» — Roboto 16 / 500, $color-blue.
.doctor-services {
  &__body {
    font-family: $font-body;
    font-size: 18px;
    line-height: 1.2;
    color: $color-text;

    @include sm {
      font-size: 16px;
      font-weight: 400;
      line-height: 1.3;
    }
  }

  &__lead {
    margin: 0 0 20px;
    font-family: $font-body;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.2;
    color: $color-text;

    @include sm {
      font-size: 16px;
      line-height: 1.3;
    }
  }

  &__list-wrap {
    @include up(($bp-576 + 1px)) {
      max-height: none;
      overflow: visible;

      &::after {
        display: none;
      }
    }

    @include sm {
      position: relative;
      max-height: 7.8em;
      overflow: hidden;
      transition: max-height 0.35s ease;

      &::after {
        content: '';
        pointer-events: none;
        position: absolute;
        inset-inline: 0;
        bottom: 0;
        height: 2.4em;
        background: linear-gradient(
          to bottom,
          rgba($color-doctor-card-bg, 0),
          $color-doctor-card-bg 85%
        );
      }

      &.doctor-services__list-wrap--expanded {
        max-height: none;
        overflow: visible;

        &::after {
          display: none;
        }
      }
    }
  }

  &__list {
    margin: 0;
  }

  &__toggle {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 20px 0 0;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font-family: $font-body;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: $color-blue;
    text-align: left;

    &:hover {
      text-decoration: underline;
    }

    &:focus-visible {
      outline: 2px solid $color-blue;
      outline-offset: 2px;
      border-radius: 2px;
    }

    @include sm {
      display: inline-flex;
    }
  }

  &__toggle-icon {
    flex-shrink: 0;
    color: $color-blue;
    transition: transform 0.2s ease;

    &--open {
      transform: rotate(180deg);
    }
  }
}

.price-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 18px;
  line-height: normal;
  color: $color-text;

  @include sm {
    font-size: 16px;
  }

  &__item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
  }

  &__name {
    flex: 1;
    min-width: 0;
    font-weight: 400;
  }

  &__value {
    flex-shrink: 0;
    font-weight: 400;
    white-space: nowrap;
  }

  // 576+ и 360+: мобильная типографика блока цен по макету.
  @include viewport-mobile {
    font-size: 16px;
    gap: 16px;
  }

  @include viewport-mobile-sm {
    font-size: 16px;
    gap: 14px;
  }
}

.doctor-prices {
  // По макету у блока цен на desktop есть внутренние поля карточки.
  padding: 30px;

  &__legal {
    margin: 0;
    font-size: 14px;
    line-height: 1.3;
    color: $color-text-secondary;
  }

  &__all {
    align-self: flex-start;
  }

  // 1440+, 992+, 768+: одинаковая плотность карточки.
  @include viewport-desktop {
    padding: 30px;
  }

  @include viewport-laptop {
    padding: 30px;
  }

  @include viewport-tablet {
    padding: 30px;
  }

  // 576+ и 360+: компактная карточка.
  @include viewport-mobile {
    padding: 20px;

    &__legal {
      font-size: 13px;
      line-height: 1.3;
    }
  }

  @include viewport-mobile-sm {
    padding: 20px;

    &__legal {
      font-size: 12px;
      line-height: 1.35;
    }
  }

  @include sm {
    padding: 20px;
  }
}

// Сертификаты: слайдер Swiper
.doctor-certificates {
  .certificates-swiper {
    width: 100%;
  }

  .swiper-slide {
    border-radius: $radius-md;
    overflow: hidden;
    height: auto;
  }

  // Fallback, если Swiper не успел инициализироваться.
  .certificates-swiper:not(.swiper-initialized) .swiper-wrapper {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;

    @include md {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    @include sm {
      grid-template-columns: 1fr;
      gap: 20px;
    }
  }
}

.cert-link {
  display: block;
  border-radius: $radius-md;
  overflow: hidden;
}

.cert-img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: contain;
  object-position: center;
  border-radius: $radius-md;
  background: $color-white;

  @include sm {
    height: auto;
    aspect-ratio: 350 / 260;
  }
}

.certificates-swiper,
.doctor-reviews-swiper {
  .swiper-pagination {
    margin-top: 20px;
    position: static;
    text-align: center;
  }

  .swiper-pagination-bullet {
    background: $color-blue;
    opacity: 0.35;

    &-active {
      opacity: 1;
    }
  }
}

// Пагинация снаружи .swiper — не обрезается overflow:hidden у трека (thanks, cases)
.doctor-thanks__swiper-shell,
.doctor-cases__swiper-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
}

#doctor-thanks-swiper-pagination,
#doctor-cases-swiper-pagination {
  margin-top: 24px;
  position: static !important;
  left: auto !important;
  bottom: auto !important;
  top: auto !important;
  width: 100%;
  text-align: center;
  min-height: 12px;
  z-index: 1;

  &.swiper-pagination-lock {
    display: flex !important;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
  }

  .swiper-pagination-bullet {
    background: $color-blue;
    opacity: 0.35;

    &-active {
      opacity: 1;
    }
  }
}

.doctor-reviews-swiper {
  width: 100%;

  .swiper-slide {
    height: auto;
  }
}

// «Наши работы»: вертикальный слайд + жесты (без нативного drag картинок)
.doctor-cases-swiper {
  width: 100%;

  .swiper-slide {
    height: auto;
    display: flex;
    flex-direction: column;
  }
}

// Письменные отзывы: Swiper как в макете (Figma 95:1507, ряд 4× на ≥992)
.thanks-swiper {
  width: 100%;

  .swiper-slide {
    height: auto;
  }
}

.doctor-video-reviews {
  display: flex;
  gap: 30px;
  align-items: flex-start;

  @include md {
    flex-direction: column;
  }

  &__col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;

    &--aside {
      padding-top: 46px;

      @include md {
        padding-top: 0;
      }
    }
  }

  &__label {
    margin: 0;
    font-size: 22px;
    font-weight: 400;
    line-height: normal;
    color: $color-text;

    @include sm {
      font-size: 18px;
    }
  }

  &__frame {
    position: relative;
    border-radius: $radius-md;
    overflow: hidden;
    background: $color-detail-soft-bg;
  }

  &__thumb {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3396 / 1884;
    object-fit: cover;
  }

  &__play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 0;
    border-radius: 50%;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));

    &:focus-visible {
      outline: 2px solid $color-white;
      outline-offset: 3px;
    }
  }

  &__caption {
    margin: 0;
    font-size: 14px;
    line-height: normal;
    color: $color-text;
  }

  &__heading {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: normal;
    color: $color-text;
  }

  &__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
  }

  &__tag-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
  }

  &__tag {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: $radius-sm;
    background: $color-doctor-hero-bg;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: $color-blue;
  }

  &__tag-text {
    font-size: 16px;
    font-weight: 400;
    line-height: normal;
    color: $color-text;
    max-width: 360px;
  }

  &__quote {
    margin: 0;
    font-size: 20px;
    font-style: italic;
    font-weight: 400;
    line-height: normal;
    color: $color-text;

    @include sm {
      font-size: 18px;
    }
  }
}

.doctor-thanks {
  &__card {
    display: block;
    border-radius: $radius-md;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    -webkit-user-drag: none;
    user-select: none;

    &:focus-visible {
      outline: 2px solid $color-blue;
      outline-offset: 3px;
    }

    &:hover .doctor-thanks__slide {
      box-shadow: 0 10px 28px rgba(33, 53, 112, 0.14);
    }
  }

  &__slide {
    width: 100%;
    border-radius: $radius-md;
    aspect-ratio: 210 / 297;
    min-height: 220px;
    background: linear-gradient(165deg, $color-detail-soft-bg 0%, #dce2f0 100%);
    transition: box-shadow 0.25s ease;

    @include viewport-desktop-xl {
      min-height: 260px;
    }

    @include sm {
      min-height: 200px;
      aspect-ratio: 4 / 5;
    }
  }
}

.doctor-cases {
  &__compare {
    position: relative;
    display: flex;
    gap: 30px;

    @include md {
      gap: 20px;
    }

    @include sm {
      flex-direction: column;
      gap: $gap-mobile;
    }
  }

  &__shot {
    position: relative;
    flex: 1;
    min-width: 0;
    border-radius: $radius-md;
    overflow: hidden;
    background: $color-detail-soft-bg;

    img {
      display: block;
      width: 100%;
      height: auto;
      aspect-ratio: 3396 / 1884;
      object-fit: cover;
      -webkit-user-drag: none;
      user-select: none;
    }
  }

  &__badge {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1;
    padding: 4px 8px;
    border-radius: $radius-sm;
    background: $color-white;
    font-family: $font-body;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: $color-blue;
    box-shadow: 0 1px 8px rgba(33, 53, 112, 0.12);
  }

  &__text {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    margin-top: 30px;

    @include sm {
      margin-top: 20px;
    }
  }

  &__tag {
    margin: 0;
    font-family: $font-body;
    font-size: 20px;
    font-weight: 500;
    line-height: 1.3;
    color: $color-blue;
  }

  &__subtitle {
    margin: 0;
    font-family: $font-body;
    font-size: 18px;
    font-weight: 600;
    line-height: normal;
    color: $color-text;
  }

  &__desc {
    margin: 0;
    font-family: $font-body;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    color: $color-text;
  }

}

.doctor-reviews-list {
  display: flex;
  flex-direction: column;
  gap: 24px;

  .reviews-list {
    margin-bottom: 0;
  }

  &__cta {
    align-self: flex-start;
  }
}

.reviews-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;

  .doctor-reviews-list & {
    margin-bottom: 0;
  }
}

.review-card {
  background: $color-doctor-card-bg;
  border-radius: $radius-md;
  padding: 24px;
  border: 1px solid $color-detail-border-soft;

  &__header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }

  &__author {
    font-size: 15px;
    color: $color-text;
  }

  &__date {
    font-size: 13px;
    color: $color-text-secondary;
  }

  &__stars {
    color: $color-detail-accent-warm;
    font-size: 15px;
    letter-spacing: 2px;
    margin-left: auto;

    @include md {
      margin-left: 0;
    }
  }

  p {
    font-size: 14px;
    line-height: 1.7;
    color: $color-text;
    margin: 0;
  }
}

