/**
 * Video Player Styles - Hearth Theme
 *
 * Based on the CourseFuture shared video player (controls, container)
 * combined with the proven IPV scene-based template CSS.
 *
 * Architecture:
 * - .video-player: outer container with controls (rendered by VideoPlayer class)
 * - .video-scene: each scene with layered rendering:
 *     .scene-background (image with Ken Burns)
 *     .scene-overlay (semi-transparent gradient)
 *     .scene-content (heading + bullets)
 * - Template variations via data-template attribute on .video-scene
 */

/* ============================================================================
   Animations
   ============================================================================ */

@keyframes videofadein {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes ken-burns {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

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

@keyframes bullet-enter {
  0% { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}

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

.video-player {
  position: relative;
  background: linear-gradient(135deg, #1a0f0a 0%, #2c1a12 100%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.video-player:fullscreen {
  border-radius: 0;
}

.video-player__display {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1a0f0a;
  overflow: hidden;
  cursor: pointer;
}

/* ============================================================================
   Scene Structure (IPV-style layered rendering)
   ============================================================================ */

.video-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scene-background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.video-scene.active .scene-background {
  animation: ken-burns 15s ease-out forwards;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  /* No full-scene overlay - let images show clearly */
  background: none;
}

.scene-content {
  width: 50%;
  padding: 1.5rem 2rem;
  padding-bottom: 5rem;
  color: #ffffff;
  overflow: hidden;
  /* Localized backdrop behind text only - images stay fully visible */
  background: rgba(30, 15, 10, 0.75);
  border-radius: 12px;
  margin: 1rem;
  backdrop-filter: blur(4px);
}

.scene-content ul,
.scene-content li {
  background: none !important;
}

/* --- Scene Heading --- */
.scene-heading,
.video-scene .scene-heading,
h2.scene-heading {
  font-family: 'Merriweather', Georgia, serif;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  color: #E8C9A0 !important;
  max-width: 100%;
}

/* Accent line under heading */
.scene-heading::after {
  content: '';
  display: block;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, #D7A86E, #B8894A);
  margin-top: 0.75rem;
  border-radius: 2px;
}

/* --- Scene Bullets --- */
.scene-bullets,
ul.scene-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 100%;
}

.scene-bullets li {
  font-family: 'Open Sans', system-ui, sans-serif;
  font-size: clamp(0.75rem, 1.2vw, 0.9rem);
  padding: 0.4rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: #ffffff !important;
  line-height: 1.4;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.scene-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: #D7A86E;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(215, 168, 110, 0.6);
}

/* Staggered animation for bullets */
.video-scene.active .scene-bullets li {
  animation: bullet-enter 0.5s ease-out forwards;
}
.video-scene.active .scene-bullets li:nth-child(1) { animation-delay: 0.2s; opacity: 0; }
.video-scene.active .scene-bullets li:nth-child(2) { animation-delay: 0.35s; opacity: 0; }
.video-scene.active .scene-bullets li:nth-child(3) { animation-delay: 0.5s; opacity: 0; }
.video-scene.active .scene-bullets li:nth-child(4) { animation-delay: 0.65s; opacity: 0; }
.video-scene.active .scene-bullets li:nth-child(5) { animation-delay: 0.8s; opacity: 0; }

/* ============================================================================
   Template: Intro
   ============================================================================ */

.video-scene[data-template="intro"] .scene-overlay {
  align-items: center;
  justify-content: center;
  background: none;
}

.video-scene[data-template="intro"] .scene-content {
  text-align: center;
  width: auto;
  max-width: 80%;
  padding: 3rem;
}

.video-scene[data-template="intro"] .scene-heading {
  font-size: clamp(2rem, 5vw, 3rem);
  max-width: 100%;
  color: #E8C9A0 !important;
}

.video-scene[data-template="intro"] .scene-heading::after {
  margin: 1rem auto 0;
  width: 120px;
}

/* ============================================================================
   Template: Split Left (content on RIGHT, image visible on LEFT)
   ============================================================================ */

.video-scene[data-template="split-left"] .scene-overlay,
.video-scene.template-split-left .scene-overlay {
  align-items: stretch;
  justify-content: flex-end;
  background: none;
}

.video-scene[data-template="split-left"] .scene-content,
.video-scene.template-split-left .scene-content {
  width: 45%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 2rem;
  padding-bottom: 5rem;
}

/* ============================================================================
   Template: Split Right (content on LEFT, image visible on RIGHT)
   ============================================================================ */

.video-scene[data-template="split-right"] .scene-overlay,
.video-scene.template-split-right .scene-overlay {
  align-items: stretch;
  justify-content: flex-start;
  background: none;
}

.video-scene[data-template="split-right"] .scene-content,
.video-scene.template-split-right .scene-content {
  width: 45%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 2rem;
  padding-bottom: 5rem;
}

/* ============================================================================
   Template: Diagonal / Diagonal-Badge
   ============================================================================ */

.video-scene[data-template="diagonal"] .scene-overlay,
.video-scene[data-template="diagonal-badge"] .scene-overlay,
.video-scene.template-diagonal .scene-overlay {
  align-items: center;
  background: none;
}

.video-scene[data-template="diagonal"] .scene-content,
.video-scene[data-template="diagonal-badge"] .scene-content,
.video-scene.template-diagonal .scene-content {
  width: 48%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 2rem;
  padding-bottom: 5rem;
}

/* ============================================================================
   Template: Quote
   ============================================================================ */

.video-scene[data-template="quote"] .scene-overlay,
.video-scene[data-template="quote-floating"] .scene-overlay {
  align-items: center;
  justify-content: center;
  background: none;
}

.video-scene[data-template="quote"] .scene-content,
.video-scene[data-template="quote-floating"] .scene-content {
  width: 85%;
  max-width: 800px;
  text-align: center;
  padding: 2.5rem;
  background: rgba(30, 15, 10, 0.8);
  border: 1px solid rgba(215, 168, 110, 0.3);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

.video-scene[data-template="quote"] .scene-heading {
  max-width: 100%;
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  line-height: 1.4;
  font-style: italic;
}

.video-scene[data-template="quote"] .scene-heading::before {
  content: '\201C';
  position: absolute;
  top: -0.5em;
  left: -0.3em;
  font-size: 4rem;
  color: #D7A86E;
  opacity: 0.5;
  font-family: Georgia, serif;
  line-height: 1;
}

.video-scene[data-template="quote"] .scene-heading::after {
  margin: 1.5rem auto 0;
  width: 100px;
}

/* ============================================================================
   Template: Stats
   ============================================================================ */

.video-scene[data-template="stats"] .scene-overlay {
  align-items: stretch;
  background: none;
}

.video-scene[data-template="stats"] .scene-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 3rem 5rem;
}

.video-scene[data-template="stats"] .scene-heading {
  text-align: center;
  max-width: 100%;
  margin-bottom: 2rem;
}

.video-scene[data-template="stats"] .scene-heading::after {
  margin: 0.75rem auto 0;
}

/* ============================================================================
   Template: Final / Outro
   ============================================================================ */

.video-scene[data-template="final"] .scene-overlay {
  align-items: center;
  justify-content: center;
  background: none;
}

.video-scene[data-template="final"] .scene-content {
  text-align: center;
  width: auto;
  max-width: 80%;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-scene[data-template="final"] .scene-heading {
  max-width: 100%;
}

.video-scene[data-template="final"] .scene-heading::after {
  margin: 1rem auto 0;
}

/* ============================================================================
   Preview Overlay
   ============================================================================ */

.video-player__preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.6) 100%);
  z-index: 10;
}

.video-player__big-play {
  width: 80px;
  height: 80px;
  background: rgba(215, 168, 110, 0.9) !important;
  border: none !important;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(215, 168, 110, 0.4);
  padding: 0;
}

.video-player__big-play svg {
  width: 40px;
  height: 40px;
  fill: currentColor;
  color: #ffffff;
  display: inline-block;
  max-width: none;
}

.video-player__big-play:hover {
  transform: scale(1.1);
  background: #D7A86E;
  box-shadow: 0 6px 30px rgba(215, 168, 110, 0.6);
}

.video-player__preview-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.video-player__preview-duration {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* ============================================================================
   Loading & Error States
   ============================================================================ */

.video-player__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.7);
}

