/* One DOM, four skins. Everything skin-specific lives under [data-skin=…];
   the shared block below is layout and behaviour only. */

.ebv {
  --ebv-accent: #2563eb;
  --ebv-ratio: 16 / 9;
  --ebv-ink: rgba(255, 255, 255, 0.94);
  --ebv-ink-dim: rgba(255, 255, 255, 0.62);
  --ebv-track: rgba(255, 255, 255, 0.26);
  --ebv-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--ebv-ratio);
  background: #000;
  overflow: hidden;
  border-radius: inherit;
  font: 500 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ebv-ink);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.ebv--fill { position: absolute; inset: 0; aspect-ratio: auto; height: 100%; }
.ebv:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ebv-accent) 70%, transparent); }

.ebv-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ---- big play ----------------------------------------------------------- */
.ebv-bigplay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 999px;
  background: var(--ebv-accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  transition: transform 0.22s var(--ebv-ease), opacity 0.18s var(--ebv-ease);
}
.ebv-bigplay svg { width: 34px; height: 34px; fill: currentColor; margin-left: 3px; }
.ebv-bigplay:hover { transform: scale(1.07); }
.ebv-bigplay:active { transform: scale(0.97); }
.ebv.is-playing .ebv-bigplay { opacity: 0; pointer-events: none; transform: scale(0.7); }

/* ---- controls shell ----------------------------------------------------- */
.ebv-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--ebv-ease), transform 0.2s var(--ebv-ease);
}
.ebv:hover .ebv-controls,
.ebv:focus-within .ebv-controls,
.ebv.is-menu-open .ebv-controls,
.ebv:not(.is-playing) .ebv-controls { opacity: 1; transform: none; }
/* Idle beats every reveal above, hover and focus included; player.js only sets
   it while playing with no menu open. pointer-events: none so the tap that
   wakes a hidden player lands on the video, not an invisible button. */
.ebv.is-playing.is-idle { cursor: none; }
.ebv.is-playing.is-idle .ebv-controls {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}
/* controls=auto: being paused is no reason to show the chrome, so the poster
   starts clean. Hover, focus or an open menu still bring it up. */
.ebv--autohide:not(.is-playing):not(:hover):not(:focus-within):not(.is-menu-open) .ebv-controls {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.ebv-bar { display: flex; align-items: center; gap: 6px; }
.ebv-flex { flex: 1 1 auto; }

.ebv-btn {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
  transition: background-color 0.15s var(--ebv-ease), color 0.15s var(--ebv-ease);
}
.ebv-btn:hover { background: rgba(255, 255, 255, 0.16); }
.ebv-btn:active { transform: scale(0.94); }
.ebv-btn svg { width: 20px; height: 20px; fill: currentColor; }
.ebv-btn svg [stroke] { stroke: currentColor; }
.ebv-btn.is-active { color: var(--ebv-accent); }

.ebv-time { flex: none; font-variant-numeric: tabular-nums; color: var(--ebv-ink-dim); white-space: nowrap; }

/* ---- volume: slider expands on hover ------------------------------------ */
.ebv-volume-wrap { display: flex; align-items: center; }
.ebv-volume {
  width: 0;
  opacity: 0;
  margin: 0;
  accent-color: var(--ebv-accent);
  background: transparent;
  transition: width 0.2s var(--ebv-ease), opacity 0.2s var(--ebv-ease), margin 0.2s var(--ebv-ease);
}
.ebv-volume-wrap:hover .ebv-volume,
.ebv-volume:focus-visible { width: 66px; opacity: 1; margin: 0 6px 0 2px; }

/* ---- scrub bar ---------------------------------------------------------- */
.ebv-scrub-row { position: relative; display: flex; align-items: center; }
.ebv-scrub {
  position: relative;
  flex: 1 1 auto;
  height: 4px;
  border-radius: 999px;
  background: var(--ebv-track);
  cursor: pointer;
  touch-action: none;
  transition: height 0.14s var(--ebv-ease);
}
/* 18px hit target behind a 4px bar */
.ebv-scrub::before { content: ""; position: absolute; inset: -9px 0; }
.ebv-scrub:hover, .ebv-scrub:focus-visible { height: 6px; }
.ebv-buffered,
.ebv-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: inherit;
  pointer-events: none;
}
.ebv-buffered { background: rgba(255, 255, 255, 0.32); width: 0; }
.ebv-progress { background: var(--ebv-accent); width: 0; }
.ebv-handle {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.14s var(--ebv-ease), transform 0.14s var(--ebv-ease);
}
.ebv:hover .ebv-handle,
.ebv-scrub:focus-visible .ebv-handle { opacity: 1; transform: scale(1); }

