/* Styled-caption overlay — only active when a captionstyle other than 'plain'
   is selected. Native Video.js caption rendering (.vjs-text-track-display) is
   suppressed while this is showing, and restored untouched when switched back
   to 'plain'. System font stacks only — no webfont loading. */

.sch-caption-style-overlay {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  max-width: 90%;
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  z-index: 10;
  /* Tweaked live via the caption settings panel (settings-panel.js), which
     sets these as inline custom properties on this element. */
  font-size: calc(28px * var(--sch-cs-scale, 1));
}

/* ── Karaoke — word-by-word highlight sweep ─────────────────────────────── */
.sch-caption-style-karaoke {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-karaoke .sch-cs-word {
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.15s ease;
}
.sch-caption-style-karaoke .sch-cs-word.spoken {
  color: #fff;
}
.sch-caption-style-karaoke .sch-cs-word.active {
  display: inline-block;
  color: var(--sch-cs-karaoke-accent, #ff8000);
  transform: scale(1.08);
  filter: saturate(var(--sch-cs-intensity, 1)) brightness(var(--sch-cs-intensity, 1));
  transition:
    color 0.1s ease,
    transform 0.1s ease;
}

/* ── Neon — glowing whole-cue treatment with a slow pulse ───────────────── */
.sch-caption-style-neon .sch-cs-neon-text {
  display: inline-block;
  font-family: 'Arial Black', system-ui, sans-serif;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow:
    0 0 calc(4px * var(--sch-cs-intensity, 1)) var(--sch-cs-neon-glow, #ff8000),
    0 0 calc(10px * var(--sch-cs-intensity, 1)) var(--sch-cs-neon-glow, #ff8000),
    0 0 calc(20px * var(--sch-cs-intensity, 1))
      color-mix(in srgb, var(--sch-cs-neon-glow, #ff8000) 60%, transparent),
    0 0 calc(30px * var(--sch-cs-intensity, 1))
      color-mix(in srgb, var(--sch-cs-neon-glow, #ff8000) 40%, transparent);
  animation: sch-neon-pulse 1.6s ease-in-out infinite;
}

@keyframes sch-neon-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.75;
  }
}

/* ── Bold Pop — each word pops in bigger, then settles ──────────────────── */
.sch-caption-style-bold-pop {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-bold-pop .sch-cs-pop-word {
  display: inline-block;
  color: #fff;
  opacity: 0;
  transform: scale(0.5);
}
.sch-caption-style-bold-pop .sch-cs-pop-word.revealed {
  animation: sch-bold-pop-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sch-bold-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  60% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Minimal Fade — understated whole-cue soft fade-in ──────────────────── */
.sch-caption-style-minimal-fade .sch-cs-fade-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 400;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  animation: sch-fade-in 0.3s ease forwards;
}

@keyframes sch-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Typewriter — character-by-character reveal with a blinking cursor ──── */
.sch-caption-style-typewriter {
  font-family: 'Courier New', 'Consolas', monospace;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-typewriter .sch-cs-tw-cursor {
  display: inline-block;
  color: #ff8000;
  animation: sch-tw-blink 0.8s steps(1) infinite;
}

@keyframes sch-tw-blink {
  50% {
    opacity: 0;
  }
}

/* ── Highlighter Sweep — marker-pen bar under each word, leaves a mark ──── */
.sch-caption-style-highlighter {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-highlighter .sch-cs-hl-word {
  padding: 0 2px;
  border-radius: 3px;
  transition: background-color 0.15s ease;
}
.sch-caption-style-highlighter .sch-cs-hl-word.marked {
  background-color: color-mix(
    in srgb,
    var(--sch-cs-highlighter-markColor, #ff8000) calc(35% * var(--sch-cs-intensity, 1)),
    transparent
  );
}
.sch-caption-style-highlighter .sch-cs-hl-word.active {
  background-color: color-mix(
    in srgb,
    var(--sch-cs-highlighter-markColor, #ff8000) calc(85% * var(--sch-cs-intensity, 1)),
    transparent
  );
}

/* ── Bounce — each word drops in and bounces once ───────────────────────── */
.sch-caption-style-bounce {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-bounce .sch-cs-bounce-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(-30px);
}
.sch-caption-style-bounce .sch-cs-bounce-word.revealed {
  animation: sch-bounce-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sch-bounce-in {
  0% {
    opacity: 0;
    transform: translateY(-30px);
  }
  60% {
    opacity: 1;
    transform: translateY(6px);
  }
  80% {
    transform: translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Wave — a ripple travels across the phrase as it's spoken ───────────── */
.sch-caption-style-wave {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-wave .sch-cs-wave-word {
  display: inline-block;
  color: rgba(255, 255, 255, 0.6);
  transition:
    transform 0.15s ease,
    color 0.15s ease;
}
.sch-caption-style-wave .sch-cs-wave-word.spoken {
  color: #fff;
}

/* ── Slide-Up — whole cue slides up into position, Reels/TikTok-style ───── */
.sch-caption-style-slide-up .sch-cs-slide-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  animation: sch-slide-up-in 0.25s ease-out forwards;
}

@keyframes sch-slide-up-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Bubble — cue text on a rounded colour pill, Stories-style ──────────── */
.sch-caption-style-bubble .sch-cs-bubble-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  color: var(--sch-cs-bubble-textColor, #fff);
  background: color-mix(
    in srgb,
    var(--sch-cs-bubble-background, #ff8000) calc(85% * var(--sch-cs-intensity, 1)),
    transparent
  );
  padding: 6px 16px;
  border-radius: 999px;
  animation: sch-bubble-pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sch-bubble-pop {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── VHS — retro chromatic-aberration text with an occasional flicker ───── */
.sch-caption-style-vhs .sch-cs-vhs-text {
  display: inline-block;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  text-shadow:
    calc(-2px * var(--sch-cs-intensity, 1)) 0 rgba(255, 0, 60, 0.7),
    calc(2px * var(--sch-cs-intensity, 1)) 0 rgba(0, 220, 255, 0.7);
  animation: sch-vhs-flicker 2.5s steps(1) infinite;
}

@keyframes sch-vhs-flicker {
  0%,
  92%,
  100% {
    opacity: 1;
  }
  93% {
    opacity: 0.7;
  }
  94% {
    opacity: 1;
  }
}

/* ── Outline Pop — stroked text that fills solid on entrance ────────────── */
.sch-caption-style-outline-pop .sch-cs-outline-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 900;
  -webkit-text-stroke: calc(1.5px * var(--sch-cs-intensity, 1)) #ff8000;
  color: transparent;
  animation: sch-outline-fill 0.3s ease-out 0.15s forwards;
}

@keyframes sch-outline-fill {
  to {
    color: #fff;
  }
}

/* ── Caption styling hub — pick a style template, then tweak it ─────────── */
.vjs-caption-settings-button {
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 30px !important;
  text-align: center !important;
  color: #fff !important;
  cursor: pointer !important;
}
.vjs-caption-settings-button:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}

.sch-caption-settings-panel {
  position: absolute;
  bottom: 50px;
  right: 20px;
  width: 240px;
  background: rgba(50, 50, 50, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 15px;
  border-radius: 6px;
  display: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  z-index: 2000;
}
.sch-caption-settings-panel h4 {
  margin: 0 0 10px;
  font-size: 14px;
}
.sch-caption-settings-panel hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 14px 0;
}

.sch-cs-style-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sch-cs-style-option {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.sch-cs-style-option:hover {
  background: rgba(255, 255, 255, 0.16);
}
.sch-cs-style-option.active {
  background: rgba(255, 128, 0, 0.2);
  border-color: #ff8000;
  color: #ff8000;
  font-weight: 700;
}

.sch-caption-settings-panel label {
  display: block;
  margin-bottom: 12px;
}
.sch-caption-settings-panel label:last-child {
  margin-bottom: 0;
}
.sch-caption-settings-panel .sch-cs-setting-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sch-caption-settings-panel .sch-cs-setting-label span:last-child {
  color: #ff8000;
}
.sch-caption-settings-panel input[type='range'] {
  width: 100%;
}
.sch-cs-hub-appearance-disabled input[type='range'] {
  opacity: 0.4;
  cursor: not-allowed;
}

.sch-cs-style-settings {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.sch-cs-style-settings h4 {
  margin: 0 0 10px;
}
.sch-caption-settings-panel input[type='color'] {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

/* ── Glitch — brief RGB-split jitter as each word becomes active ────────── */
.sch-caption-style-glitch {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-glitch .sch-cs-glitch-word {
  display: inline-block;
  color: rgba(255, 255, 255, 0.4);
}
.sch-caption-style-glitch .sch-cs-glitch-word.spoken {
  color: #fff;
}
.sch-caption-style-glitch .sch-cs-glitch-word.glitching {
  color: #fff;
  animation: sch-glitch-jitter 0.12s steps(2) 2;
  text-shadow:
    calc(-2px * var(--sch-cs-intensity, 1)) 0 rgba(255, 0, 60, 0.8),
    calc(2px * var(--sch-cs-intensity, 1)) 0 rgba(0, 220, 255, 0.8);
}

@keyframes sch-glitch-jitter {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-2px, 1px);
  }
  50% {
    transform: translate(2px, -1px);
  }
  75% {
    transform: translate(-1px, 0);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* ── Underline Sweep — underline draws itself beneath the active word ──── */
.sch-caption-style-underline-sweep {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-underline-sweep .sch-cs-underline-word {
  position: relative;
  display: inline-block;
}
.sch-caption-style-underline-sweep .sch-cs-underline-word::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -3px;
  height: 3px;
  width: calc(100% * var(--sch-underline-progress, 0));
  background: var(--sch-cs-underline-sweep-lineColor, #ff8000);
  transition: width 0.05s linear;
}

/* ── Letter Snap — wide letter-spacing snaps tight when active ──────────── */
.sch-caption-style-snap {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-snap .sch-cs-snap-word {
  display: inline-block;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.3em;
  transition:
    letter-spacing 0.18s ease,
    color 0.18s ease;
}
.sch-caption-style-snap .sch-cs-snap-word.active {
  color: #fff;
  letter-spacing: normal;
}

/* ── Colour Cycle — active word flashes through accent colours, then white ─ */
.sch-caption-style-color-cycle {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.sch-caption-style-color-cycle .sch-cs-cycle-word {
  display: inline-block;
  color: rgba(255, 255, 255, 0.4);
}
.sch-caption-style-color-cycle .sch-cs-cycle-word.active {
  animation: sch-color-cycle 0.4s steps(1) forwards;
}
.sch-caption-style-color-cycle .sch-cs-cycle-word.spoken {
  color: var(--sch-cs-color-cycle-finalColor, #fff);
}

@keyframes sch-color-cycle {
  0% {
    color: #ff8000;
  }
  33% {
    color: #ffcc00;
  }
  66% {
    color: #00ccff;
  }
  100% {
    color: var(--sch-cs-color-cycle-finalColor, #fff);
  }
}

/* ── Chalkboard — handwriting font, chalky shadow, slight rotation ──────── */
.sch-caption-style-chalkboard .sch-cs-chalk-text {
  display: inline-block;
  font-family: 'Segoe Print', 'Bradley Hand', cursive, system-ui, sans-serif;
  font-weight: 700;
  color: var(--sch-cs-chalkboard-textColor, #fff);
  text-shadow:
    1px 1px 0 rgba(255, 255, 255, 0.15),
    -1px -1px 0 rgba(255, 255, 255, 0.1);
  animation: sch-chalk-in 0.25s ease-out forwards;
}

@keyframes sch-chalk-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Glass — frosted-glass background pill (glassmorphism) ──────────────── */
.sch-caption-style-glass .sch-cs-glass-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 16px;
  border-radius: 12px;
  animation: sch-glass-in 0.25s ease-out forwards;
}

@keyframes sch-glass-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Aurora Gradient — animated rainbow fill sweeping across the text ───── */
.sch-caption-style-aurora .sch-cs-aurora-text {
  display: inline-block;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-weight: 800;
  background: linear-gradient(90deg, #ff8000, #ff3d81, #00ccff, #7cff6b, #ff8000);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  animation: sch-aurora-shift 3s linear infinite;
}

@keyframes sch-aurora-shift {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 300% 50%;
  }
}

/* ── Comic Pop — bold comic lettering on a halftone pill, starburst entry ─ */
.sch-caption-style-comic-pop .sch-cs-comic-text {
  display: inline-block;
  font-family: Impact, 'Arial Black', system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  -webkit-text-stroke: 1px #000;
  background-color: color-mix(
    in srgb,
    var(--sch-cs-comic-pop-background, #ff8000) calc(90% * var(--sch-cs-intensity, 1)),
    transparent
  );
  background-image: radial-gradient(rgba(255, 255, 255, 0.25) 15%, transparent 16%);
  background-size: 8px 8px;
  padding: 6px 18px;
  border-radius: 8px;
  border: 2px solid #000;
  animation: sch-comic-pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sch-comic-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.6) rotate(-3deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.1) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}
