/**
 * Video Testimonials Widget Styles
 */

/* Wrapper */
.vtw-wrapper {
  position: relative;
  width: 100%;
  z-index: 0;
}

/* Cards Container */
.vtw-cards-container {
  display: grid;
  margin: 0 auto;
}

/* Card */
.vtw-card {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  z-index: 1;
  transition: transform 0.3s ease;
}

.vtw-card:hover,
.vtw-card:active,
.vtw-card:focus-within {
  z-index: 10;
}

.vtw-card:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Static cards (no video, no link) shouldn't have pointer cursor */
.vtw-card--static {
  cursor: default;
}

/* Media Container - fills card via flex */
.vtw-card__media {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

/* Image - fills media container */
.elementor-widget-csw_video_testimonials .vtw-card__img {
  display: block; /* Fix Safari grid row height calculation - removes inline baseline spacing */
  width: 100%;
  height: 100% !important; /* Override Elementor's .elementor img { height: auto } */
  object-fit: cover;
  transition: opacity 0.3s ease;
}

/* Video - absolute overlay on image */
.vtw-card__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0;
  z-index: 2;
  transition: opacity 0.3s ease;
}

/* Hover states - only on devices that support hover AND only for cards with hover video */
@media (hover: hover) and (pointer: fine) {
  .vtw-card--has-hover-video:hover .vtw-card__img {
    opacity: 0;
  }

  .vtw-card--has-hover-video:hover .vtw-card__video {
    opacity: 1;
  }
}

/* Card Info */
.vtw-card__info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 20px;
  z-index: 2;
  border-radius: inherit;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.vtw-card__quote {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 12px 0;
}

.vtw-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

/* Play Button */
.vtw-card__play {
  position: absolute;
  bottom: 24px;
  right: 20px;
  width: 36px;
  height: 36px;
  /* background: rgba(255, 255, 255, 0.2); */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.vtw-card__play svg {
  width: 12px;
  height: 12px;
  fill: #fff;
  margin-left: 2px;
}

.vtw-card:hover .vtw-card__play {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Modal (native dialog element) */
.vtw-modal {
  border: none;
  background: transparent;
  padding: 20px;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}

.vtw-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.3);
}

.vtw-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: vtw-modal-fade-in 0.3s ease;
}

@keyframes vtw-modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.vtw-modal__content {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: visible;
}

.vtw-modal__video,
.vtw-modal__youtube {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  border-radius: 12px;
}

.vtw-modal__video.is-active,
.vtw-modal__youtube.is-active {
  display: block;
}

.vtw-modal__close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  border: none;
  padding: 0px !important;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.vtw-modal__close:hover {
  transform: scale(1.1);
  background-color: rgba(255, 255, 255, 0.3);
}

.vtw-modal__close:focus {
  outline: 2px solid #fff;
  background-color: rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}

.vtw-modal__close svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .vtw-cards-container {
    max-width: 100%;
  }

  .vtw-card {
    max-width: 100%;
  }

  .vtw-card__info {
    padding: 16px;
  }

  .vtw-card__quote {
    font-size: 1rem;
  }

  .vtw-card__meta {
    font-size: 0.75rem;
  }

  .vtw-card__play {
    bottom: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
  }

  .vtw-card__play svg {
    width: 10px;
    height: 10px;
  }

  .vtw-modal__content {
    border-radius: 8px;
  }

  .vtw-modal__close {
    top: -45px;
    width: 36px;
    height: 36px;
  }
}

/* Elementor Editor - ensure card content is above editor overlays */
.elementor-editor-active .vtw-card {
  z-index: 1;
}

.elementor-editor-active .vtw-card__media {
  z-index: 1;
}

.elementor-editor-active .vtw-card__img {
  z-index: 2;
}

.elementor-editor-active .vtw-card__info {
  z-index: 3;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vtw-card,
  .vtw-card__img,
  .vtw-card__video,
  .vtw-card__play,
  .vtw-modal,
  .vtw-modal__close {
    transition: none;
    animation: none;
  }
}

/* Loading state for videos */
.vtw-card__video[data-loading="true"] {
  opacity: 0;
}
