/**
 * Video Facade Styles
 *
 * YouTube/Vimeo facade pattern - lightweight thumbnail + click-to-load
 *
 * @package RLM_Blocks
 */

/* ===== FACADE CONTAINER ===== */

.rlm-video-facade {
  /* Reset button styles (facade is now a <button> element) */
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;

  /* Facade layout */
  position: relative;
  display: block;
  width: 100%;

  /* CRITICAL: Aspect ratio lock prevents CLS when iframe loads */
  aspect-ratio: 16 / 9;

  /* Ensure content fits */
  overflow: hidden;

  /* Cursor feedback */
  cursor: pointer;

  /* Background while thumbnail loads */
  background-color: var(--gray-900, #1a1a1a);

  /* Smooth fade transition */
  transition: opacity 0.3s ease;
}

/* Hover state */
.rlm-video-facade:hover {
  opacity: 0.95;
}

/* Focus state (keyboard navigation) */
.rlm-video-facade:focus {
  outline: 2px solid var(--brand-primary, #007bff);
  outline-offset: 2px;
}

/* Active state */
.rlm-video-facade:active {
  opacity: 0.9;
}

/* ===== THUMBNAIL IMAGE ===== */

.rlm-video-facade__thumbnail {
  /* Fill container */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  /* Cover aspect ratio */
  object-fit: cover;

  /* Prevent text selection */
  user-select: none;

  /* Prevent dragging */
  pointer-events: none;
}

/* ===== PLAY BUTTON ===== */
/* Note: This is a decorative <span> with aria-hidden="true" */
/* The outer <button> (.rlm-video-facade) handles all interactions */

.rlm-video-facade__play-btn {
  /* Center in container */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  /* Decorative element styling */
  padding: 0;
  border: none;
  background: none;

  /* Prevent interaction (outer button handles clicks) */
  pointer-events: none;

  /* Transitions */
  transition: transform 0.2s ease, opacity 0.2s ease;

  /* Z-index above thumbnail */
  z-index: 1;
}

/* Hover effect */
.rlm-video-facade:hover .rlm-video-facade__play-btn {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Active effect */
.rlm-video-facade:active .rlm-video-facade__play-btn {
  transform: translate(-50%, -50%) scale(0.95);
}

/* SVG sizing */
.rlm-video-facade__play-btn svg {
  display: block;
  width: 68px;
  height: 48px;

  /* Drop shadow for visibility on light backgrounds */
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* ===== LOADING STATE ===== */

/* When facade is clicked and loading iframe */
.rlm-video-facade--loading {
  pointer-events: none;
}

.rlm-video-facade--loading .rlm-video-facade__play-btn {
  opacity: 0.5;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ===== IFRAME (After Replacement) ===== */

/* Ensure replaced iframe maintains aspect ratio */
.rlm-video-facade + iframe,
iframe.rlm-video-iframe {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  border: none;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

/* Mobile: Smaller play button */
@media (max-width: 768px) {
  .rlm-video-facade__play-btn svg {
    width: 56px;
    height: 40px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .rlm-video-facade,
  .rlm-video-facade__play-btn {
    transition: none;
  }

  .rlm-video-facade--loading .rlm-video-facade__play-btn {
    animation: none;
  }
}
