/* ==========================================================================
   Player chrome — sits on top of Vidstack's default theme
   ========================================================================== */

:root {
  color-scheme: dark;
}

html, body {
  min-width: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  color: #fff;
  background: #000;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", sans-serif;
}

#app {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100svh;
  overflow: hidden;
}

media-player {
  display: block;
  width: 100%;
  max-height: 100svh;
  background: #000;
}

/* Aspect-ratio control via the `aspect` query param */
media-player[style*="--strmcx-aspect"] {
  aspect-ratio: var(--strmcx-aspect);
  max-height: 100svh;
}

/* ---- Embedded mode: fill the host iframe completely -------------------- */
html[data-embedded],
html[data-embedded] body,
html[data-embedded] #app,
html[data-embedded] media-player {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
}

/* ---- Theatre mode ------------------------------------------------------ */
html[data-theater] #app {
  align-items: start;
}
html[data-theater] media-player {
  max-height: 80svh;
  aspect-ratio: 16 / 9;
}

/* ---- Pre-start screen ---------------------------------------------------
   Until playback begins the player shows only the click-to-play screen:
   black background, buffering spinner while the stream loads, and the
   centered play button. Control-bar chrome and the duration badge stay
   hidden until the user starts playback. */
media-player:not([data-started]) .vds-controls,
media-player:not([data-started]) .vds-start-duration {
  display: none !important;
}

.strmcx-start {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  /* opaque so the already-buffering stream's first frame can't show through */
  background: #000;
}
.strmcx-start[hidden] { display: none; }

