/*
 * Chargement des médias lourds : vidéos d'en-tête (assets/js/xds-lazy-video.js)
 * et bloc Twitch de l'accueil. Squelette « shimmer » jusqu'au chargement, puis fondu.
 */

/* --- Vidéos d'en-tête --- */
video[data-xds-video] {
  transition: opacity 0.5s ease;
}

/* Sans affiche, la vidéo reste invisible jusqu'à sa première image (pas de cadre noir). */
video[data-xds-video]:not([poster]):not(.is-ready) {
  opacity: 0;
}

video[data-xds-video].is-failed {
  display: none;
}

/* Les fonds .video-background sont déjà positionnés (absolute) et rognés. */
.xds-media-skeleton:not(.video-background) {
  position: relative;
  overflow: hidden;
}

.xds-media-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.16) 45%, rgba(255, 255, 255, 0.04) 60%, transparent 80%);
  background-size: 220% 100%;
  animation: xds-media-shimmer 1.6s linear infinite;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

[data-bs-theme="dark"] .xds-media-skeleton::after {
  background-image: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.07) 45%, rgba(255, 255, 255, 0.02) 60%, transparent 80%);
}

.xds-media-skeleton.is-settled::after {
  opacity: 0;
  animation: none;
}

@keyframes xds-media-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

/* --- Bloc Twitch de l'accueil --- */
.xds-twitch-frame {
  position: relative;
}

.xds-twitch-frame > iframe[data-consent-category] {
  opacity: 0;
  transition: opacity 0.45s ease;
}

.xds-twitch-frame.is-embed-loaded > iframe[data-consent-category] {
  opacity: 1;
}

.xds-twitch-skeleton {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: inherit;
  background-color: var(--my-white-bg-subtle, #ffffffee);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

[data-bs-theme="dark"] .xds-twitch-skeleton {
  background-color: var(--my-dark-bg-subtle, #16171be5);
}

/* Le squelette n'apparaît que si les embeds sont acceptés (sinon : message de consentement). */
html:not([data-cookie-embeds="granted"]) .xds-twitch-skeleton,
.xds-twitch-frame.is-embed-loaded .xds-twitch-skeleton {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.xds-twitch-skeleton__bar,
.xds-twitch-skeleton__screen,
.xds-twitch-skeleton__line {
  border-radius: 12px;
  background: rgba(119, 0, 255, 0.1);
}

.xds-twitch-skeleton__screen {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  color: rgba(119, 0, 255, 0.55);
}

.xds-twitch-skeleton__bar {
  height: 2.25rem;
}

.xds-twitch-skeleton__line {
  height: 0.85rem;
}

.xds-twitch-skeleton__line:nth-child(odd) {
  width: 78%;
}

.xds-twitch-skeleton__line:nth-child(even) {
  width: 56%;
}

.xds-twitch-skeleton__lines {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.7rem;
}

.xds-twitch-skeleton__shimmer {
  overflow: hidden;
}

.xds-twitch-skeleton__shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.18) 45%, transparent 75%);
  background-size: 220% 100%;
  animation: xds-media-shimmer 1.6s linear infinite;
  pointer-events: none;
}

.xds-twitch-skeleton__screen svg {
  width: 3rem;
  height: 3rem;
}

.xds-twitch-skeleton__fallback {
  position: absolute;
  inset: auto 1rem 1rem;
  z-index: 2;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  text-align: center;
  color: var(--bs-body-color);
  background-color: var(--my-white-bg-subtle-solid, #ffffff);
}

[data-bs-theme="dark"] .xds-twitch-skeleton__fallback {
  background-color: var(--my-dark-bg-subtle-solid, #16171b);
}

.xds-twitch-skeleton__fallback a,
.xds-twitch-skeleton__fallback button {
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .xds-media-skeleton::after,
  .xds-twitch-skeleton__shimmer::after {
    animation: none;
  }

  video[data-xds-video],
  .xds-twitch-frame > iframe[data-consent-category],
  .xds-twitch-skeleton {
    transition: none;
  }
}
