/**
 * Video optimization styles for KAB TECH AFRICA website
 */

.lazy-video {
  position: relative;
  width: 100%;
  background-color: #000;
}

.video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.lazy-video.loaded .video-placeholder {
  opacity: 0;
  pointer-events: none;
}

.lazy-video video {
  width: 100%;
  height: 100%;
  display: block;
  background-color: #000;
  object-fit: contain;
}

/* For modal videos - make sure they load properly */
.modal .lazy-video {
  background-color: #000;
  border-radius: 6px;
  overflow: hidden;
  max-height: 80vh;
}

/* Show placeholder in error state */
.lazy-video.error .video-placeholder {
  opacity: 1;
  pointer-events: all;
  display: flex !important;
  background-color: rgba(0, 0, 0, 0.7);
}

/* Optimize video display in cards */
.portfolio-item .ratio-16x9 {
  background-color: #111;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  overflow: hidden;
}

/* Style play button */
.video-play-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  transition: transform 0.2s ease, color 0.2s ease;
  cursor: pointer;
  padding: 1rem;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.5);
}

.video-play-button:hover {
  transform: scale(1.1);
  color: var(--kab-primary);
  background-color: rgba(0, 0, 0, 0.7);
}

.video-play-button i {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  color: var(--kab-primary, #E56B1F); /* Fallback if CSS var not available */
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.5));
}

.video-play-button p {
  font-weight: 500;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Video error state */
.video-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #f8d7da;
  padding: 1rem;
  border-radius: 8px;
  background-color: rgba(220, 53, 69, 0.3);
}

.video-error i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: #dc3545;
}

.video-error p {
  margin: 0;
  font-weight: 500;
}

/* Loading spinner */
.loading-spinner {
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  border-top: 5px solid var(--kab-primary, #E56B1F); /* Fallback if CSS var not available */
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -25px;
  margin-left: -25px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.lazy-video.loading .loading-spinner {
  opacity: 1;
}

.lazy-video.loading .video-placeholder {
  opacity: 0.5;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Custom poster image */
.lazy-video[data-poster] {
  background-size: cover;
  background-position: center;
}