/* Страница «Сертификаты» — Figma 12:26546 (список), 12:26657 (пусто),
   12:27762 (попап просмотра). Шапка, футер и чипы — из общих стилей. */

/* Хлебные крошки — отдельный блок над хиро, как в макете. */
.cf-breadcrumbs {
  display: flex;
  width: min(var(--container-width), calc(100vw - var(--rz-gutter) * 2));
  margin: 170px auto 0;
  align-items: center;
  gap: 12px;
  font-size: clamp(16px, 1.04vw, 20px);
  letter-spacing: -0.04em;
  line-height: 1.3;
}

.cf-breadcrumbs a {
  color: #6b6b6b;
  transition: color 240ms var(--transition-soft);
}

.cf-breadcrumbs a:hover {
  color: var(--color-accent);
}

/* ---------- Хиро: заголовок слева, инфо-карточка справа ---------- */

.cf-hero {
  display: grid;
  width: min(var(--container-width), calc(100vw - var(--rz-gutter) * 2));
  /* 24px — отступ от крошек до заголовка (193 → 243 в макете). */
  margin: 24px auto 0;
  /* В макете: текст 1040px, карточка 443px */
  grid-template-columns: 1040fr 443fr;
  gap: 48px;
  align-items: start;
}

.cf-hero__title {
  /* Отступ 24px задаёт .cf-hero (крошки — отдельный блок выше). */
  margin: 0;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(38px, 4.8vw, 72px);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.05em;
}

.cf-hero__lead {
  margin: 24px 0 0;
  color: var(--color-muted);
  font-size: clamp(17px, 1.25vw, 24px);
  letter-spacing: -0.05em;
  line-height: normal;
}

.cf-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 32px;
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-panel);
}

.cf-note__badge {
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--color-background);
  color: var(--color-accent);
  font-size: 16px;
  letter-spacing: -0.04em;
  line-height: 1.3;
}

.cf-note__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cf-note__title {
  margin: 0;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(20px, 1.25vw, 24px);
  font-weight: 500;
  line-height: normal;
}

.cf-note__text {
  margin: 0;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.4;
}

/* ---------- Панель: чипы + поиск ---------- */

.cf-toolbar {
  display: flex;
  width: min(var(--container-width), calc(100vw - var(--rz-gutter) * 2));
  margin: 64px auto 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cf-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cf-search {
  display: flex;
  width: 443px;
  max-width: 100%;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-background);
}

.cf-search img {
  display: block;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  opacity: 0.7;
}

.cf-search input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: -0.04em;
  line-height: 1.3;
}

.cf-search input::placeholder {
  /* По доку страницы плейсхолдер светлее вторичного серого. */
  color: #a0a0a0;
}

.cf-search input:focus {
  outline: none;
}

/* ---------- Группы документов ---------- */

.cf-groups {
  display: flex;
  width: min(var(--container-width), calc(100vw - var(--rz-gutter) * 2));
  margin: 48px auto 0;
  flex-direction: column;
  gap: 64px;
}

.cf-group[hidden] {
  display: none;
}

.cf-group__head {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 24px;
}

.cf-group__titles {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.cf-group__name {
  color: var(--color-muted);
  font-size: clamp(16px, 1.04vw, 20px);
  letter-spacing: -0.04em;
  line-height: 1.3;
  text-transform: uppercase;
}

.cf-group__count {
  color: #6b6b6b;
  font-size: 16px;
  letter-spacing: -0.04em;
  line-height: 1.3;
}

.cf-group__line {
  height: 1px;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--color-border);
}

.cf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* ---------- Карточка документа ---------- */

.cf-card {
  display: flex;
  align-items: stretch;
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-panel);
}

.cf-card[hidden] {
  display: none;
}

.cf-card__preview {
  position: relative;
  width: 40%;
  flex: 0 0 40%;
  align-self: stretch;
  overflow: hidden;
  border-radius: 8px;
  background: var(--color-border);
}

.cf-card__preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cf-card__body {
  display: flex;
  min-width: 0;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}