.video-player__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #ef4444;
  padding: 2rem;
  text-align: center;
}

/* ============================================================================
   Caption Overlay
   ============================================================================ */

.video-player__caption-overlay {
  position: absolute;
  bottom: 80px;
  left: 10%;
  right: 10%;
  text-align: center;
  z-index: 90;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.video-player__caption-overlay.hidden {
  opacity: 0;
}

.video-player__caption-text {
  display: inline-block;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 100%;
  font-family: 'Open Sans', system-ui, sans-serif;
  text-shadow: none;
}

/* ============================================================================
   Controls Bar
   ============================================================================ */

.video-player__controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  background: linear-gradient(to top, rgba(26, 15, 10, 0.98) 0%, transparent 100%);
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.video-player:not(:hover) .video-player__controls {
  opacity: 0.85;
}

.video-player:hover .video-player__controls {
  opacity: 1;
}

.video-player__controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ============================================================================
   Control Buttons
   ============================================================================ */

.video-player__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(215, 168, 110, 0.35) !important;
  border: 1px solid rgba(215, 168, 110, 0.5) !important;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.video-player__btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  color: #ffffff;
  flex-shrink: 0;
  /* Override base.css svg reset */
  display: inline-block;
  max-width: none;
}

.video-player__btn:hover {
  background: rgba(215, 168, 110, 0.5);
  border-color: rgba(215, 168, 110, 0.8);
  transform: scale(1.05);
}

