/* ==========================================================================
   ОГЛАВЛЕНИЕ (block-04-free.css) — Блок 4 «Смотреть бесплатно»
   HTML: index.html → секция #block-04
   JS:   js/block-04-free.js (кометы в верхней зоне)

   1.  Секция .block-04 — размер, нахлёст на блок 3
   2.  Фон: слой атмосферы, градиент космос → небо
   3.  Кометы — canvas-зона (рисует JS)
   4.  Контент поверх фона + заголовки блока
   5.  Подпись «По курсам»
   6.  Сетка трёх карточек (под три курса блока 3)
   7.  Карточка: только opacity (без scale — текст не дёргается)
   8.  Видео: scale внутри рамки + покачивание у неактивных
   9.  Название курса над видео (RU + EN подпись)
   10. Обёртка видео — рамка, тень, золотая подсветка активной
   11. Тег <video> внутри карточки
   12. Текст описания под видео
   13. Кнопка «Смотреть все N видео» → лендинг курса
   14. Декор: ножницы в углу
   15. Мобилка и prefers-reduced-motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. СЕКЦИЯ .block-04
   За что отвечает: весь блок «Смотреть бесплатно», нахлёст на тёмный блок 3.
   -------------------------------------------------------------------------- */
.block-04 {
  background: #eef8fb;
  color: var(--color-text);
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
  margin-top: -160px;
  padding-top: 140px;
  padding-bottom: calc(var(--gap-xl) + var(--gap-md));
  min-height: auto;
}

/* --------------------------------------------------------------------------
   2. ФОН — атмосфера и градиент
   -------------------------------------------------------------------------- */
.block-04__atmosphere {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.block-04__atmosphere-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #0a0a0f 0%,
    #0a0a0f 20%,
    #0a0a10 23%,
    #0a0b12 26%,
    #0a0c15 29%,
    #0b0e19 32%,
    #0b101c 35%,
    #0c121f 38%,
    #0d1423 41%,
    #0e1627 44%,
    #0f182b 47%,
    #101a2f 50%,
    #111d34 53%,
    #132038 56%,
    #15233d 59%,
    #172742 62%,
    #1a2b48 65%,
    #1d304e 68%,
    #213655 71%,
    #253c5d 74%,
    #2a4366 77%,
    #304b6f 80%,
    #375478 83%,
    #3f5e82 86%,
    #48698c 89%,
    #527696 91%,
    #5d839f 93%,
    #6a91a8 95%,
    #78a0b2 96.5%,
    #86acc0 97.5%,
    #94b8ca 98.3%,
    #a2c4d4 98.8%,
    #b0d0de 99.2%,
    #bddce8 99.5%,
    #c9e5ef 99.7%,
    #d4edf4 99.85%,
    #dff3f8 99.92%,
    #e8f6fa 99.97%,
    #eef8fb 100%
  );
}

/* --------------------------------------------------------------------------
   3. КОМЕТЫ — верхняя половина блока (canvas, js/block-04-free.js)
   -------------------------------------------------------------------------- */
.block-04__comets-zone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52%;
  overflow: hidden;
}

