/* ==========================================================================
   ShortStream · Short Drama Player Styles (Pure English Edition)
   ========================================================================== */

:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-deep: #050608;
  --accent-red: #ff2d55;
  --accent-gold: #ffb800;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.5);
  --glass-bg: rgba(20, 24, 35, 0.7);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  --shadow-popup: 0 10px 40px rgba(0, 0, 0, 0.85);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  letter-spacing: -0.2px;
}

/* App Viewport Container */
.drama-app {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #151b28 0%, #050608 85%);
}

/* Phone Mockup Wrapper (Centered on desktop, fullscreen on mobile) */
.player-wrapper {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  max-height: 900px;
  background: #000;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 24px;
}

@media (max-width: 600px) {
  body {
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }

  .drama-app {
    width: 100vw;
    height: 100dvh;
    background: #000;
  }

  .player-wrapper {
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .top-bar {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .bottom-overlay {
    bottom: calc(26px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .progress-container {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .side-actions {
    bottom: calc(120px + env(safe-area-inset-bottom));
    right: max(12px, env(safe-area-inset-right));
  }

  .episodes-drawer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }

  .unlock-modal {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .drama-cover-layer {
    top: calc(66px + env(safe-area-inset-top));
    bottom: calc(175px + env(safe-area-inset-bottom));
    padding: 6px 12px;
  }
}

/* Video Stage */
/* Video & Cover Stage */
/* Video & Cover Stage (Pure Black Background) */
.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000000;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Video Element (Pure Black letterboxing, 100% full uncropped display) */
.video-element {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 2;
  background: #000000;
}

/* Dedicated Complete Cover Layer: Fixed between top bar and bottom info to guarantee NO overlaps */
.drama-cover-layer {
  position: absolute;
  top: 68px; /* Safe space below top bar */
  bottom: 175px; /* Safe space above bottom drama info & progress bar */
  left: 0;
  right: 0;
  width: 100%;
  height: auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  box-sizing: border-box;
  background: #000000; /* Pure black surroundings as requested */
  transition: opacity 0.35s ease, visibility 0.35s ease;
  cursor: pointer;
}

.drama-cover-layer.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Cover Image: 100% completely visible inside safe bounds, surrounding areas naturally black */
.cover-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.95);
  position: relative;
  z-index: 2;
}

/* Center Play Button Overlay on Cover */
.cover-play-cta {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.cta-play-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-red), #ff5a79);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 10px 30px rgba(255, 45, 85, 0.55), 0 0 0 6px rgba(255, 255, 255, 0.2);
  animation: pulsePlayCta 2s infinite ease-in-out;
}

.cta-play-btn svg {
  width: 30px;
  height: 30px;
  margin-left: 4px;
}

@keyframes pulsePlayCta {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 10px 30px rgba(255, 45, 85, 0.55), 0 0 0 6px rgba(255, 255, 255, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 14px 40px rgba(255, 45, 85, 0.75), 0 0 0 10px rgba(255, 255, 255, 0.1);
  }
}

/* Large Center Play Indicator */
.play-state-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: 76px;
  height: 76px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

.play-state-indicator svg {
  width: 36px;
  height: 36px;
  fill: #fff;
  margin-left: 4px;
}

.play-state-indicator.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Top App Bar (Clean header without back/share buttons) */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  z-index: 20;
}

.top-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.drama-tag {
  font-size: 10px;
  background: var(--accent-red);
  color: #fff;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.6px;
}

.drama-series-name {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right Side Actions (Only Speed & Audio) */
.side-actions {
  position: absolute;
  right: 14px;
  bottom: 130px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 20;
}

.side-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: #fff;
}

.side-icon-circle {
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: transform 0.2s, background 0.2s;
  font-size: 12px;
  font-weight: 800;
}

.side-btn:hover .side-icon-circle {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.65);
}

.side-icon-circle svg {
  width: 22px;
  height: 22px;
}

