.cv-grammar-video-wrap {
  position: relative;
  width: 100%;
}

.cv-video-protected {
  width: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.cv-video-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: transparent;
}

/* ─────────────────────────────────────────────
   Custom grammar video player
   ───────────────────────────────────────────── */
.bdgv-player {
  --bdgv-accent: #6366f1;
  position: relative;
  border-radius: 0.9rem;
  overflow: hidden;
  background: #0b1020;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  outline: none;
}

.bdgv-player:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.55);
}

/* Animation and film episodes are identified by name, not by lesson number, so
   the title has to live inside the player rather than in a separate cv-meta. */
.bdgv-kind-animation,
.bdgv-kind-animation2 {
  --bdgv-accent: #ec4899;
}

.bdgv-kind-film,
.bdgv-kind-film2 {
  --bdgv-accent: #0ea5e9;
}

.bdgv-kind-podcast {
  --bdgv-accent: #10b981;
}

.bdgv-title {
  margin: 0;
  padding: 0.6rem 0.9rem;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.6;
  border-bottom: 2px solid var(--bdgv-accent);
}

.bdgv-caption {
  margin: 0;
  padding: 0.55rem 0.9rem;
  background: rgba(15, 23, 42, 0.92);
  color: #cbd5e1;
  font-size: 0.75rem;
  line-height: 1.75;
}

.bdgv-stage {
  position: relative;
  width: 100%;
  background: #000;
  cursor: pointer;
  line-height: 0;
}

.bdgv-player .bdgv-video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
}

.bdgv-player.is-fullscreen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #000;
}

.bdgv-player.is-fullscreen .bdgv-video {
  max-height: calc(100vh - 3.5rem);
  height: auto;
  margin: auto;
}

/* Big center play button */
.bdgv-bigplay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  z-index: 4;
  width: 4.25rem;
  height: 4.25rem;
  border: none;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.92);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.5);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.bdgv-bigplay svg {
  width: 2rem;
  height: 2rem;
  fill: currentColor;
  margin-inline-start: 0.15rem;
}

.bdgv-player.is-playing .bdgv-bigplay {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
  pointer-events: none;
}

.bdgv-bigplay:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

/* Loading spinner */
.bdgv-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.bdgv-spinner > span {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: bdgv-spin 0.8s linear infinite;
}

@keyframes bdgv-spin {
  to { transform: rotate(360deg); }
}

/* Skip flash badges */
.bdgv-stage::before,
.bdgv-stage::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
  z-index: 4;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
}

.bdgv-stage::before { content: '« ۱۰'; left: 8%; }
.bdgv-stage::after { content: '۱۰ »'; right: 8%; }

.bdgv-flash-back .bdgv-stage::before { animation: bdgv-flash 0.5s ease; }
.bdgv-flash-fwd .bdgv-stage::after { animation: bdgv-flash 0.5s ease; }

@keyframes bdgv-flash {
  0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
  30% { opacity: 1; transform: translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateY(-50%) scale(1); }
}

/* Control bar */
.bdgv-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.6), #0b1020);
  direction: ltr;
}

.bdgv-btn {
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  border: none;
  background: transparent;
  color: #e2e8f0;
  border-radius: 0.55rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.bdgv-btn svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.bdgv-btn:hover {
  background: rgba(148, 163, 184, 0.18);
  color: #fff;
}

.bdgv-btn:active {
  transform: scale(0.92);
}

/* Seek bar */
.bdgv-seek {
  flex: 1 1 auto;
  min-width: 3rem;
  height: 2.15rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0 0.35rem;
  outline: none;
}

.bdgv-seek-track {
  position: relative;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  transition: height 0.12s ease;
}

.bdgv-seek:hover .bdgv-seek-track,
.bdgv-seeking .bdgv-seek-track {
  height: 7px;
}

.bdgv-seek-buffered,
.bdgv-seek-played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
}

.bdgv-seek-buffered {
  width: 0;
  background: rgba(226, 232, 240, 0.35);
}

.bdgv-seek-played {
  width: 0;
  background: var(--bdgv-accent);
}

.bdgv-seek-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
}

.bdgv-seek:hover .bdgv-seek-thumb,
.bdgv-seek:focus-visible .bdgv-seek-thumb,
.bdgv-seeking .bdgv-seek-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.bdgv-seek:focus-visible .bdgv-seek-track {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.6);
}

/* Time readout */
.bdgv-time {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
  padding: 0 0.35rem;
  white-space: nowrap;
}

/* Playback speed */
.bdgv-rate-wrap {
  position: relative;
  flex: 0 0 auto;
}

.bdgv-rate-btn {
  width: auto;
  min-width: 2.4rem;
  padding: 0 0.4rem;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bdgv-rate-btn.is-off-normal {
  color: #fff;
  background: rgba(99, 102, 241, 0.85);
}

.bdgv-rate-menu {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.3rem;
  border-radius: 0.6rem;
  background: #111827;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.bdgv-rate-menu[hidden] {
  display: none;
}

.bdgv-rate-item {
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.75rem;
  border-radius: 0.4rem;
  cursor: pointer;
  white-space: nowrap;
}

.bdgv-rate-item:hover {
  background: rgba(148, 163, 184, 0.2);
}

.bdgv-rate-item.is-active {
  background: var(--bdgv-accent);
  color: #fff;
}

/* Volume */
.bdgv-vol-wrap {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.bdgv-vol {
  width: 0;
  height: 2.15rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  opacity: 0;
  transition: width 0.16s ease, opacity 0.16s ease;
}

.bdgv-vol-wrap:hover .bdgv-vol,
.bdgv-vol:focus-visible {
  width: 4rem;
  opacity: 1;
}

.bdgv-vol-track {
  position: relative;
  width: 100%;
  height: 4px;
  margin: 0 0.3rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
}

.bdgv-vol-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 999px;
  background: #e2e8f0;
}

/* Resume prompt */
.bdgv-resume {
  position: absolute;
  bottom: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.7rem;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  font-size: 0.78rem;
  color: #e2e8f0;
}

.bdgv-resume[hidden] {
  display: none;
}

.bdgv-resume button {
  border: none;
  cursor: pointer;
  border-radius: 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
}

.bdgv-resume-go {
  background: var(--bdgv-accent);
  color: #fff;
}

.bdgv-resume-restart {
  background: rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
}

/* Error overlay */
.bdgv-error {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  text-align: center;
  background: rgba(11, 16, 32, 0.94);
  color: #e2e8f0;
  line-height: 1.8;
}

.bdgv-error[hidden] {
  display: none;
}

.bdgv-error-msg {
  margin: 0;
  font-size: 0.85rem;
  max-width: 34rem;
}

.bdgv-retry {
  border: none;
  cursor: pointer;
  border-radius: 0.5rem;
  padding: 0.45rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bdgv-accent);
  color: #fff;
}

.bdgv-player.has-error .bdgv-bigplay {
  display: none;
}

@media (max-width: 520px) {
  .bdgv-controls {
    gap: 0.15rem;
    padding: 0.4rem;
  }
  .bdgv-btn {
    width: 1.9rem;
    height: 1.9rem;
  }
  .bdgv-time {
    font-size: 0.68rem;
    padding: 0 0.2rem;
  }
  /* No hover on touch: keep the slider out of the way, mute button still works. */
  .bdgv-vol {
    display: none;
  }
  .bdgv-rate-btn {
    min-width: 2.1rem;
    font-size: 0.7rem;
  }
  .bdgv-resume {
    inset-inline: 0.5rem;
    bottom: 0.5rem;
    font-size: 0.72rem;
    justify-content: center;
    flex-wrap: wrap;
  }
}
