/* ==========================================================================
   Stepify — Custom Video Player
   Segmented timeline with per-step chapters, custom captions overlay.
   ========================================================================== */

/* ---- Player container ---- */
.stepify-player {
  position: relative; width: 100%; background: #000;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  border: 4px solid white; aspect-ratio: 8 / 5;
}
[data-theme="dark"] .stepify-player { border-color: #334155; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .stepify-player { border-color: #334155; }
}
.stepify-player video {
  width: 100%; height: 100%; display: block; object-fit: contain;
  background: #000;
}

/* ---- Play overlay (centre button) ---- */
.player-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; z-index: 2;
  transition: opacity 0.3s ease;
}
.player-overlay .play-icon {
  width: 72px; height: 72px; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}
.player-overlay.hidden { opacity: 0; pointer-events: none; }
.player-overlay:focus { outline: 2px solid #0891B2; outline-offset: -2px; }

/* ---- Controls bar ---- */
.player-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
  padding: 2rem 0.75rem 0.5rem; display: flex; align-items: center; gap: 0.5rem;
  opacity: 0; transition: opacity 0.3s;
}
.stepify-player:hover .player-controls,
.stepify-player:focus-within .player-controls,
.stepify-player.paused .player-controls { opacity: 1; }

/* ---- Control buttons ---- */
.player-controls button {
  background: none; border: none; color: #fff; cursor: pointer;
  padding: 0.35rem; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.player-controls button:hover { background: rgba(255,255,255,0.15); }
.player-controls button:focus-visible { outline: 2px solid #0891B2; outline-offset: 2px; }
.player-controls button svg { width: 20px; height: 20px; }

/* ---- Play/pause ---- */
.ctl-play svg { width: 22px; height: 22px; }

/* ---- Progress bar ---- */
.ctl-progress {
  flex: 1; display: flex; align-items: center; gap: 0.5rem; min-width: 0;
}
.progress-track {
  position: relative; flex: 1; height: 6px;
  background: rgba(0,0,0,0.3); border-radius: 4px; cursor: pointer;
}
.progress-track:hover { height: 8px; }
.progress-scrubber {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3); cursor: grab;
  opacity: 0; transition: opacity 0.15s; z-index: 3;
}
.progress-track:hover .progress-scrubber,
.stepify-player.scrubbing .progress-scrubber { opacity: 1; }
.stepify-player.scrubbing .progress-scrubber { cursor: grabbing; }

/* ---- Segmented timeline (one segment per step) ---- */
.step-segments {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; gap: 3px; z-index: 1;
}
.step-segment {
  position: relative; height: 100%; flex-shrink: 0; flex-grow: 0;
  background: rgba(255,255,255,0.25); border-radius: 2px;
  cursor: pointer; overflow: hidden;
  transition: background 0.2s;
}
.step-segment:hover { background: rgba(34,211,238,0.4); }
.step-segment.active { background: rgba(8,145,178,0.35); }
.step-segment:focus { outline: none; }
.step-segment:focus-visible {
  outline: 2px solid #0891B2; outline-offset: 1px; z-index: 2;
}
.segment-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: #0891B2; border-radius: 2px;
  pointer-events: none; width: 0;
}
.segment-tooltip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.9); color: #fff; padding: 6px 10px; border-radius: 4px;
  font-size: 13px; font-weight: 500; font-family: var(--font-body); white-space: nowrap;
  opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 10;
}
.step-segment:hover .segment-tooltip,
.step-segment:focus-visible .segment-tooltip { opacity: 1; }

/* ---- Custom captions overlay ---- */
.custom-captions {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff;
  font-size: 18px; font-weight: 500; line-height: 1.4;
  padding: 8px 16px; border-radius: 6px;
  max-width: 80%; text-align: center;
  pointer-events: none; z-index: 3;
  opacity: 0; transition: opacity 0.15s;
}
.custom-captions:empty { display: none; }
.stepify-player:fullscreen .custom-captions {
  bottom: 100px; font-size: 24px; padding: 12px 20px;
}

/* ---- Time display ---- */
.ctl-time {
  color: #fff; font-size: 0.75rem; font-weight: 500;
  font-family: var(--font-body); white-space: nowrap; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ---- Volume ---- */
.ctl-vol-slider {
  width: 60px; height: 4px; background: rgba(255,255,255,0.25);
  border-radius: 2px; cursor: pointer; position: relative; flex-shrink: 0;
}
.vol-track { position: relative; width: 100%; height: 100%; }
.vol-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: #fff; border-radius: 2px;
  width: 100%;
}

/* ---- CC button ---- */
.ctl-cc {
  font-family: var(--font-body); font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.02em; line-height: 1; padding: 0.2rem 0.4rem !important;
  border: 2px solid rgba(255,255,255,0.5) !important; border-radius: 3px;
}
.ctl-cc.active {
  background: #0891B2 !important; border-color: #0891B2 !important;
}

/* ---- Fullscreen ---- */
.stepify-player:fullscreen,
.stepify-player:-webkit-full-screen {
  max-width: none; border-radius: 0; border: none; aspect-ratio: auto;
}
.stepify-player:fullscreen video { object-fit: contain; }

/* ---- Responsive: mobile ---- */
@media (max-width: 640px) {
  .stepify-player { border-width: 2px; border-radius: 8px; }
  .player-controls { padding: 1.5rem 0.5rem 0.4rem; gap: 0.35rem; }
  .player-controls button svg { width: 18px; height: 18px; }
  .ctl-vol-slider { display: none; }
  .ctl-time { font-size: 0.65rem; }
  .player-overlay .play-icon { width: 56px; height: 56px; }
  .progress-track { height: 10px; }
  .step-segments { gap: 4px; }
  .segment-tooltip { font-size: 12px; padding: 5px 8px; }
  .custom-captions { bottom: 60px; font-size: 14px; padding: 6px 12px; max-width: 90%; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .player-overlay,
  .player-controls,
  .progress-scrubber,
  .step-segment,
  .segment-tooltip,
  .custom-captions { transition: none; }
}