/* ---- scrub thumbnail preview -------------------------------------------- */
.ebv-preview {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(12, 12, 14, 0.86);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.14s var(--ebv-ease), transform 0.14s var(--ebv-ease);
}
.ebv.is-previewing .ebv-preview { opacity: 1; transform: none; }
.ebv-preview-img {
  border-radius: 6px;
  background-repeat: no-repeat;
  background-color: #000;
}
.ebv-preview--time-only { padding: 4px 8px; }
.ebv-preview--time-only .ebv-preview-img { display: none; }
.ebv-preview-time { font-size: 11px; font-variant-numeric: tabular-nums; color: #fff; }

/* ---- settings menu ------------------------------------------------------ */
.ebv-menu-wrap { position: relative; flex: none; }
.ebv-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 148px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: rgba(16, 16, 18, 0.94);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.15s var(--ebv-ease), transform 0.15s var(--ebv-ease);
  z-index: 3;
}
.ebv.is-menu-open .ebv-menu { opacity: 1; transform: none; pointer-events: auto; }
.ebv-menu-label {
  padding: 6px 8px 4px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ebv-ink-dim);
}
.ebv-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ebv-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ebv-menu-item:hover { background: rgba(255, 255, 255, 0.12); }
.ebv-menu-check { width: 14px; height: 14px; display: grid; place-items: center; opacity: 0; }
.ebv-menu-check svg { width: 14px; height: 14px; }
.ebv-menu-check svg [stroke] { stroke: var(--ebv-accent); }
.ebv-menu-item.is-active .ebv-menu-check { opacity: 1; }
.ebv-menu-item.is-active { color: #fff; }

/* ---- teaser (hover preview) --------------------------------------------- */
.ebv-teaser {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ebv-ease);
}
.ebv.is-teasing .ebv-teaser { opacity: 1; }
.ebv.is-playing .ebv-teaser { opacity: 0; }

/* ---- "tap for sound" ---------------------------------------------------- */
.ebv-unmute {
  position: absolute;
  top: 12px;
  right: 12px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.66);
  backdrop-filter: blur(12px);
  color: var(--ebv-ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  z-index: 4;
  animation: ebv-rise 0.3s var(--ebv-ease);
}
.ebv.is-autoplay-muted .ebv-unmute { display: inline-flex; }
.ebv-unmute:hover { background: rgba(30, 30, 34, 0.82); }
.ebv-unmute svg { width: 15px; height: 15px; fill: currentColor; }
.ebv-unmute svg [stroke] { stroke: currentColor; }

@keyframes ebv-rise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* ---- loading ------------------------------------------------------------ */
.ebv-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #fff;
  opacity: 0;
  pointer-events: none;
}
.ebv.is-loading .ebv-spinner { opacity: 1; animation: ebv-spin 0.8s linear infinite; }
.ebv.is-loading .ebv-bigplay { opacity: 0; }
@keyframes ebv-spin { to { transform: rotate(360deg); } }

/* =========================================================================
   SKIN: glass - controls float in a blurred, inset container
   ========================================================================= */
