/**
 * AtomCAE — блок «Сертификаты» (Figma 233:3134 desktop / 283:1840 mobile).
 * Светлая секция: шапка (надзаголовок + заголовок + стрелки) + карусель карточек
 * сертификатов (Swiper, ADR-0012). Десктоп — стрелки prev/next, мобайл — точки.
 * Грузится после layout.css. Десктоп-first. Значения из макета.
 */

.certificates {
  background: var(--color-surface);
  color: var(--color-dark);
}

.certificates__inner {
  width: min(1402px, 100% - 2 * 40px);
  margin-inline: auto;
}

/* --- Шапка секции --- */
.certificates__head {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding-bottom: 32px;
}

.certificates__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  font-size: var(--font-size-eyebrow);
  line-height: var(--font-size-eyebrow);
  letter-spacing: var(--letter-spacing-tight);
  white-space: nowrap;
}

.certificates__eyebrow-arrow {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  background-color: var(--color-primary);
  -webkit-mask: url("../icons/arrow-down-right.svg") center / contain no-repeat;
  mask: url("../icons/arrow-down-right.svg") center / contain no-repeat;
}

.certificates__eyebrow-text {
  opacity: 0.4;
}

/* заголовок + интро-текст столбцом (стрелки навигации унесены на бока, п. 1.19) */
.certificates__intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.certificates__title {
  margin: 0;
  font-family: var(--font-family-display);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-h2);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
}

/* интро-текст под заголовком (п. 1.3). R11 (правка заказчика 23.11): «выделить цветом
   и/или шрифт на 1-2 п. больше» — 18 → 20px, вес 400 → 500, брендовый синий, opacity 1
   (было 0.7, из-за чего строка выглядела бледной). */
.certificates__lead {
  max-width: 820px;
  margin: 0;
  font-size: 20px;
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-relaxed);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-primary);
  opacity: 1;
}

/* --- Стрелки навигации (Figma 233:3144): два бокса 53×53 с шевроном --- */
/* Стрелки — общий примитив .carousel-nav в layout.css (п. 1.19: по бокам). */

/* --- Карусель (Swiper) --- */
.certificates__carousel {
  margin-top: 24px;
}

/* слайд = карточка-скан + подпись под ней (п. 1.3). Ширину задаёт Swiper
   (slidesPerView). Колонка: карточка сверху, подпись снизу. */
.certificates__slide {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: auto;
}

/* подпись под сертификатом (п. 1.3): min-height резервирует 2 строки, чтобы
   карточки в ряду были выровнены по высоте при подписях разной длины. */
.certificates__caption {
  margin: 0;
  min-height: calc(2 * 1.5em);
  font-size: var(--font-size-nav);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-dark);
  opacity: 0.7;
}

/* карточка = ссылка-скан (открывает попап). Ширину задаёт Swiper (slidesPerView),
   высота фиксированная — скан показывается ЦЕЛИКОМ (object-fit: contain) на белом. */
.certificates__card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 510px;
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
  text-decoration: none;
}

/* скан целиком, по центру карточки */
.certificates__media-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* лупа — оверлей поверх скана, проявляется при наведении/фокусе (на тач — всегда) */
.certificates__zoom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 34, 56, 0.04);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.certificates__card:hover .certificates__zoom,
.certificates__card:focus-visible .certificates__zoom {
  opacity: 1;
}

.certificates__zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
}

.certificates__zoom-icon {
  width: 28px;
  height: 28px;
  background-color: var(--color-dark);
  -webkit-mask: url("../icons/search.svg") center / contain no-repeat;
  mask: url("../icons/search.svg") center / contain no-repeat;
}

/* П. 2.16: на тач-устройствах лупа СКРЫТА (заказчик: «загораживает сертификат»).
   Раньше тут было @media (hover:none) { opacity:1 } — лупа висела постоянно.
   На десктопе аффорданс остаётся — проявление по hover/focus (правило выше). */

@media (prefers-reduced-motion: reduce) {
  .certificates__zoom {
    transition: none;
  }
}