.strmcx-start__btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: clamp(36px, 4.5vw, 56px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #111;
  background: #fff;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.strmcx-start__btn:hover  { transform: scale(1.06); }
.strmcx-start__btn:active { transform: scale(0.96); }
.strmcx-start__btn svg {
  display: block;
  /* triangle geometry taken from the reference icon asset: 33% of the
     circle wide, 47% tall, centre offset 3.5% of the diameter to the right */
  width: 33.5%;
  height: auto;
  margin-left: 3.5%;
  fill: currentColor;
}

/* ---- Init failure -------------------------------------------------------- */
.strmcx-error {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* ---- Skip intro / outro ------------------------------------------------ */
.strmcx-skip {
  position: absolute;
  right: 16px;
  bottom: 88px;
  z-index: 15;
  display: flex;
  gap: 8px;
}
.strmcx-skip[hidden] { display: none; }

.strmcx-skip__btn {
  padding: 8px 18px;
  font: 600 13px/1 inherit;
  color: #000;
  background: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.strmcx-skip__btn:hover  { background: #e5e5e5; }
.strmcx-skip__btn:active { transform: scale(0.96); }

/* Intro/outro ranges on the seek bar — MegaPlay's marker yellow, sized to
   sit just above Vidstack's track inside the 45px slider hit area. */
.vds-time-slider { position: relative; }

.strmcx-skip-range {
  position: absolute;
  top: 50%;
  z-index: 3;
  height: 10px;
  margin-top: -5px;
  pointer-events: none;
  background: #fdd253;
  border-radius: 9999px;
  transform: scaleY(0.6);
  transform-origin: center center;
  transition: transform 150ms ease-in-out;
}

/* Keep the scrub thumb above the yellow range so the circle stays clean. */
.vds-time-slider > .vds-slider-thumb {
  z-index: 4;
}

/* ---- Next-episode overlay ---------------------------------------------- */
.strmcx-next {
  position: absolute;
  right: 16px;
  bottom: 88px;
  z-index: 14;
}
.strmcx-next[hidden] { display: none; }

.strmcx-next__btn {
  padding: 12px 22px;
  font: 700 14px/1 inherit;
  color: #000;
  background: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}
.strmcx-next__btn:hover { background: #e5e5e5; }

/* Keep our overlays clear of the control bar when it auto-hides */
media-player[data-controls] .strmcx-skip,
media-player[data-controls] .strmcx-next {
  bottom: 96px;
}

/* ---- Custom control-bar buttons ---------------------------------------- */
.strmcx-skip__btn:focus-visible,
.strmcx-next__btn:focus-visible,
button:focus-visible {
  outline: 2px solid #7c5cff;
  outline-offset: 2px;
}

/* ±10s seek buttons are desktop chrome only — the small ("minimized")
   layout has no room for them and hides them entirely. */
.vds-video-layout[data-sm] [data-strmcx-seek] {
  display: none !important;
}

/* ---- Light scheme (via set-color-scheme command) ----------------------- */
html[data-color-scheme="light"] body { background: #fff; }
html[data-color-scheme="light"] .strmcx-start__btn {
  color: #fff;
  background: #111;
  box-shadow: 0 2px 14px rgb(0 0 0 / 0.25);
}
html[data-color-scheme="light"] .strmcx-error { color: #111; }

/* ---- Stable video geometry across fullscreen toggles -------------------
   The video box always matches the provider box; letterboxing happens
   inside the element via object-fit. The vendored theme instead sizes the
   video to an aspect-ratio-derived box, which re-shapes the rendered layer
   mid-toggle and shows as a zoom/crop jump on fullscreen enter/exit. */
[data-media-provider] video {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
  object-fit: contain;
}

/* ==========================================================================
   Performance tuning
   --------------------------------------------------------------------------
   GPU-hostile effects off: backdrop-filter blur re-samples every video frame
   through the GPU (the main low-fps/jank source, worse with captions on), and
   persistent will-change forces layer re-composites on every time-update step
   (visible as a glitchy re-scale when toggling fullscreen). Plain surfaces.
   ========================================================================== */

:root {
  --media-cue-backdrop: none;
}

*,
*::before,
*::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  will-change: auto !important;
}

/* ---- Popup-blocked ad fallback -----------------------------------------
   Shown only in free-embed mode when the direct-link popup is blocked.
   Sandboxed iframe + fixed 5 s auto-close; playback continues behind it. */
.strmcx-ad {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.92);
}

.strmcx-ad__panel {
  display: flex;
  flex-direction: column;
  width: min(92%, 640px);
  height: min(80%, 420px);
  overflow: hidden;
  background: #0b0b0c;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 10px;
}

.strmcx-ad__frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #000;
}

.strmcx-ad__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: #a1a1aa;
}

.strmcx-ad__skip {
  padding: 5px 12px;
  font: inherit;
  color: #e4e4e7;
  cursor: pointer;
  background: #18181b;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 9999px;
}

.strmcx-ad__skip:hover {
  color: #fff;
  background: #27272a;
}

/* ---- Fatal stream error / failover overlay -----------------------------
   Covers the player so a dead source never looks like an idle black screen.
   With a backup provider the page navigates away; on the last provider a
   Retry button reloads the page. */
.strmcx-fatal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: rgb(0 0 0 / 0.88);
}

.strmcx-fatal__panel {
  max-width: 340px;
}

.strmcx-fatal__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: #f4f4f5;
}

.strmcx-fatal__retry {
  margin-top: 16px;
  padding: 8px 20px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #e4e4e7;
  cursor: pointer;
  background: #18181b;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 9999px;
}

.strmcx-fatal__retry:hover {
  color: #fff;
  background: #27272a;
}

.strmcx-fatal__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.strmcx-fatal__actions .strmcx-fatal__retry {
  margin-top: 0;
}

/* ---- Boot shell: resolve failure --------------------------------------- */
.strmcx-boot--error {
  gap: 8px;
}

.strmcx-boot__detail {
  max-width: 340px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: #a1a1aa;
  text-align: center;
}

.strmcx-boot__retry {
  margin-top: 10px;
  padding: 8px 20px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #e4e4e7;
  cursor: pointer;
  background: #18181b;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 9999px;
}

.strmcx-boot__retry:hover {
  color: #fff;
  background: #27272a;
}