.video-player__btn.active {
  background: rgba(215, 168, 110, 0.5);
  border-color: #D7A86E;
  color: #D7A86E;
}

.video-player__btn--play {
  width: 52px;
  height: 52px;
  background: #8D6E63 !important;
  border: 2px solid #D7A86E !important;
}

.video-player__btn--play:hover {
  background: #D7A86E;
  transform: scale(1.08);
}

.video-player__btn--play svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  color: #ffffff;
  display: inline-block;
  max-width: none;
}

/* ============================================================================
   Progress Bar
   ============================================================================ */

.video-player__progress {
  flex: 1;
  min-width: 100px;
}

.video-player__progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.video-player__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8D6E63, #D7A86E);
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* ============================================================================
   Time & Counter
   ============================================================================ */

.video-player__time {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: center;
}

.video-player__scene-counter {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
}

/* ============================================================================
   Volume Control
   ============================================================================ */

.video-player__volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Volume slider — MUST beat accessibility.css input:not():not() (specificity 0,2,1)
   Using triple-class selector (0,3,0) — same approach as podcast-player.css */
.video-player__controls .video-player__volume-control .video-player__volume-slider {
  display: inline-block;
  width: 0;
  height: 4px;
  min-height: 0;
  min-width: 0;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, width 0.2s;
}

.video-player__volume-control:hover .video-player__volume-slider,
.video-player__volume-slider:focus {
  opacity: 1;
  width: 70px;
}

.video-player__volume-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  border: none;
}

.video-player__volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #E8C9A0;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -4px;
  border: none;
}

.video-player__volume-slider::-moz-range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  border: none;
}

.video-player__volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #E8C9A0;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.video-player__volume-slider:focus-visible {
  outline: 2px solid #D7A86E;
  outline-offset: 4px;
}

/* ============================================================================
   Info Panel (Accessibility - Image Description)
   ============================================================================ */

.video-player__info-panel {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  border-top: 2px solid #D7A86E;
  padding: 12px 16px;
  z-index: 95;
  transition: opacity 0.3s ease;
}

.video-player__info-panel.hidden {
  display: none;
}

.video-player__info-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #D7A86E;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.video-player__info-label::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #D7A86E;
  border-radius: 50%;
}