/* --- Точки-пагинация (Swiper): только мобайл (Figma 283:1980) --- */
/* --- Планшет: стрелки остаются, заголовок мельче (карусель 2 карточки — JS) --- */
@media (max-width: 1100px) {
  .certificates__title {
    font-size: 40px;
  }
}

/* --- Смартфон: 1 карточка, стрелки → точки (Figma 283:1840) --- */
@media (max-width: 640px) {
  .certificates {
    padding-block: 30px;
  }

  .certificates__inner {
    width: min(1402px, 100% - 2 * 15px);
  }

  .certificates__head {
    gap: 24px;
    padding-bottom: 0;
  }

  .certificates__eyebrow {
    font-size: 16px;
    line-height: 16px;
  }

  .certificates__title {
    font-size: 28px;
    letter-spacing: -1px;
  }

  /* стрелки скрыты, листание свайпом + точки */

  .certificates__carousel {
    margin-top: 32px;
  }

  /* карточка ниже (скан целиком на меньшей ширине), лупа меньше */
  .certificates__card {
    height: 440px;
    padding: 16px;
  }

  .certificates__zoom-btn {
    width: 52px;
    height: 52px;
  }

  .certificates__zoom-icon {
    width: 24px;
    height: 24px;
  }


}

/* ============================================================
   Попап сертификата (п. 2.7): скан слева, развернутый текст справа,
   крестик. Заменил лайтбокс GLightbox. Открытие/наполнение — certificates.js.
   ============================================================ */
.cert-popup {
  position: fixed;
  inset: 0;
  /* ниже попапа формы (1100) и чата (9999), выше остального контента */
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cert-popup[hidden] {
  display: none;
}

.cert-popup__overlay {
  position: absolute;
  inset: 0;
  background: rgba(22, 34, 56, 0.6);
  cursor: pointer;
}

.cert-popup__dialog {
  position: relative;
  display: flex;
  gap: 40px;
  width: min(1060px, 100%);
  max-height: 88vh;
  padding: 40px;
  background: var(--color-surface);
  box-shadow: 0 24px 64px rgba(22, 34, 56, 0.25);
}

.cert-popup__close {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  appearance: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.cert-popup__close::before {
  content: "";
  width: 22px;
  height: 22px;
  background-color: var(--color-dark);
  -webkit-mask: url("../icons/close.svg") center / contain no-repeat;
  mask: url("../icons/close.svg") center / contain no-repeat;
}

.cert-popup__media {
  flex: 0 0 44%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
}

.cert-popup__img {
  max-width: 100%;
  max-height: calc(88vh - 80px);
  object-fit: contain;
}

.cert-popup__body {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding-inline-end: 8px;
}

.cert-popup__title {
  margin: 0 0 16px;
  font-family: var(--font-family-display);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-h3);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

.cert-popup__text {
  margin: 0;
  font-size: var(--font-size-nav);
  line-height: var(--line-height-relaxed);
  letter-spacing: var(--letter-spacing-tight);
  /* переносы из textarea (certificates.js кладёт textContent) */
  white-space: pre-line;
}

/* сертификат без текста — скан по центру, колонка текста не рендерит пустоту */
.cert-popup--no-text .cert-popup__media {
  flex: 1;
}

.cert-popup--no-text .cert-popup__body {
  display: none;
}

/* блокировка прокрутки страницы под попапом */
html.cert-popup-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .cert-popup {
    padding: 12px;
  }

  .cert-popup__dialog {
    flex-direction: column;
    gap: 20px;
    padding: 48px 16px 20px;
    overflow-y: auto;
  }

  .cert-popup__media {
    flex: 0 0 auto;
  }

  .cert-popup__img {
    max-height: 48vh;
  }

  .cert-popup__body {
    overflow: visible;
    padding-inline-end: 0;
  }

  .cert-popup__title {
    font-size: 22px;
  }

  .cert-popup__text {
    font-size: 16px;
  }
}
