/* ============================================
   VIDEO PIP — CSS-only Picture-in-Picture
   Desktop: floating 320px bottom-right
   Mobile: full-width at header position (Dynamic Island)
   ============================================ */

/* ── PiP state on the inline player ── */

.video-player.video-player--pip {
  position: fixed;
  bottom: var(--space-6, 24px);
  right: var(--space-6, 24px);
  width: 320px;
  z-index: 150;
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25),
              0 2px 8px rgba(0, 0, 0, 0.15);
  animation: pip-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Override article-layout sizing when in PiP */
.article-layout .video-player.video-player--pip {
  margin: 0;
  max-width: none;
}

@keyframes pip-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Hide inline controls in PiP mode (desktop — too wide) ── */

.video-player--pip .video-player__controls {
  display: none !important;
}

/* Hide play overlay in PiP */
.video-player--pip .video-player__play-btn {
  display: none !important;
}

/* ── PiP overlay controls (injected into .video-player) ── */

.video-pip__overlay {
  display: none;
}

.video-player--pip .video-pip__overlay {
  display: block;
}

/* Close & expand buttons */
.video-pip__close,
.video-pip__expand {
  position: absolute;
  top: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.15s ease, transform 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.video-pip__close {
  right: 8px;
}

.video-pip__expand {
  left: 8px;
}

.video-pip__close:hover,
.video-pip__expand:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

/* ── Mini control bar ── */

.video-pip__mini-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(244, 235, 225, 0.3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 5;
}

.video-pip__play {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background 0.15s;
}

.video-pip__play:hover {
  background: rgba(255, 255, 255, 0.15);
}

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

.video-pip__progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.video-pip__progress:hover {
  height: 5px;
}

.video-pip__progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: width 0.15s linear;
}

.video-pip__time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
}

/* ── Placeholder ── */

.video-pip__placeholder {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md, 12px);
  background: transparent;
}

/* ── Mobile: full-width Dynamic Island video ── */

@media (max-width: 767px) {
  .video-player.video-player--pip {
    top: var(--space-4, 16px);
    left: var(--grid-margin, 16px);
    right: var(--grid-margin, 16px);
    bottom: auto;
    width: auto;
    z-index: 151;
    border-radius: var(--radius-lg, 16px);
    animation: pip-enter-mobile 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  /* Show normal inline controls instead of mini overlay bar */
  .video-player--pip .video-player__controls {
    display: flex !important;
  }

  /* Hide the mini-bar (normal controls handle play/progress/time) */
  .video-player--pip .video-pip__mini-bar {
    display: none !important;
  }
}

@keyframes pip-enter-mobile {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