.block-04__comets {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* --------------------------------------------------------------------------
   4. КОНТЕНТ И ЗАГОЛОВКИ БЛОКА
   -------------------------------------------------------------------------- */
.block-04__content {
  position: relative;
  z-index: var(--z-content);
}

.block-04 .section-title {
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.block-04 .section-title span {
  background: linear-gradient(120deg, #ffb347, #ff6b1a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.block-04 .section-lead {
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  max-width: none;
}

/* --------------------------------------------------------------------------
   5. ПОДПИСЬ «ПО КУРСАМ»
   -------------------------------------------------------------------------- */
.block-04__samples-intro {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: calc(var(--gap-lg) * -0.25) auto var(--gap-lg);
  max-width: 52ch;
}

/* --------------------------------------------------------------------------
   6. СЕТКА ТРЁХ КАРТОЧЕК ВИДЕО
   Слева → направо: полный курс | новый уровень | лучше чем основа
   -------------------------------------------------------------------------- */
.block-04__samples {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.25rem;
  align-items: stretch;
  margin-bottom: var(--gap-lg);
  padding-block: 20px 16px;
  overflow: visible;
}

/* --------------------------------------------------------------------------
   7. КАРТОЧКА ВИДЕО — только opacity (без scale всей карточки)
   Фокус синхронизирован с блоком 3 (block-03-courses.js). Scale только у .block-04__sample-media.
   -------------------------------------------------------------------------- */
.block-04__sample-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  opacity: 0.72;
  transition: opacity 0.45s var(--ease-smooth);
  cursor: default;
}

.block-04__sample-card.is-active {
  opacity: 1;
  z-index: 2;
}

.block-04__sample-card.is-dimmed {
  opacity: 0.72;
  z-index: 0;
}

/* --------------------------------------------------------------------------
   8. ВИДЕО — scale внутри рамки (overflow:hidden), текст и кнопки не смещаются
   -------------------------------------------------------------------------- */
@keyframes block04VideoFloat {
  0%, 100% { transform: scale(1) translateY(2px); }
  50% { transform: scale(1) translateY(-3px); }
}

/* --------------------------------------------------------------------------
   9. НАЗВАНИЕ КУРСА НАД ВИДЕО
   HTML: .block-04__course-label + .block-04__course-label-en
   -------------------------------------------------------------------------- */
.block-04__course-label {
  margin: 0 0 0.75rem;
  padding: 0;
  flex-shrink: 0;
  min-height: 3.1em;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  transition: text-shadow 0.45s var(--ease-smooth), opacity 0.45s var(--ease-smooth);
}

.block-04__course-label-en {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: linear-gradient(120deg, #ffb347, #ff6b1a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.block-04__sample-card.is-active .block-04__course-label {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 159, 61, 0.22);
}

/* --------------------------------------------------------------------------
   10. ОБЁРТКА ВИДЕО — рамка и подсветка активной карточки
   -------------------------------------------------------------------------- */
.block-04__sample-media {
  position: relative;
  width: 100%;
  max-width: 100%;
  flex-shrink: 0;
  aspect-ratio: 16 / 11.25;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0a0a12;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  transform: scale(0.99);
  transform-origin: center center;
  transition:
    border-color 0.55s var(--ease-smooth),
    box-shadow 0.55s var(--ease-smooth),
    transform 0.55s var(--ease-smooth);
}

.block-04__sample-card.is-active .block-04__sample-media {
  transform: scale(1.04);
  border-color: #ffd84d;
  box-shadow:
    0 0 0 1px rgba(255, 220, 90, 0.7),
    0 0 22px rgba(255, 200, 55, 0.45),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

.block-04__sample-card.is-dimmed .block-04__sample-media {
  transform: scale(0.99);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* --------------------------------------------------------------------------
   11. ТЕГ <video> В КАРТОЧКЕ
   -------------------------------------------------------------------------- */
.block-04__sample-video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: block;
  object-fit: cover;
  background: #0a0a0f;
  vertical-align: top;
  transform-origin: center center;
  transition: transform 0.55s var(--ease-smooth);
}

.block-04__sample-card.is-active .block-04__sample-video {
  transform: scale(1.03);
  animation: none;
}

.block-04__sample-card.is-dimmed .block-04__sample-video {
  animation: block04VideoFloat 8s ease-in-out infinite;
}

.block-04__samples .block-04__sample-card:nth-child(2).is-dimmed .block-04__sample-video {
  animation-delay: -2.5s;
}

.block-04__samples .block-04__sample-card:nth-child(3).is-dimmed .block-04__sample-video {
  animation-delay: -5s;
}

/* --------------------------------------------------------------------------
   12. ТЕКСТ ОПИСАНИЯ ПОД ВИДЕО
   -------------------------------------------------------------------------- */
.block-04__course-desc {
  margin: 0.65rem 0 1rem;
  padding: 0 0.25rem;
  flex: 1 1 auto;
  flex-shrink: 0;
  min-height: calc(var(--text-sm) * 1.5 * 3);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------------------
   13. КНОПКА «Смотреть все N видео» ПОД ВИДЕО
   HTML: <a class="block-04__samples-btn btn"> → лендинг курса (fullmasters / brera / better)
   Ширина фиксированная — одинаковая у всех трёх карточек.
   -------------------------------------------------------------------------- */
.block-04__samples-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15.5rem;
  max-width: calc(100% - 1rem);
  flex-shrink: 0;
  margin-top: auto;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0.75rem;
  padding: 1.25rem 1.1rem;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background 0.45s var(--ease-smooth),
    border-color 0.45s var(--ease-smooth),
    box-shadow 0.45s var(--ease-smooth),
    color 0.45s var(--ease-smooth);
}

/* Кнопка — активная карточка (оранжевая заливка) */
.block-04__sample-card.is-active .block-04__samples-btn {
  background: var(--gradient-accent);
  color: #0a0a0f;
  border-color: transparent;
  box-shadow: 0 8px 32px rgba(255, 107, 26, 0.4);
  transform: translateY(-3px);
}

.block-04__sample-card.is-active .block-04__samples-btn:hover,
.block-04__sample-card.is-active .block-04__samples-btn:focus-visible {
  color: #0a0a0f;
  box-shadow: 0 8px 28px rgba(255, 107, 26, 0.45);
}

/* Кнопка — приглушённая карточка (полупрозрачная) */
.block-04__sample-card.is-dimmed .block-04__samples-btn {
  background: rgba(255, 107, 26, 0.22);
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 159, 61, 0.35);
  box-shadow: none;
}

.block-04__sample-card.is-dimmed .block-04__samples-btn:hover,
.block-04__sample-card.is-dimmed .block-04__samples-btn:focus-visible {
  background: rgba(255, 107, 26, 0.32);
  color: #fff;
}

/* --------------------------------------------------------------------------
   14. ДЕКОР — ножницы в углу блока
   -------------------------------------------------------------------------- */
.block-04__deco-scissors {
  position: absolute;
  right: 5%;
  top: 12%;
  width: 48px;
  opacity: 0.1;
  color: rgba(255, 255, 255, 0.6);
  z-index: 1;
  animation: spinSlow 20s linear infinite;
  pointer-events: none;
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   15. МОБИЛКА И prefers-reduced-motion
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .block-04__samples {
    grid-template-columns: 1fr;
    max-width: 420px;
    margin-inline: auto;
    gap: var(--gap-lg);
  }
}

@media (max-width: 768px) {
  .block-04__sample-media {
    min-height: 250px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .block-04__sample-card,
  .block-04__sample-media,
  .block-04__sample-video {
    animation: none !important;
    transition: none;
  }
  .block-04__sample-card.is-dimmed,
  .block-04__sample-card.is-active {
    opacity: 1;
  }
  .block-04__sample-media,
  .block-04__sample-video {
    transform: none;
  }
}
