/* ===========================================================================
   style.css — страница «Сертификаты и награды» (шаблон certificates
   компонента bitrix:news.list), Битрикс подключает его сам. Вёрстка — как
   у «Жизни компании» (шаблон gallery): переключатель — .pill-tabs (ui.css),
   тёмная полоса — .lens-band (blocks.css), сетка и карточка — свои.
   Окно просмотра — vendor/photoswipe/photoswipe.css.
   =========================================================================== */

@layer blocks {

  /* Нижняя линза полосы выступает вниз на 100px из 1920 (и тень ещё на 80) —
     следующий блок отодвигаем, чтобы она на него не легла */
  .certificates { padding-bottom: 9vw; }

  /* Выше полосы: её верхняя линза заходит наверх (.lens-band) */
  .certificates__head {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    margin-top: 24px;
  }

  /* === Полоса с карточками ================================================ */

  .certificates__band {
    margin-top: 10px;
    padding-block: calc(3vw + clamp(40px, 5.2vw, 100px)) clamp(80px, 13.9vw, 267px);
  }

  /* Колонок столько, сколько влезает карточек ~180–258px: 2, 3, 4 или 6.
     Чётные колонки (при трёх — средняя) ниже на 50px из 344 высоты
     карточки — сдвиг в процентах от неё самой. Считаются только видимые
     карточки (nth-child … of): скрытые фильтром (hidden) и уходящие во время
     анимации (.is-leaving, script.js) места в сетке не занимают */
  .certificates__band > .container { container: certificates / inline-size; }

  .certificates__grid {
    --columns: 2;
    position: relative; /* уходящие карточки — абсолютно внутри списка */
    display: grid;
    grid-template-columns: repeat(var(--columns), minmax(0, 258px));
    justify-content: center;
    gap: 10px;
    /* место под сдвинутые вниз колонки */
    margin: 0 0 50px;
    padding: 0;
    list-style: none;
  }

  .certificates__grid > li:nth-child(even of :not([hidden], .is-leaving)) { translate: 0 14.535%; }

  @container certificates (width >= 520px) {
    .certificates__grid { --columns: 3; }
    .certificates__grid > li:nth-child(even of :not([hidden], .is-leaving)) { translate: none; }
    .certificates__grid > li:nth-child(3n + 2 of :not([hidden], .is-leaving)) { translate: 0 14.535%; }
  }

  @container certificates (width >= 760px) {
    .certificates__grid { --columns: 4; }
    .certificates__grid > li:nth-child(3n + 2 of :not([hidden], .is-leaving)) { translate: none; }
    .certificates__grid > li:nth-child(even of :not([hidden], .is-leaving)) { translate: 0 14.535%; }
  }

  /* Карточка, которую фильтр прячет: пока гаснет, стоит на прежнем месте
     поверх сетки (координаты задаёт script.js) */
  .certificates__grid > li.is-leaving {
    position: absolute;
    translate: none;
    pointer-events: none;
  }

  @container certificates (width >= 1200px) {
    .certificates__grid { --columns: 6; }
  }

  .certificates__empty {
    margin: 0;
    color: var(--color-gray-300);
    text-align: center;
  }

  /* === Карточка: картинка с полями 10px ================================== */
  /* 258×344, поля и скругление картинки — как у фото галереи (.gallery-card);
     сертификат любой пропорции обрезается по центру. При наведении — тот же
     светлый градиент, что у галереи */

  .certificate-card {
    position: relative;
    isolation: isolate;
    display: block;
    aspect-ratio: 258 / 344;
    box-sizing: border-box;
    padding: 10px;
    overflow: hidden;
    border-radius: var(--radius-quote);
    background: var(--color-white);
  }

  /* Градиент не анимируется — проявляем слоем под картинкой */
  .certificate-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--gradient-light);
    opacity: 0;
    transition: opacity var(--transition);
  }

  .certificate-card:hover::before { opacity: 1; }

  .certificate-card:focus-visible {
    outline: 2px solid var(--color-blue);
    outline-offset: 2px;
  }

  .certificate-card__img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    object-fit: cover;
  }

  @media (width >= 768px) {
    .certificates__head { margin-top: 40px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .certificate-card::before { transition: none; }
  }
}