.ebv[data-skin="glass"] .ebv-controls {
  left: 12px;
  right: 12px;
  bottom: 12px;
  gap: 8px;
  padding: 10px 12px 8px;
  border-radius: 16px;
  background: rgba(18, 18, 20, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.ebv[data-skin="glass"] .ebv-bar { gap: 4px; }
.ebv[data-skin="glass"] .ebv-preview { bottom: calc(100% + 14px); }

@media (max-width: 480px) {
  .ebv[data-skin="glass"] .ebv-controls { left: 8px; right: 8px; bottom: 8px; padding: 8px 8px 6px; }
}

/* =========================================================================
   SKIN: edge - flush to the bottom edge over a gradient scrim
   ========================================================================= */
.ebv[data-skin="edge"] .ebv-controls {
  gap: 2px;
  padding: 34px 14px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.45) 45%, rgba(0, 0, 0, 0) 100%);
}
.ebv[data-skin="edge"] .ebv-scrub { height: 4px; }
.ebv[data-skin="edge"] .ebv-scrub:hover { height: 7px; }
.ebv[data-skin="edge"] .ebv-bar { gap: 4px; margin-top: 4px; }

/* =========================================================================
   SKIN: minimal - a hairline until you interact
   ========================================================================= */
.ebv[data-skin="minimal"] .ebv-controls {
  gap: 0;
  padding: 30px 14px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  opacity: 1;                 /* the shell stays; the BAR is what hides */
  transform: none;
}
.ebv[data-skin="minimal"] .ebv-bar {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.24s var(--ebv-ease), opacity 0.18s var(--ebv-ease), margin-top 0.24s var(--ebv-ease);
}
.ebv[data-skin="minimal"]:hover .ebv-bar,
.ebv[data-skin="minimal"]:focus-within .ebv-bar,
.ebv[data-skin="minimal"].is-menu-open .ebv-bar,
.ebv[data-skin="minimal"]:not(.is-playing) .ebv-bar {
  max-height: 40px;
  margin-top: 8px;
  opacity: 1;
}
/* Idle: hairline progress, no scrim, no track. */
.ebv[data-skin="minimal"] .ebv-scrub { height: 2px; background: rgba(255, 255, 255, 0.2); }
.ebv[data-skin="minimal"]:hover .ebv-scrub { height: 6px; background: var(--ebv-track); }
.ebv[data-skin="minimal"].is-playing:not(:hover):not(:focus-within) .ebv-controls {
  padding: 0;
  background: none;
}
.ebv[data-skin="minimal"].is-playing:not(:hover):not(:focus-within) .ebv-scrub {
  border-radius: 0;
}
/* Idle falls back to the same hairline instead of hiding the shell outright. */
.ebv[data-skin="minimal"].is-playing.is-idle .ebv-controls {
  padding: 0;
  background: none;
  opacity: 1;
  transform: none;
}
.ebv[data-skin="minimal"].is-playing.is-idle .ebv-bar { max-height: 0; margin-top: 0; opacity: 0; }
.ebv[data-skin="minimal"].is-playing.is-idle .ebv-scrub {
  height: 2px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.2);
}
.ebv[data-skin="minimal"].is-playing.is-idle .ebv-handle { opacity: 0; }

/* =========================================================================
   SKIN: bar - a solid accent strip along the bottom, always visible.
   Time on the left, scrub inline, actions on the right.
   ========================================================================= */
