/*
 * Cue Point Overlay Grid
 *
 * A 3x3 CSS grid overlaid on the video player. Each cue point overlay
 * element is placed in a specific grid cell based on its screen_position.
 * The grid container has pointer-events: none so it doesn't block
 * player interactions; individual overlay elements re-enable pointer-events.
 */

.cue-point-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 56px; /* Clear Video.js control bar (48px) + progress bar (8px) */
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 0.75rem;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

/* Portrait mode: tighter padding, adjusted row distribution */
.video-player-container--portrait .cue-point-grid {
  padding: 0.5rem;
  grid-template-rows: 1fr 2fr 1fr;
}

/* ==================
 * Animation States
 * ================== */

.cue-point-overlay {
  display: flex;
  flex-direction: column;
  transition: opacity 300ms ease-in-out, transform 300ms ease-in-out;
  opacity: 1;
  transform: scale(1);
  cursor: pointer;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.cue-point-overlay--entering {
  opacity: 0;
  transform: scale(0.9);
}

.cue-point-overlay--active {
  opacity: 1;
  transform: scale(1);
}

.cue-point-overlay--exiting {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

/* Hover effect */
.cue-point-overlay:hover {
  transform: scale(1.03);
}

/* ==================
 * Card Display Style
 * ================== */

.cue-point-card {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 0.5rem;
  overflow: hidden;
  max-width: 240px;
  min-height: 0; /* Allow shrinking as flex child of .cue-point-overlay */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
}

.cue-point-card__image-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  flex-shrink: 1;
  min-height: 0; /* Allow thumbnail to shrink below aspect-ratio height */
}

.cue-point-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cue-point-card__image-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 200ms ease;
}

.cue-point-card:hover .cue-point-card__image-overlay {
  opacity: 1;
}

.cue-point-card__icon-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
}

.cue-point-card__body {
  display: flex;
  flex-direction: column;
  padding: 0.375rem 0.5rem;
  gap: 0.125rem;
  flex-shrink: 0;
}

.cue-point-card__title {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-point-card__subtitle {
  font-size: 0.625rem;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-point-card__badge {
  font-size: 0.5625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.5);
  padding: 0 0.5rem 0.375rem;
  flex-shrink: 0;
}

/* ==================
 * Pill Display Style
 * ================== */

.cue-point-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  max-width: 200px;
  transition: background 200ms ease;
}

.cue-point-pill:hover {
  background: rgba(0, 0, 0, 0.9);
}

.cue-point-pill__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.8);
}

.cue-point-pill__title {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-point-pill__chevron {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.5);
  transition: transform 200ms ease;
}

.cue-point-pill:hover .cue-point-pill__chevron {
  transform: translateX(2px);
}

/* ==================
 * Minimal Display Style
 * ================== */

.cue-point-minimal {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  transition: background 200ms ease, transform 200ms ease;
}

.cue-point-minimal:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.cue-point-minimal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Subtle pulsing ring to draw attention */
.cue-point-minimal__pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: cue-point-pulse 2s ease-in-out infinite;
}

@keyframes cue-point-pulse {
  0%, 100% { opacity: 0; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ==================
 * Mini Modal
 * ================== */

.cue-point-modal {
  position: absolute;
  z-index: 20;
  opacity: 0;
  transform: scale(0.95) translateY(4px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: auto;
}

.cue-point-modal--active {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.cue-point-modal--exiting {
  opacity: 0;
  transform: scale(0.95) translateY(4px);
  pointer-events: none;
}

.cue-point-modal__inner {
  position: relative;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 0.75rem;
  padding: 0.75rem;
  min-width: 200px;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  color: white;
}

.cue-point-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  border: none;
  cursor: pointer;
  transition: background 150ms ease;
}

.cue-point-modal__close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.cue-point-modal__header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding-right: 1.5rem;
  margin-bottom: 0.75rem;
}

.cue-point-modal__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.cue-point-modal__titles {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.cue-point-modal__title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cue-point-modal__subtitle {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-point-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cue-point-modal__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 150ms ease;
  white-space: nowrap;
}

.cue-point-modal__btn--primary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.cue-point-modal__btn--primary:hover {
  background: rgba(255, 255, 255, 0.25);
}

.cue-point-modal__btn--secondary {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cue-point-modal__btn--secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.cue-point-modal__btn--success {
  background: rgba(34, 197, 94, 0.2) !important;
  color: #22c55e !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

.cue-point-modal__btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cue-point-modal__feedback {
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

/* ==================
 * Portrait Mode Adjustments
 * ================== */

.video-player-container--portrait .cue-point-card {
  max-width: 160px;
}

.video-player-container--portrait .cue-point-card__title {
  font-size: 0.6875rem;
}

.video-player-container--portrait .cue-point-card__subtitle {
  font-size: 0.5625rem;
}

.video-player-container--portrait .cue-point-pill {
  padding: 0.25rem 0.5rem;
  gap: 0.25rem;
  max-width: 140px;
}

.video-player-container--portrait .cue-point-pill__title {
  font-size: 0.6875rem;
}

.video-player-container--portrait .cue-point-minimal {
  width: 1.75rem;
  height: 1.75rem;
}

.video-player-container--portrait .cue-point-pill__icon svg,
.video-player-container--portrait .cue-point-minimal__icon svg {
  width: 0.875rem;
  height: 0.875rem;
}

.video-player-container--portrait .cue-point-modal__inner {
  min-width: 180px;
  max-width: 220px;
  padding: 0.625rem;
}

.video-player-container--portrait .cue-point-modal__btn {
  padding: 0.375rem 0.625rem;
  font-size: 0.6875rem;
}

/* ==================
 * Fullscreen Mode Adjustments
 * ================== */

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-card {
  max-width: 320px;
}

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-card__title {
  font-size: 0.875rem;
}

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-card__subtitle {
  font-size: 0.75rem;
}

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-pill {
  padding: 0.5rem 1rem;
  max-width: 260px;
}

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-pill__title {
  font-size: 0.875rem;
}

.video-js.vjs-fullscreen ~ .cue-point-grid .cue-point-minimal {
  width: 2.5rem;
  height: 2.5rem;
}

/* ==================
 * Responsive sizing
 * ================== */

@media (max-width: 480px) {
  .cue-point-grid {
    padding: 0.25rem;
    bottom: 48px; /* Smaller control bar on mobile */
  }

  .cue-point-pill {
    padding: 0.25rem 0.5rem;
    max-width: 140px;
  }

  .cue-point-pill__title {
    font-size: 0.6875rem;
  }

  .cue-point-minimal {
    width: 1.75rem;
    height: 1.75rem;
  }
}

/* ==================
 * Accessibility
 * ================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .cue-point-overlay {
    transition: opacity 100ms ease;
    transform: none !important;
  }

  .cue-point-overlay--entering {
    transform: none;
  }

  .cue-point-overlay--exiting {
    transform: none;
  }

  .cue-point-minimal__pulse {
    animation: none;
  }

  .cue-point-pill__chevron {
    transition: none;
  }

  .cue-point-modal {
    transition: opacity 100ms ease;
    transform: none !important;
  }

  .cue-point-modal--active {
    transform: none;
  }

  .cue-point-modal--exiting {
    transform: none;
  }
}

/* Focus-visible for keyboard navigation */
.cue-point-overlay:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}