.cf-card__top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.cf-card__title {
  margin: 0;
  overflow: hidden;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(17px, 1.04vw, 20px);
  font-weight: 500;
  line-height: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Переключатель языка документа */
.cf-lang {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border-radius: 6px;
  background: var(--color-background);
}

.cf-lang__btn {
  padding: 4px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: normal;
  cursor: pointer;
  transition: background 200ms var(--transition-soft), color 200ms var(--transition-soft);
}

.cf-lang__btn.is-active {
  /* По доку: активная кнопка тоже на белом, отличается акцентным текстом. */
  background: var(--color-background);
  color: var(--color-accent);
}

/* Кнопка языка без файла — недоступна */
.cf-lang__btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.cf-meta {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: normal;
}

.cf-meta__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cf-meta__label {
  flex: 0 0 auto;
  color: #6b6b6b;
}

.cf-meta__value {
  overflow: hidden;
  color: var(--color-accent);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-card__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Кнопки карточки — те же пилюли, что на сайте */
.cf-btn {
  display: flex;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 20px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-background);
  color: var(--color-muted);
  font-family: var(--font-body);
  font-size: clamp(15px, 1.04vw, 20px);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: normal;
  white-space: nowrap;
  cursor: pointer;
  transition: background 240ms var(--transition-soft), color 240ms var(--transition-soft);
}

.cf-btn__circle {
  display: grid;
  width: 47px;
  height: 47px;
  flex: 0 0 47px;
  place-items: center;
  border-radius: 999px;
  background: var(--color-background);
}

/* Дисковые PNG (диск + стрелка запечены) нельзя красить filter'ом — заливает
   и диск, и стрелку одним цветом. Состояния рисуем свапом файла через
   background-image круга, PNG из разметки скрыт (геометрия сохраняется). */
.cf-btn__circle img {
  display: block;
  width: 47px;
  height: 47px;
  object-fit: contain;
  opacity: 0;
}

.cf-btn--light {
  border-color: var(--color-inverse);
  background: var(--color-accent);
  color: var(--color-inverse);
}

/* Primary: белый диск + стрелка #003049. */
.cf-btn--light .cf-btn__circle {
  background: var(--color-inverse) url(../assets/icons/rasprodazha/arrow-bottom-left-black.png?v=20260812) center / 47px 47px no-repeat;
}

/* Hover secondary: инверсия в акцент. (Блок стоит ДО --light:hover,
   чтобы при равной специфичности не перебивать hover primary-кнопки.) */
.cf-btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-inverse);
}

.cf-btn:hover .cf-btn__circle {
  background: var(--color-inverse);
}

.cf-btn:hover .cf-btn__size {
  color: var(--color-inverse);
}

/* Hover primary: инверсия в белую пилюлю, круг акцентный со белой стрелкой. */
.cf-btn--light:hover {
  border-color: var(--color-accent);
  background: var(--color-inverse);
  color: var(--color-accent);
}

.cf-btn--light:hover .cf-btn__circle {
  background: var(--color-accent) url(../assets/icons/rasprodazha/arrow-bottom-left-white.png?v=20260812) center / 47px 47px no-repeat;
}

/* Кнопка скачивания всегда на месте (так в макете). Пока файл не загружен —
   показываем её неактивной, а не прячем. */
.cf-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Кнопка скачивания: круг меньше, внутри стрелка вниз */
.cf-btn__size {
  color: var(--color-muted);
}

.cf-btn--download .cf-btn__circle {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.cf-btn--download .cf-btn__circle svg {
  display: block;
  width: 22px;
  height: 22px;
  color: var(--color-accent);
}

.cf-btn--download:hover .cf-btn__circle svg {
  color: var(--color-accent);
}

/* ---------- Ничего не найдено ---------- */

.cf-empty {
  display: none;
  width: min(var(--container-width), calc(100vw - var(--rz-gutter) * 2));
  margin: 48px auto 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 32px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-panel);
  text-align: center;
}

.cf-empty.is-visible {
  display: flex;
}

.cf-empty__icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--color-muted);
}

