/* ==========================================================================
   eScience Secure Video Player Engine (Masked YouTube + Custom Controls)
   Anti-Link-Sharing & Subtle Student Dynamic Watermark
   ========================================================================== */

.escience-custom-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* Fullscreen mode styling */
.escience-custom-player:fullscreen,
.escience-custom-player:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  aspect-ratio: unset !important;
  max-width: none !important;
}

/* 1. MASKED YOUTUBE IFRAME WRAPPER
   - Pushes top bar (title & share button) and bottom logo outside visible bounds
   - pointer-events: none completely prevents user from clicking links or context menus */
.escience-custom-player .yt-masked-frame {
  position: absolute;
  top: -14%;
  left: -7%;
  width: 114%;
  height: 128%;
  pointer-events: none !important;
  overflow: hidden;
  background: #000;
}

.escience-custom-player .yt-masked-frame iframe,
.escience-custom-player .yt-masked-frame #secureYtPlayer,
.escience-custom-player .yt-masked-frame #escienceYtEmbedTarget {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  pointer-events: none !important;
}

/* 2. CLICK SHIELD OVERLAY (Tap to Play/Pause) */
.escience-custom-player .player-click-shield {
  position: absolute;
  inset: 0;
  z-index: 5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

/* Center Animated Play/Pause Indicator */
.escience-custom-player .play-state-indicator {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.escience-custom-player .play-state-indicator.active {
  opacity: 1;
  transform: scale(1);
}

/* 3. SUBTLE STUDENT WATERMARK LAYER (Anti-Leak Protection) */
.escience-custom-player .player-watermark-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none !important;
  overflow: hidden;
}

/* Repeating diagonal faint background watermark */
.escience-custom-player .watermark-grid-bg {
  position: absolute;
  inset: -60%;
  width: 220%;
  height: 220%;
  transform: rotate(-24deg);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 60px 40px;
  opacity: 0.085;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
  user-select: none;
}

.escience-custom-player .watermark-grid-bg span {
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* Floating subtle student pill (Drifts smoothly across the screen) */
.escience-custom-player .floating-watermark-pill {
  position: absolute;
  top: 15%;
  left: 15%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  animation: watermarkDrift 28s infinite ease-in-out alternate;
  will-change: top, left, opacity;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.escience-custom-player .floating-watermark-pill i {
  color: #38BDF8;
  font-size: 12px;
}

.escience-custom-player .floating-watermark-pill .pill-sub {
  font-size: 10px;
  opacity: 0.85;
  color: #CBD5E1;
  font-family: monospace;
}

/* Smooth drifting animation across quadrants so it cannot be cropped */
@keyframes watermarkDrift {
  0% {
    top: 12%;
    left: 8%;
    opacity: 0.42;
  }
  25% {
    top: 68%;
    left: 48%;
    opacity: 0.58;
  }
  50% {
    top: 18%;
    left: 56%;
    opacity: 0.38;
  }
  75% {
    top: 62%;
    left: 12%;
    opacity: 0.62;
  }
  100% {
    top: 15%;
    left: 42%;
    opacity: 0.45;
  }
}

/* Top Protection Badge */
.escience-custom-player .top-protection-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94A3B8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.escience-custom-player .top-protection-badge i {
  color: #10B981;
  font-size: 11px;
}

/* 4. CUSTOM CONTROLS BAR */
.escience-custom-player .player-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 8px 16px 10px;
  background: linear-gradient(to top, rgba(10, 15, 29, 0.95) 0%, rgba(10, 15, 29, 0.6) 60%, transparent 100%);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.escience-custom-player.controls-hidden .player-controls-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.escience-custom-player.controls-hidden {
  cursor: none;
}

/* Timeline / Seekbar */
.escience-custom-player .timeline-container {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  cursor: pointer;
  transition: height 0.15s ease;
  display: flex;
  align-items: center;
}

.escience-custom-player .timeline-container:hover {
  height: 8px;
}

.escience-custom-player .timeline-buffer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.38);
  border-radius: 6px;
  width: 0%;
  pointer-events: none;
}

.escience-custom-player .timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #2563EB, #0284C7);
  border-radius: 6px;
  width: 0%;
  pointer-events: none;
}

.escience-custom-player .timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  background: #38BDF8;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.escience-custom-player .timeline-container:hover .timeline-thumb,
.escience-custom-player .timeline-container.dragging .timeline-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.escience-custom-player .timeline-hover-time {
  position: absolute;
  top: -26px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #FFFFFF;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.escience-custom-player .timeline-container:hover .timeline-hover-time {
  display: block;
}

/* Control Buttons Row */
.escience-custom-player .controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.escience-custom-player .controls-left,
.escience-custom-player .controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.escience-custom-player .player-btn {
  background: none;
  border: none;
  color: #F8FAFC;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
  outline: none;
}

.escience-custom-player .player-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #38BDF8;
}

.escience-custom-player .player-btn:active {
  transform: scale(0.92);
}

.escience-custom-player .time-display {
  color: #E2E8F0;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 3px;
}

.escience-custom-player .time-display .time-sep {
  opacity: 0.5;
}

/* Speed selector dropdown */
.escience-custom-player .speed-menu-wrap {
  position: relative;
}

.escience-custom-player .speed-btn {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.escience-custom-player .speed-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 90px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.escience-custom-player .speed-dropdown.show {
  display: flex;
}

.escience-custom-player .speed-option {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #E2E8F0;
  cursor: pointer;
  border-radius: 4px;
  text-align: center;
  transition: all 0.15s ease;
}

.escience-custom-player .speed-option:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #38BDF8;
}

.escience-custom-player .speed-option.active {
  background: #2563EB;
  color: #FFFFFF;
}

/* Volume Slider */
.escience-custom-player .volume-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.escience-custom-player .volume-slider {
  width: 65px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.escience-custom-player .volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #38BDF8;
  cursor: pointer;
}

.escience-custom-player .volume-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #38BDF8;
  cursor: pointer;
  border: none;
}

/* Mobile responsive tweaks */
@media (max-width: 640px) {
  .escience-custom-player .volume-wrap .volume-slider {
    display: none;
  }
  .escience-custom-player .floating-watermark-pill {
    padding: 4px 10px;
    font-size: 10px;
  }
  .escience-custom-player .time-display {
    font-size: 11px;
  }
  .escience-custom-player .player-btn {
    padding: 4px 6px;
    font-size: 13px;
  }
}
