/**
 * Kundawell HLS Video Player & Practice Timer Styles
 */

/* ==========================================================================
   Video Container
   ========================================================================== */

.kw-video-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  /* 16:9 aspect ratio */
  background-color: #000;
  overflow: hidden;
  border-radius: 0 8px 8px 8px;
}

/* ==========================================================================
   Video Wrapper (for standard player)
   ========================================================================== */

.kw-video-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.kw-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.kw-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}

/* Hide overlay when controls are visible */
.kw-video-container.kw-controls-visible .kw-video-overlay {
  display: none;
}

/* ==========================================================================
   Big Play Button
   ========================================================================== */

.kw-big-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  padding: 0;
}

.kw-big-play-btn svg {
  width: 64px;
  height: 64px;
}

.kw-big-play-btn svg circle {
  fill: #6153cc;
  stroke: none;
}

.kw-big-play-btn svg path {
  fill: white;
}

.kw-big-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
  filter: brightness(1.1);
}

.kw-big-play-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.kw-video-container.kw-playing .kw-big-play-btn {
  display: none;
}

/* ==========================================================================
   Video Controls
   ========================================================================== */

.kw-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 40px 16px 16px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  /* Allow clicks to pass through to video */
}

.kw-video-container:hover .kw-video-controls,
.kw-video-container.kw-controls-visible .kw-video-controls {
  opacity: 1;
}

/* Progress Bar */
.kw-progress-container {
  margin-bottom: 12px;
  pointer-events: auto;
  /* Enable clicks on progress bar */
}

.kw-progress-bar {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: height 0.2s;
  z-index: 10;
  /* Keep above subtitles */
}

.kw-progress-bar:hover {
  height: 8px;
}

.kw-progress-filled {
  height: 100%;
  background-color: #fff;
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* Controls Row */
.kw-controls-row {
  display: flex;
  align-items: center;
  gap: 4px;
  /* Tighter spacing between buttons */
  color: #fff;
  position: relative;
  z-index: 10;
  /* Keep above subtitles */
  pointer-events: auto;
}

.kw-control-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  border-radius: 4px;
  box-sizing: border-box;
  margin: 0;
  line-height: 1;
  overflow: hidden;
}

.kw-control-btn:hover {
  transform: scale(1.1);
  background-color: rgba(255, 255, 255, 0.1);
}

.kw-control-btn:active {
  transform: scale(0.95);
}

/* Time Display */
.kw-time-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.kw-time-separator {
  opacity: 0.7;
}

/* Spacer */
.kw-spacer {
  flex: 1;
}

/* Speed Button */
.kw-speed-btn {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 40px;
}

/* Make SVGs consistent and vertically centered across all controls */
.kw-control-btn svg {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
}

.kw-play-icon,
.kw-pause-icon,
.kw-volume-icon,
.kw-muted-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* These three icons are visually larger; reduce ~30% to match the others */
.kw-speed-btn svg,
.kw-lang-btn svg,
.kw-cc-btn svg,
.kw-quality-btn svg {
  width: 18px;
  height: 18px;
}


.kw-speed-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
  min-width: 100px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.kw-speed-option {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  color: #fff;
}

.kw-speed-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.kw-speed-option.kw-active-option {
  color: #6153cc;
  font-weight: 600;
  background-color: rgba(97, 83, 204, 0.1);
}

/* Quality Button */
.kw-quality-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.kw-quality-label {
  font-size: 13px;
  font-weight: 500;
  display: none;
}

.kw-quality-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
  min-width: 100px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.kw-quality-option {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  color: #fff;
}

.kw-quality-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Group for combined controls (icon + label/menu or icon + slider) */
.kw-control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  height: 40px;
}

/* Volume Group specific */
.kw-volume-group {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Slightly larger gap between mute button and slider */
}

/* Volume */
.kw-volume-slider {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
}

.kw-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.kw-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.kw-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.kw-volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   Locked State
   ========================================================================== */

.kw-video-locked {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.kw-video-locked-content {
  text-align: center;
  color: #fff;
  padding: 32px;
}

.kw-lock-icon {
  margin-bottom: 16px;
  opacity: 0.9;
}

.kw-locked-message {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 20px;
}

.kw-unlock-button {
  display: inline-block;
  background: #fff;
  color: #667eea;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kw-unlock-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Practice Timer Components
   ========================================================================== */

.kw-timer-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Practice video controls styling */
.kw-practice-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 4;
}

.kw-timer-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.kw-timer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #000;
  filter: blur(20px);
  /* Always blurred */
}

