/* Video Hub — YouTube-inspired player for WordPress */

.vh-player {
  --vh-accent: #ff0000;
  --vh-accent-hover: #cc0000;
  --vh-radius: 12px;
  --vh-bg: #0f0f0f;
  --vh-control-bg: rgba(28, 28, 28, 0.9);
  --vh-text: #f1f1f1;
  --vh-text-muted: #aaa;

  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--vh-bg);
  border-radius: var(--vh-radius);
  overflow: hidden;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--vh-text);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  contain: layout style paint;
}

.vh-player * {
  box-sizing: border-box;
}

/* ——— Facade (click-to-play) ——— */
.vh-player.vh-facade {
  cursor: pointer;
  outline: none;
}

.vh-player.vh-facade:focus-visible {
  box-shadow: 0 0 0 3px var(--vh-accent);
}

.vh-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  transition: transform 0.45s ease, filter 0.35s ease;
}

.vh-player.vh-facade:hover .vh-poster {
  transform: scale(1.03);
  filter: brightness(0.92);
}

.vh-facade-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.08) 0%,
    transparent 45%,
    rgba(0, 0, 0, 0.35) 100%
  );
  pointer-events: none;
}

.vh-player.vh-active .vh-facade-shade,
.vh-player.vh-playing .vh-facade-shade {
  display: none;
}

.vh-facade-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 3rem 1.25rem 1.1rem;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  font-weight: 600;
  line-height: 1.35;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 2;
}

.vh-facade-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: rgba(255, 0, 0, 0.92);
  color: #fff;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, background 0.2s ease;
}

.vh-facade-play svg {
  width: 28px;
  height: 28px;
  margin-left: 3px;
}

.vh-player.vh-facade:hover .vh-facade-play {
  transform: translate(-50%, -50%) scale(1.08);
  background: var(--vh-accent);
}

.vh-facade-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 2;
}

/* ——— Video + overlays ——— */
.vh-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 1;
  cursor: pointer;
}

.vh-big-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 0, 0, 0.92);
  color: #fff;
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.vh-big-play[hidden] {
  display: none;
}

.vh-big-play svg {
  width: 28px;
  height: 28px;
  margin-left: 3px;
}

.vh-big-play:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

/* ——— Spinner ——— */
.vh-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  animation: vh-spin 0.85s linear infinite;
}

.vh-player.vh-loading .vh-spinner,
.vh-player.vh-buffering:not(.vh-error-state) .vh-spinner {
  opacity: 1;
}

@keyframes vh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— Controls ——— */
.vh-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  padding: 0 12px 10px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
}

.vh-player.vh-show-controls .vh-controls,
.vh-player.vh-is-paused .vh-controls {
  opacity: 1;
  transform: translateY(0);
}

.vh-progress-wrap {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 2px;
  direction: ltr;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.vh-progress-wrap:focus-visible {
  outline: 2px solid var(--vh-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.vh-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  transition: height 0.15s ease;
}

.vh-progress-wrap:hover .vh-progress-track {
  height: 6px;
}

.vh-progress-buffer,
.vh-progress-played {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
}

.vh-progress-buffer {
  background: rgba(255, 255, 255, 0.35);
}

.vh-progress-played {
  background: var(--vh-accent);
  z-index: 1;
}

.vh-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px;
  height: 13px;
  background: var(--vh-accent);
  border-radius: 50%;
  z-index: 2;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.vh-progress-wrap:hover .vh-progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.vh-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
}

.vh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--vh-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.vh-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.vh-btn svg {
  width: 22px;
  height: 22px;
}

.vh-btn-back,
.vh-btn-forward {
  font-size: 0.75rem;
  min-width: 32px;
}

.vh-volume-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

.vh-volume-input {
  width: 0;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
  accent-color: var(--vh-accent);
  cursor: pointer;
  direction: ltr;
}

.vh-volume-wrap:hover .vh-volume-input,
.vh-volume-wrap:focus-within .vh-volume-input {
  width: 72px;
  opacity: 1;
}

.vh-time {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--vh-text);
  white-space: nowrap;
  margin-inline-start: 4px;
}

.vh-time-sep {
  color: var(--vh-text-muted);
}

.vh-spacer {
  flex: 1;
}

.vh-menu-anchor {
  position: relative;
}

.vh-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 120px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px 0;
  border-radius: 10px;
  background: var(--vh-control-bg);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.vh-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--vh-text);
  font-size: 0.82rem;
  text-align: start;
  cursor: pointer;
}

.vh-menu button:hover,
.vh-menu button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.vh-menu button.active {
  font-weight: 700;
}

/* Safety: never show hidden/empty error overlays (legacy bug) */
.vh-error[hidden],
.vh-player:not(.vh-error-state) .vh-error {
  display: none !important;
}

/* ——— Error (only when .vh-error-state is active) ——— */
.vh-player.vh-error-state .vh-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.88);
  color: #ffb4b4;
  font-size: 0.95rem;
  z-index: 8;
}

.vh-player.vh-error-state {
  min-height: 200px;
  aspect-ratio: 16 / 9;
}

.videohub-wrap {
  margin: 1.25rem 0;
  max-width: 100%;
}

.videohub-wrap img.vh-poster {
  pointer-events: none;
}

/* ——— Pre-roll ads ——— */
.vh-ad-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}
.vh-player.vh-ad-playing .vh-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.vh-player.vh-ad-playing .vh-big-play {
  display: none !important;
}
.vh-ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: #fbbf24;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.vh-ad-bar {
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  min-height: 32px;
  direction: ltr;
}
.vh-player.vh-ad-playing .vh-ad-bar {
  display: flex;
}
.vh-ad-link {
  padding: 6px 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
  direction: rtl;
  text-align: right;
}
.vh-ad-link:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.vh-ad-skip {
  flex-shrink: 0;
  margin-left: auto;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 2px;
  background: rgba(15, 15, 15, 0.88);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  direction: rtl;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.vh-ad-skip:disabled {
  opacity: 0.85;
  cursor: default;
  color: rgba(255, 255, 255, 0.88);
}
.vh-ad-skip:not(:disabled):hover {
  background: rgba(40, 40, 40, 0.95);
  border-color: rgba(255, 255, 255, 0.65);
}

/* ——— Fullscreen ——— */
.vh-player:fullscreen {
  border-radius: 0;
  max-width: none;
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

.vh-player:fullscreen .vh-video {
  object-fit: contain;
}

/* ——— Mobile ——— */
@media (max-width: 640px) {
  .vh-facade-title {
    font-size: 0.9rem;
    padding-bottom: 0.85rem;
  }

  .vh-btn-back,
  .vh-btn-forward {
    display: none;
  }

  .vh-volume-wrap:hover .vh-volume-input {
    width: 56px;
  }

  .vh-controls {
    padding-inline: 8px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vh-poster,
  .vh-controls,
  .vh-facade-play,
  .vh-spinner {
    transition: none;
    animation: none;
  }
}