.side-text {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* Bottom Episode Details & Drawer Trigger Chevron */
.bottom-info {
  position: absolute;
  left: 0;
  bottom: 24px;
  width: 100%;
  padding: 0 16px 14px;
  z-index: 20;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  pointer-events: auto;
}

.bottom-content-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.bottom-text-wrap {
  flex: 1;
  min-width: 0;
  padding-right: 4px;
}

.episode-chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.episode-chip {
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.free-badge {
  font-size: 10px;
  font-weight: 800;
  background: rgba(0, 255, 163, 0.2);
  color: #00ffa3;
  border: 1px solid rgba(0, 255, 163, 0.4);
  padding: 1px 6px;
  border-radius: 4px;
}

.episode-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.episode-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* Transparent Background Drawer Trigger Icon (Like ^) */
.btn-drawer-trigger {
  background: transparent;
  border: none;
  outline: none;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ffffff;
  padding: 0;
  margin-bottom: 2px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-drawer-trigger .chevron-up-icon {
  width: 30px;
  height: 30px;
  stroke: #ffffff;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
  transition: transform 0.25s ease, stroke 0.2s;
  animation: chevronBounce 2s ease-in-out infinite;
}

@keyframes chevronBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.btn-drawer-trigger:hover {
  transform: scale(1.18);
}

.btn-drawer-trigger:hover .chevron-up-icon {
  stroke: var(--accent-red);
  animation-play-state: paused;
}

.btn-drawer-trigger:active {
  transform: scale(0.92);
}

/* Bottom Scrubbing Progress Bar */
.progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px 8px;
  z-index: 25;
  background: #000;
  cursor: pointer;
}

.progress-bar-bg {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  position: relative;
  transition: height 0.15s;
}

.progress-container:hover .progress-bar-bg {
  height: 5px;
}

.progress-bar-current {
  width: 0%;
  height: 100%;
  background: var(--accent-red);
  border-radius: var(--radius-pill);
  position: relative;
}

.progress-bar-current::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
}

.progress-container:hover .progress-bar-current::after {
  opacity: 1;
}

.time-display {
  display: flex;
  justify-content: flex-end;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: monospace;
}

/* ==========================================================================
   Episodes Bottom Drawer (Whole Series Display with Locks)
   ========================================================================== */

.episodes-drawer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 68%;
  background: rgba(14, 18, 28, 0.96);
  backdrop-filter: blur(24px);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.95);
  z-index: 40;
  transform: translateY(105%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.episodes-drawer.active {
  transform: translateY(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-title {
  font-size: 17px;
  font-weight: 800;
}

.drawer-total-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.drawer-close-btn:hover {
  color: #fff;
}

.episodes-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding-bottom: 20px;
}

/* Episode Item: Unlocked vs Locked */
.ep-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.ep-item:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.ep-item.active {
  background: var(--accent-red);
  border-color: var(--accent-red);
  box-shadow: 0 0 15px rgba(255, 45, 85, 0.5);
}

/* Locked items with subtle golden lock badge */
.ep-item.locked {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
}

.ep-item.locked .lock-corner {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  line-height: 1;
}

/* ==========================================================================
   Unlock Locked Episode Modal (Upsell / Subscription Dialog)
   ========================================================================== */

.unlock-modal-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.unlock-modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.unlock-modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #111522;
  border: 1px solid rgba(255, 184, 0, 0.35);
  border-radius: var(--radius-lg);
  padding: 28px 22px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 184, 0, 0.15);
}

.unlock-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  z-index: 5;
}

.unlock-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.lock-graphic {
  margin-bottom: 14px;
}

.lock-icon-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 184, 0, 0.15);
  border: 2px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto;
}

.unlock-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.unlock-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}

.unlock-perks {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--accent-gold);
  text-align: left;
}

.unlock-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.btn-unlock-primary {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #ffb800 0%, #ff8800 100%);
  color: #000;
  font-size: 14.5px;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 184, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-unlock-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 184, 0, 0.45);
}

.btn-unlock-primary:disabled {
  cursor: wait;
  opacity: 0.95;
  background: linear-gradient(135deg, #e5a400 0%, #e07800 100%);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(0, 0, 0, 0.25);
  border-top-color: #000000;
  border-radius: 50%;
  display: inline-block;
  animation: spinLoading 0.75s linear infinite;
  margin-right: 10px;
  flex-shrink: 0;
}

@keyframes spinLoading {
  to {
    transform: rotate(360deg);
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 18, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(12px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: var(--shadow-popup);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(10px);
}