.kw-timer-canvas.kw-blur-out {
  filter: blur(0px);
  transition: filter 3s ease-in-out;
}

.kw-timer-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #000;
  transition: filter 3s ease-in-out;
}

/* Blur animations for video */
.kw-timer-video.kw-blur-in {
  filter: blur(20px);
}

/* ==========================================================================
   Timer Overlay
   ========================================================================== */

.kw-timer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex !important;
  /* Always flex, visibility handled by opacity */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
}

.kw-timer-overlay.kw-visible {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 1s ease;
}

/* Timer Setup Screen */
.kw-timer-setup {
  text-align: center;
  color: #fff;
  padding: 32px;
  max-width: 600px;
  width: 100%;
}

.kw-timer-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 32px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  color: #fff;
}



/* Timer Countdown Screen */
.kw-timer-countdown {
  text-align: center;
  color: #fff;
  animation: kwFadeIn 1s ease-out;
}

@keyframes kwFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kw-timer-display {
  margin-bottom: 32px;
}

.kw-timer-time {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.kw-timer-label {
  font-size: 18px;
  font-weight: 500;
  opacity: 0.9;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.kw-timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.kw-timer-pause-btn,
.kw-timer-stop-btn {
  background: #6153cc;
  border: none;
  color: #fff;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(97, 83, 204, 0.4);
}

.kw-timer-pause-btn:hover,
.kw-timer-stop-btn:hover {
  background: #7266d4;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(97, 83, 204, 0.5);
}

.kw-timer-pause-btn:active,
.kw-timer-stop-btn:active {
  transform: scale(0.95);
}

/* Play button for autoplay prevention */
.kw-timer-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s;
  padding: 0;
}

.kw-timer-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.kw-timer-play-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

/* Circular Dial Timer Selector */
.kw-dial-container {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 0 auto 32px;
  user-select: none;
  cursor: grab;
  touch-action: none;
}

.kw-dial-container:active {
  cursor: grabbing;
}

.kw-dial-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  /* Let clicks pass through to container */
}

.kw-dial-ticks {
  pointer-events: none;
}

.kw-dial-arc {
  filter: drop-shadow(0 0 4px rgba(97, 83, 204, 0.6));
  pointer-events: none;
}

.kw-dial-knob-group {
  transition: transform 0.1s ease-out;
  pointer-events: none;
}

.kw-dial-knob {
  fill: #fff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  cursor: grab;
  pointer-events: auto;
  /* Knob itself is interactive */
}

.kw-dial-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.kw-dial-icon {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 8px;
}

.kw-dial-value-wrapper {
  margin-bottom: 4px;
}