.ebv[data-skin="bar"] {
  /* Both tunable from the outside. Alpha: lower shows more video through,
     toward 100% is a solid strip. Height drives the bar AND the offsets of the
     centred overlays, so they can never drift apart. */
  --ebv-bar-alpha: 82%;
  --ebv-bar-h: 34px;
  /* Always visible is the point of this skin, so it never idles away. */
  --ebv-autohide: 0;
  --ebv-ink: var(--ebv-bar-ink, #fff);
  --ebv-ink-dim: color-mix(in srgb, var(--ebv-bar-ink, #fff) 78%, transparent);
  --ebv-track: color-mix(in srgb, var(--ebv-bar-ink, #fff) 32%, transparent);
}
.ebv[data-skin="bar"] .ebv-controls {
  /* `display: contents` on .ebv-bar lifts its children into this flex row, so
     the time can sit left of the scrub even though the markup nests it. One
     DOM, four skins - the alternative was a skin-specific DOM branch. */
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: var(--ebv-bar-h);
  padding: 0 10px;
  /* Translucent, and it overlays the video rather than reserving space below
     it - reserving space would put black letterbox behind the transparency
     instead of the picture, which defeats the point. */
  background: color-mix(in srgb, var(--ebv-accent) var(--ebv-bar-alpha), transparent);
  backdrop-filter: blur(10px) saturate(1.25);
  -webkit-backdrop-filter: blur(10px) saturate(1.25);
  opacity: 1;
  transform: none;
}
.ebv[data-skin="bar"] .ebv-bar { display: contents; }

.ebv[data-skin="bar"] .ebv-bar > * { order: 4; }
.ebv[data-skin="bar"] .ebv-play { order: 1; margin-left: -4px; }
.ebv[data-skin="bar"] .ebv-time {
  order: 2;
  font-size: 12px;
  font-weight: 600;
  color: var(--ebv-ink);
}
.ebv[data-skin="bar"] .ebv-scrub-row { order: 3; flex: 1 1 auto; }
.ebv[data-skin="bar"] .ebv-flex { display: none; }

.ebv[data-skin="bar"] .ebv-scrub { height: 3px; background: var(--ebv-track); }
.ebv[data-skin="bar"] .ebv-scrub:hover { height: 4px; }
/* The bar is short, so the invisible hit target has to stay tall enough to
   grab comfortably - it must not shrink with the visible track. */
.ebv[data-skin="bar"] .ebv-scrub::before { inset: -12px 0; }
.ebv[data-skin="bar"] .ebv-progress { background: var(--ebv-ink); }
.ebv[data-skin="bar"] .ebv-buffered { background: color-mix(in srgb, var(--ebv-bar-ink, #fff) 22%, transparent); }
.ebv[data-skin="bar"] .ebv-handle {
  background: var(--ebv-ink);
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  opacity: 1;
  transform: scale(1);
}

.ebv[data-skin="bar"] .ebv-btn { color: var(--ebv-ink); width: 26px; height: 26px; border-radius: 6px; }
.ebv[data-skin="bar"] .ebv-btn svg { width: 17px; height: 17px; }
.ebv[data-skin="bar"] .ebv-btn:hover { background: color-mix(in srgb, var(--ebv-bar-ink, #fff) 16%, transparent); }
/* Minimal means minimal: the volume slider and PiP go, and the settings menu
   keeps everything they contained. */
.ebv[data-skin="bar"] .ebv-volume { display: none; }
.ebv[data-skin="bar"] .ebv-preview { bottom: calc(100% + 16px); }
.ebv[data-skin="bar"] .ebv-menu { bottom: calc(100% + 14px); }

/* Nudge the centred overlays up by half the bar so they read as centred in the
   picture the viewer actually sees. Insets, not margins: margin-bottom would
   fight the `margin: auto` that does the centring. */
.ebv[data-skin="bar"] .ebv-bigplay,
.ebv[data-skin="bar"] .ebv-spinner { inset: 0 0 var(--ebv-bar-h); }

@media (max-width: 480px) {
  .ebv[data-skin="bar"] { --ebv-bar-h: 32px; }
  .ebv[data-skin="bar"] .ebv-controls { padding: 0 8px; gap: 6px; }
}

/* ---- shared responsive + motion ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ebv-controls, .ebv-bigplay, .ebv-handle, .ebv-preview, .ebv-menu, .ebv-bar, .ebv-volume {
    transition: none;
  }
  .ebv.is-loading .ebv-spinner { animation-duration: 2s; }
}

@media (max-width: 480px) {
  .ebv-volume-wrap:hover .ebv-volume { width: 0; opacity: 0; margin: 0; }
  .ebv-time { font-size: 11px; }
  .ebv-bigplay { width: 62px; height: 62px; }
  .ebv-bigplay svg { width: 28px; height: 28px; }
}

/* Coarse pointers never hover, so the chrome must not depend on it. */
@media (hover: none) {
  .ebv .ebv-controls { opacity: 1; transform: none; }
  .ebv[data-skin="minimal"] .ebv-bar { max-height: 40px; margin-top: 8px; opacity: 1; }
  .ebv-handle { opacity: 1; transform: scale(1); }
}
