/* Lecteur embarqué : la page entière est l'iframe, le lecteur remplit tout l'espace. */
:root {
  /* --accent : couleur choisie dans l'admin (page Lecteur), posée sur <html> par embed.njk. */
  --accent: #ff0757;
  --plyr-color-main: var(--accent);
  --plyr-video-background: #000;
  --gate-fg: #fff;
  --gate-bg: rgba(0, 0, 0, .55);
  --gate-accent: var(--accent);
  --gate-accent-dark: color-mix(in srgb, var(--accent) 82%, #000);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--gate-fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.wrap {
  position: fixed;
  inset: 0;
  background: #000;
}

/* Plyr : pas de ratio imposé, on remplit la fenêtre (letterbox par object-fit). */
.wrap .plyr,
.wrap .plyr--video,
.wrap .plyr__video-wrapper {
  height: 100%;
  width: 100%;
  aspect-ratio: auto !important;
  padding-bottom: 0 !important;
}
.wrap video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Surcouche de démarrage (poster + bouton). Seule zone cliquable qui ouvre une publicité. */
.gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  background-color: #000;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.gate[hidden] { display: none; }

.gate-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  padding-inline: 14px 22px; /* propriétés logiques : symétrie correcte en arabe (RTL) */
  border: 0;
  border-radius: 999px;
  background: var(--gate-accent);
  color: var(--gate-fg);
  font: 600 16px/1.2 inherit;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
  transition: transform .12s ease, background .12s ease;
  /* Texte personnalisé long : le bouton reste dans l'iframe, le libellé est tronqué (…), le symbole jamais. */
  max-width: calc(100% - 24px);
  min-width: 0;
}
.gate-btn:hover, .gate:hover .gate-btn { background: var(--gate-accent-dark); transform: scale(1.03); }
.gate-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.gate-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent currentColor;
  margin-inline-start: 6px;
  flex: none;
}

.gate-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gate-label[hidden] { display: none; }

/* Style « symbole play seul » : bouton rond, sans texte (le libellé reste dans aria-label). */
.gate-btn--icon {
  width: 76px;
  height: 76px;
  padding: 0;
  gap: 0;
  justify-content: center;
}
.gate-btn--icon .gate-icon {
  border-width: 15px 0 15px 25px;
  margin-inline-start: 7px;
}

/* Ligne d'information sous le bouton : clics restants · mention publicité (traduits). */
.gate-sub {
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--gate-bg);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  max-width: 90%;
}
.gate-sub[hidden] { display: none; }

.gate-hint {
  margin: 0;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--gate-bg);
  font-size: 13px;
  text-align: center;
  max-width: 90%;
}

/* Bouton « Reprendre » : après un retour d'onglet qui a mis la vidéo en pause (iOS). */
.resume {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--gate-accent);
  color: var(--gate-fg);
  font: 600 16px/1.2 inherit;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
}
.resume[hidden] { display: none; }

.error {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--gate-bg);
  font-size: 14px;
  text-align: center;
  max-width: 90%;
}
.error[hidden] { display: none; }

/* Page « indisponible » */
.unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}
.unavailable-box { text-align: center; padding: 24px; max-width: 480px; }
.unavailable-box h1 { font-size: 20px; margin: 0 0 8px; font-weight: 600; }
.unavailable-box p { margin: 0; opacity: .8; font-size: 15px; }

@media (max-width: 480px) {
  .gate-btn, .resume { font-size: 14px; padding-block: 10px; padding-inline: 12px 18px; }
  .gate-btn--icon { width: 64px; height: 64px; padding: 0; }
  .gate-sub { font-size: 12px; }
}

/* Preroll VAST (public/player/vast.js) : surcouche au-dessus de la vidéo, sous les messages. */
.ad-layer {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-layer .ad-video, .ad-layer video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}
.ad-layer[data-state="loading"]::after {
  content: '';
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: var(--accent);
  animation: ad-spin .8s linear infinite;
}
@keyframes ad-spin { to { transform: rotate(360deg); } }
.ad-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}
.ad-skip {
  position: absolute;
  bottom: 56px;
  inset-inline-end: 0;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-inline-end: 0;
  border-radius: 6px 0 0 6px;
  background: rgba(0, 0, 0, .75);
  color: rgba(255, 255, 255, .8);
  font: 600 14px/1.2 inherit;
  cursor: default;
}
.ad-skip[data-ready] { color: #fff; cursor: pointer; border-color: #fff; }
.ad-skip[data-ready]:hover { background: rgba(0, 0, 0, .9); }
.ad-skip:focus-visible, .ad-cta:focus-visible, .ad-mute:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ad-cta {
  position: absolute;
  bottom: 12px;
  inset-inline-start: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.ad-mute {
  position: absolute;
  bottom: 12px;
  inset-inline-end: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  cursor: pointer;
}
.ad-mute svg { width: 20px; height: 20px; }
@media (max-width: 480px) {
  .ad-skip { bottom: 50px; font-size: 13px; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ad-layer[data-state="loading"]::after { animation: none; }
}