.kw-selected-time {
  font-size: 64px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kw-timer-unit {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Hide old elements */
.kw-timer-grid,
.kw-timer-slider-input,
.kw-timer-circle-container,
.kw-timer-display-large {
  display: none !important;
}

.kw-timer-recommended {
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 20px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.kw-timer-start-btn {
  background: rgba(97, 83, 204, 0.95);
  border: none;
  color: #fff;
  padding: 16px 48px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(97, 83, 204, 0.4);
  display: block;
  margin: 0 auto;
}

.kw-timer-start-btn:hover {
  background: rgba(97, 83, 204, 1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(97, 83, 204, 0.5);
}

.kw-timer-start-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  .kw-timer-title {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .kw-timer-title {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .kw-dial-container {
    width: 250px;
    height: 250px;
    margin-bottom: 20px;
  }

  .kw-selected-time {
    font-size: 48px;
  }

  .kw-timer-unit {
    font-size: 14px;
    letter-spacing: 0.5px;
  }

  .kw-timer-recommended {
    font-size: 12px;
  }

  .kw-timer-start-btn {
    padding: 14px 40px;
    font-size: 16px;
  }

  .kw-timer-time {
    font-size: 56px;
  }

  .kw-timer-label {
    font-size: 16px;
  }

  .kw-timer-pause-btn,
  .kw-timer-stop-btn {
    width: 56px;
    height: 56px;
  }

  .kw-volume-slider {
    width: 60px;
  }

  .kw-time-display {
    font-size: 12px;
  }

  .kw-quality-label {
    display: none;
    /* Hide quality label on mobile, keep icon */
  }
}

@media (max-width: 480px) {
  .kw-dial-container {
    width: 150px;
    height: 150px;
    margin-bottom: -10px;
  }

  .kw-dial-value-wrapper {
    margin-bottom: 0;
    line-height: 1;
  }

  .kw-selected-time {
    font-size: 32px;
  }

  .kw-timer-unit {
    font-size: 10px;
  }

  .kw-timer-setup {
    padding: 8px;
  }

  .kw-timer-title {
    font-size: 16px;
  }

  .kw-timer-start-btn {
    padding: 6px 16px;
    font-size: 11px;
    width: auto;
    min-width: 100px;
  }

  .kw-timer-time {
    font-size: 40px;
    margin-bottom: 8px;
  }

  .kw-timer-display {
    margin-bottom: 20px;
  }

  .kw-timer-pause-btn,
  .kw-timer-stop-btn {
    width: 48px;
    height: 48px;
  }

  .kw-timer-pause-btn svg,
  .kw-timer-stop-btn svg {
    width: 24px;
    height: 24px;
  }

  .kw-controls-row {
    gap: 8px;
  }

  .kw-volume-slider {
    display: none;
    /* Hide volume slider on very small screens */
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .kw-video-container {
    display: none;
  }
}

/* ==========================================================================
   Custom Subtitle Display (Replaces Native Cues)
   ========================================================================== */

.kw-subtitle-display {
  position: absolute;
  bottom: 80px;
  /* Proper spacing from bottom - always visible above controls */
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  /* Allow clicking through to video */
  z-index: 4;
  /* Above controls (controls are z-index: 3) */
  width: 80%;
  max-width: 800px;
  display: none;
  /* Hidden by default, shown when subtitle track is active */
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 50px;
  /* Prevent jumpiness */
}

.kw-subtitle-text {
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 18px;
  line-height: 1.4;
  padding: 6px 14px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
  /* Stack lines if needed */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-family: sans-serif;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.kw-subtitle-text.kw-visible {
  opacity: 1;
}

/* Hide native cues for all video elements */
.kw-video::cue,
.kw-timer-video::cue {
  visibility: hidden !important;
  color: transparent !important;
  background: transparent !important;
  display: none !important;
}

.kw-video::-webkit-media-text-track-container,
.kw-timer-video::-webkit-media-text-track-container {
  display: none !important;
  visibility: hidden !important;
}

.kw-video::-webkit-media-text-track-display,
.kw-timer-video::-webkit-media-text-track-display {
  display: none !important;
  visibility: hidden !important;
}

.kw-video::before,
.kw-timer-video::before {
  content: none !important;
}

/* Force hide all video text tracks */
video::cue {
  visibility: hidden !important;
  display: none !important;
}

video::-webkit-media-text-track-container {
  display: none !important;
}

video::-webkit-media-text-track-display {
  display: none !important;
}

/* ==========================================================================
   CC/Subtitle Controls
   ========================================================================== */

.kw-cc-btn,
.kw-lang-btn {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 32px;
  /* Same as height for consistent sizing */
}

.kw-cc-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
  min-width: 100px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.kw-cc-option {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  color: #fff;
  white-space: nowrap;
}

.kw-cc-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.kw-cc-option.kw-active-option {
  color: #6153cc;
  font-weight: 600;
  background-color: rgba(97, 83, 204, 0.1);
}

/* Language Menu - Same styles as CC menu */
.kw-lang-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
  min-width: 120px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.kw-lang-option {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  color: #fff;
  white-space: nowrap;
}

.kw-lang-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.kw-lang-option.kw-active-option {
  color: #6153cc;
  font-weight: 600;
  background-color: rgba(97, 83, 204, 0.1);
}

.kw-quality-option.kw-active-option {
  color: #6153cc;
  font-weight: 600;
  background-color: rgba(97, 83, 204, 0.1);
}

@media (max-width: 600px) {
  .kw-video-controls {
    padding: 20px 10px 10px;
  }

  .kw-control-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .kw-control-btn svg {
    width: 20px;
    height: 20px;
  }

  .kw-speed-btn svg,
  .kw-lang-btn svg,
  .kw-cc-btn svg,
  .kw-quality-btn svg {
    width: 16px;
    height: 16px;
  }

  .kw-big-play-btn svg {
    width: 48px;
    height: 48px;
  }

  /* Hide volume slider on mobile to save space, mute button is enough */
  .kw-volume-slider {
    display: none;
  }

  .kw-time-display {
    font-size: 11px;
    gap: 2px;
    margin-left: 5px;
  }

  .kw-duration,
  .kw-time-separator {
    display: none;
  }

  /* Ensure menus don't overflow screen height or width */
  .kw-speed-menu,
  .kw-quality-menu,
  .kw-cc-menu,
  .kw-lang-menu {
    max-height: 130px;
    overflow-y: auto;
    bottom: 40px;
    right: 0;
  }

  .kw-speed-menu {
    min-width: 80px;
  }
}