/**
 * Corporate Commerce – Banner popup
 * Responsive, accessible modal for promotional banners.
 */

/* Screen-reader only (fallback if theme has no .sr-only) */
.cc-banner-popup .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduce motion: skip entrance animation */
@media (prefers-reduced-motion: reduce) {
  .cc-banner-popup__dialog {
    animation: none !important;
  }
  .cc-banner-popup__backdrop {
    animation: none !important;
  }
}

.cc-banner-popup__backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cc-banner-popup.is-open .cc-banner-popup__backdrop {
  opacity: 1;
  visibility: visible;
}

.cc-banner-popup__dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 9999;
  width: calc(100% - 2rem);
  max-width: 520px;
  max-height: calc(100vh - 2rem);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.cc-banner-popup.is-open .cc-banner-popup__dialog {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Header: close button */
.cc-banner-popup__header {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.5rem 0.5rem 0 0;
  gap: 0.5rem;
}

.cc-banner-popup__close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: #f1f5f9;
  color: #475569;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.cc-banner-popup__close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.cc-banner-popup__close:focus {
  outline: 2px solid var(--eduhive-base, #0066cc);
  outline-offset: 2px;
}

/* Slider container */
.cc-banner-popup__body {
  flex: 1;
  min-height: 0;
  padding: 0 1rem 1rem;
  position: relative;
}

.cc-banner-popup__slider {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.cc-banner-popup__slide {
  display: none;
  width: 100%;
}

.cc-banner-popup__slide.is-active {
  display: block;
}

.cc-banner-popup__slide img {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 10rem);
  object-fit: contain;
  object-position: top center;
  display: block;
  vertical-align: middle;
}

/* Nav: prev/next */
.cc-banner-popup__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: #334155;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  z-index: 2;
}

.cc-banner-popup__nav:hover {
  background: #fff;
  color: var(--eduhive-base, #0066cc);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cc-banner-popup__nav:focus {
  outline: 2px solid var(--eduhive-base, #0066cc);
  outline-offset: 2px;
}

.cc-banner-popup__nav--prev {
  left: 0.5rem;
}

.cc-banner-popup__nav--next {
  right: 0.5rem;
}

/* Dots */
.cc-banner-popup__dots {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

.cc-banner-popup__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: #cbd5e1;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.cc-banner-popup__dot:hover {
  background: #94a3b8;
}

.cc-banner-popup__dot.is-active {
  background: var(--eduhive-base, #0066cc);
  transform: scale(1.2);
}

.cc-banner-popup__dot:focus {
  outline: 2px solid var(--eduhive-base, #0066cc);
  outline-offset: 2px;
}

/* Responsive: smaller screens */
@media (max-width: 575px) {
  .cc-banner-popup__dialog {
    width: calc(100% - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .cc-banner-popup__body {
    padding: 0 0.5rem 0.5rem;
  }

  .cc-banner-popup__slide img {
    max-height: calc(100vh - 8rem);
  }

  .cc-banner-popup__nav {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 0.9rem;
  }

  .cc-banner-popup__nav--prev {
    left: 0.25rem;
  }

  .cc-banner-popup__nav--next {
    right: 0.25rem;
  }
}

/* High contrast / focus visible */
@media (prefers-contrast: high) {
  .cc-banner-popup__close:focus,
  .cc-banner-popup__nav:focus,
  .cc-banner-popup__dot:focus {
    outline-width: 3px;
  }
}
