/* ============================================================================
 * video-source.css
 * Стили переключателя источника видео и модального окна плеера.
 * Палитра подобрана под лендинг: красный #ec1f25, фон #191f2d, шрифт наследуется
 * от страницы (DIN Pro). Все классы с префиксами .video-source-toggle / .vsm-
 * не пересекаются с существующими стилями.
 * ========================================================================== */

/* --------------------------- Переключатель -------------------------------- */
.video-source-toggle {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  padding: 5px;
  width: -moz-fit-content;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.video-source-toggle__btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 10px 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, opacity 0.25s ease;
}

.video-source-toggle__btn:hover {
  opacity: 0.85;
}

.video-source-toggle__btn.is-active {
  color: #fff;
  opacity: 1;
}

/* Активная вкладка — в фирменных тонах источника. */
.video-source-toggle__btn[data-source="vk"].is-active {
  background: #0066ff; /* синий ВК, контраст с белым 4.8:1 (проходит WCAG AA) */
}

.video-source-toggle__btn[data-source="youtube"].is-active {
  background: #ff0000; /* красный YouTube */
}

.video-source-toggle__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .video-source-toggle__btn {
    padding: 9px 18px;
    font-size: 12px;
  }
}

/* ----------------------------- Модалка ------------------------------------ */
.vsm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 13, 20, 0.92);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.vsm-overlay.is-open {
  opacity: 1;
}

/* КРИТИЧНО: класс .vsm-overlay задаёт display:flex и перебивает атрибут hidden
   (правило автора важнее display:none из hidden). Без этого правила скрытый
   оверлей остаётся на экране невидимым слоем и перехватывает клики по всей
   странице. Специфичность класс+атрибут выше, чем у одного класса. */
.vsm-overlay[hidden] {
  display: none;
}

.vsm-dialog {
  position: relative;
  width: min(1100px, 92vw);
  max-height: 86vh;
  aspect-ratio: 16 / 9;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.3s ease;
}

.vsm-overlay.is-open .vsm-dialog {
  transform: translateY(0) scale(1);
}

.vsm-frame-holder,
.vsm-frame {
  width: 100%;
  height: 100%;
}

.vsm-frame-holder {
  position: relative;
}

/* Индикатор загрузки, пока iframe плеера не подгрузился. */
.vsm-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: vsm-spin 0.8s linear infinite;
}

@keyframes vsm-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .vsm-spinner { animation: none; }
}

.vsm-frame {
  display: block;
  border: 0;
  border-radius: 10px;
  background: #000;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.vsm-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.vsm-close:hover {
  background: #ec1f25;
  transform: rotate(90deg);
}

.vsm-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Блокировка прокрутки страницы под модалкой. */
.vsm-lock {
  overflow: hidden;
}

/* На небольших экранах крестик уводим внутрь, чтобы он не уезжал за край. */
@media (max-width: 600px) {
  .vsm-overlay { padding: 16px; }
  .vsm-close {
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.55);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vsm-overlay,
  .vsm-dialog,
  .vsm-close { transition: none; }
}

/* -------------------- Фолбэк при недоступном YouTube ---------------------- */
.vsm-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: #000;
  border-radius: 10px;
  color: #fff;
}

.vsm-fb-title { margin: 0; font-size: 18px; font-weight: 700; }
.vsm-fb-text { margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.7); }

.vsm-fb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.vsm-fb-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
}

.vsm-fb-btn--vk { background: #0066ff; }
.vsm-fb-btn:focus-visible,
.vsm-fb-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.vsm-fb-link {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