.video-player__info-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
}

/* CC Button active state */
.video-player__btn--cc.active {
  background: rgba(215, 168, 110, 0.6);
  border-color: #D7A86E;
}

/* ============================================================================
   Responsive Design - Tablet
   ============================================================================ */

@media (max-width: 1024px) {
  .scene-heading {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    max-width: 90%;
  }

  .scene-bullets li {
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    padding: 0.4rem 0;
  }
}

/* ============================================================================
   Responsive Design - Mobile
   ============================================================================ */

@media (max-width: 768px) {
  /* Force all templates to show content at bottom on mobile */
  .scene-overlay {
    align-items: flex-end !important;
    justify-content: flex-start !important;
    background: none !important;
  }

  .scene-content {
    width: 100% !important;
    height: auto !important;
    padding: 1rem 1rem 4.5rem 1rem !important;
  }

  .scene-heading {
    font-size: 0.85rem !important;
    max-width: 100%;
    margin-bottom: 0.4rem;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .scene-heading::after {
    width: 40px;
    height: 2px;
    margin-top: 0.4rem;
  }

  .scene-bullets {
    max-width: 100%;
    margin-top: 0.25rem;
  }

  .scene-bullets li {
    font-size: 0.7rem !important;
    padding: 0.25rem 0;
    padding-left: 1rem;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .scene-bullets li::before {
    width: 5px;
    height: 5px;
    left: 0;
  }

  /* Video controls - compact for mobile */
  .video-player__controls {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
  }

  .video-player__controls-row {
    gap: 4px;
  }

  .video-player__progress {
    min-width: 60px;
  }

  .video-player__volume-control {
    display: none;
  }

  .video-player__btn {
    width: 36px;
    height: 36px;
    min-width: 44px;
    min-height: 44px;
  }

  .video-player__btn svg {
    width: 14px;
    height: 14px;
  }

  .video-player__btn--play {
    width: 44px;
    height: 44px;
  }

  .video-player__btn--play svg {
    width: 18px;
    height: 18px;
  }

  .video-player__time {
    font-size: 10px;
    min-width: 50px;
  }

  .video-player__scene-counter {
    display: none;
  }

  .video-player__caption-overlay {
    bottom: 70px;
    left: 5%;
    right: 5%;
  }

  .video-player__caption-text {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  /* Intro template on mobile */
  .video-scene[data-template="intro"] .scene-content {
    padding: 1.5rem 1rem 4.5rem !important;
    text-align: center;
  }

  .video-scene[data-template="intro"] .scene-heading {
    font-size: 1.25rem !important;
  }

  /* Big play button - smaller on mobile */
  .video-player__big-play {
    width: 56px;
    height: 56px;
  }

  .video-player__preview-title {
    font-size: 1rem;
  }
}

/* ============================================================================
   Responsive Design - Small Mobile
   ============================================================================ */

@media (max-width: 480px) {
  .video-player__controls {
    padding: 4px 6px;
  }

  .video-player__controls-row {
    gap: 3px;
  }

  .video-player__btn {
    width: 32px;
    height: 32px;
    min-width: 44px;
    min-height: 44px;
  }

  .video-player__btn svg {
    width: 12px;
    height: 12px;
  }

  .video-player__btn--play {
    width: 44px;
    height: 44px;
  }

  .video-player__btn--play svg {
    width: 14px;
    height: 14px;
  }

  .video-player__time {
    font-size: 9px;
    min-width: 45px;
  }

  .scene-heading {
    font-size: 0.9rem !important;
  }

  .scene-bullets li {
    font-size: 0.75rem !important;
  }

  .scene-bullets li:nth-child(n+4) {
    display: none;
  }
}

/* ============================================================================
   Reduced Motion Support
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .scene-background,
  .video-scene,
  .scene-bullets li,
  .video-player__btn,
  .video-player__progress-fill {
    animation: none !important;
    transition: none !important;
  }

  .video-scene.active .scene-bullets li {
    opacity: 1;
  }
}
