/**
 * Loom LazyLoad Pro - Stylesheet
 *
 * Lightweight, zero-dependency, CLS-free styles for responsive Loom video embeds.
 */

:root {
  --llp-default-bg: #111111;
  --llp-play-color: #625df5;
  --llp-play-hover: #4e47e5;
  --llp-transition-speed: 0.25s;
}

/* Base Container */
.llp-container {
  position: relative;
  width: 100%;
  max-width: var(--llp-max-width, 100%);
  background-color: var(--llp-bg, var(--llp-default-bg));
  border-radius: 8px;
  overflow: hidden;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
}

/* 16:9 Horizontal Ratio */
.llp-container.llp-ratio-16-9 {
  aspect-ratio: 16 / 9;
}

/* 9:16 Vertical Ratio (Reels, TikToks, Mobile Shorts) */
.llp-container.llp-ratio-9-16 {
  aspect-ratio: 9 / 16;
  max-width: 420px;
}

/* Legacy Aspect Ratio Fallback for browsers lacking CSS aspect-ratio support */
@supports not (aspect-ratio: 16 / 9) {
  .llp-container.llp-ratio-16-9 {
    padding-bottom: 56.25%;
    height: 0;
  }
  .llp-container.llp-ratio-9-16 {
    padding-bottom: 177.78%;
    height: 0;
  }
}

/* Anti-Blowout / Sizing Protection:
   If .llp-container is placed inside an unstripped intrinsic-ratio 0-height wrapper,
   .llp-is-nested ensures it fills that wrapper cleanly without breaking container hierarchy. */
.llp-container.llp-is-nested {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  max-width: 100% !important;
  border-radius: inherit;
}

/* Placeholder Wrapper */
.llp-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: opacity var(--llp-transition-speed) ease-in-out;
  background-color: inherit;
  outline: none;
}

.llp-placeholder:focus-visible {
  outline: 3px solid var(--llp-play-color);
  outline-offset: -3px;
}

/* Optional Custom Poster Image */
.llp-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 1;
}

/* Play Button */
.llp-play-btn {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
  transition: transform var(--llp-transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.llp-play-icon {
  width: 64px;
  height: 44px;
  display: block;
}

.llp-placeholder:hover .llp-play-btn,
.llp-placeholder:focus-visible .llp-play-btn {
  transform: scale(1.08);
}

.llp-placeholder:hover .llp-play-bg {
  fill: var(--llp-play-hover);
  fill-opacity: 1;
}

/* Loading State */
.llp-loading-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Active Loading Animation */
.llp-container.llp-is-loading .llp-loading-indicator {
  opacity: 1;
}

.llp-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: llp-spin 0.75s linear infinite;
  display: inline-block;
}

@keyframes llp-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Dynamically Generated Iframe */
.llp-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: transparent;
}

/* Fade In Iframe once loaded */
.llp-container.llp-loaded .llp-iframe {
  opacity: 1;
  z-index: 3;
}

.llp-container.llp-loaded .llp-placeholder {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .llp-placeholder,
  .llp-play-btn,
  .llp-iframe,
  .llp-loading-indicator {
    transition: none !important;
  }
  .llp-spinner {
    animation-duration: 2s;
  }
}

/* Fallback Error Display in Debug/Admin */
.llp-error-box {
  padding: 12px 16px;
  background: #fff0f0;
  border: 1px solid #ffcccc;
  border-radius: 4px;
  color: #d63638;
  font-family: monospace;
  font-size: 13px;
  margin: 12px 0;
}