.cf-empty__icon svg {
  display: block;
  width: 44px;
  height: 44px;
}

.cf-empty__title {
  margin: 0;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(18px, 1.25vw, 24px);
  font-weight: 500;
  line-height: normal;
}

.cf-empty__text {
  margin: 0;
  color: var(--color-muted);
  font-size: 16px;
  line-height: 1.3;
}

/* =========================================================================
   Попап просмотра документа (Figma 12:27762)
   ====================================================================== */

body.is-cert-open {
  overflow: hidden;
}

.cf-modal {
  position: fixed;
  z-index: 420;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 260ms var(--transition-soft), visibility 260ms var(--transition-soft);
}

.cf-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cf-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.7);
}

.cf-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(1164px, 100%);
  height: min(844px, 100%);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-background);
  box-shadow: 0 16px 32px rgb(0 0 0 / 0.1);
}

.cf-modal__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.cf-modal__head {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.cf-modal__badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 8px;
  border-radius: 6px;
  /* По доку попапа бейдж белый и сливается с шапкой — остаётся только иконка. */
  background: var(--color-background);
}

.cf-modal__badge img {
  display: block;
  width: 20px;
  height: 20px;
}

.cf-modal__title {
  margin: 0;
  overflow: hidden;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: clamp(16px, 1.04vw, 20px);
  font-weight: 500;
  line-height: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-modal__close {
  display: grid;
  width: 47px;
  height: 47px;
  flex: 0 0 47px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-background);
  color: var(--color-text);
  cursor: pointer;
  transition: background 240ms var(--transition-soft);
}

.cf-modal__close:hover {
  background: var(--color-border);
}

.cf-modal__viewer {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--color-background);
}

.cf-modal__page {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cf-modal__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
}

.cf-modal__counter {
  margin: 0;
  color: var(--color-muted);
  font-size: clamp(16px, 1.04vw, 20px);
  letter-spacing: -0.04em;
  line-height: 1.3;
}

.cf-modal__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cf-modal__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cf-modal__arrow {
  display: grid;
  width: 47px;
  height: 47px;
  flex: 0 0 47px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-background);
  cursor: pointer;
  transition: border-color 240ms var(--transition-soft), background 240ms var(--transition-soft);
}

.cf-modal__arrow img {
  display: block;
  width: 29px;
  height: 29px;
}

.cf-modal__arrow:hover:not([disabled]) {
  border-color: var(--color-accent);
  background: var(--color-panel);
}

.cf-modal__arrow[disabled] {
  /* disabled по макету передаётся цветом иконки #6B7280, без доп. прозрачности */
  cursor: default;
}

.cf-modal__download {
  width: 242px;
  max-width: 100%;
  height: 63px;
}

/* По доку попапа круг внутри «Скачать PDF» акцентный, стрелка белая
   (в отличие от карточек, где круг белый со стрелкой #003049).
   Дисковый PNG не красим фильтром — подставляем файл с белой стрелкой. */
.cf-modal__download .cf-btn__circle {
  background: var(--color-accent) url(../assets/icons/rasprodazha/arrow-bottom-left-white.png?v=20260812) center / 47px 47px no-repeat;
}

/* Одностраничный документ — навигация не нужна */
.cf-modal__nav[hidden],
.cf-modal__counter[hidden] {
  display: none;
}

/* ---------- Адаптив ---------- */

@media (max-width: 1400px) {
  .cf-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1100px) {
  .cf-breadcrumbs {
    margin-top: 130px;
  }

  .cf-hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .cf-toolbar {
    margin-top: 40px;
  }

  .cf-search {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .cf-grid {
    grid-template-columns: 1fr;
  }

  .cf-card {
    flex-direction: column;
  }

  .cf-card__preview {
    width: 100%;
    height: 260px;
    flex: 0 0 260px;
  }

  .cf-modal {
    padding: 12px;
  }

  .cf-modal__viewer {
    padding: 16px;
  }

  .cf-modal__bottom {
    flex-wrap: wrap;
  }

  .cf-modal__download {
    width: 100%;
  }
}
