/* Carousel Module Styles */

.carousel-module {
  position: relative;
  width: 100%;
}

/* Lazy Loading with Content Visibility for better performance */
.carousel-module[data-lazy="true"] {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
  contain: layout style paint;
}

.carousel-title {
  margin-bottom: 2rem;
  font-size: var(--font-size-h2, 2rem);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-text);
  font-family: var(--font-family-heading, inherit);
}

/* Container */
.carousel-container {
  position: relative;
  width: 100%;
}

/* Track */
.carousel-track-wrapper {
  position: relative;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  /* Smooth cubic-bezier for soft start/stop animation */
  transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: transform;
}

.carousel-track.transitioning {
  will-change: transform;
}

.carousel-track:not(.transitioning) {
  will-change: auto;
}

.carousel-slide {
  flex-shrink: 0;
  width: 100%;
  padding: 0.5rem 0; /* Space for hover shadow */
}

/* Card Styling - Consistent with theme cards */
.carousel-card {
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius, 0.5rem);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition:
    transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
    box-shadow 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
    border-color 0.3s ease;
}

/* Card Hover Effects */
.carousel-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.12),
    0 4px 10px rgba(0, 0, 0, 0.08);
  border-color: var(--color-primary);
}

/* Clickable card specific styles */
.clickable-card {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.clickable-card:hover {
  transform: translateY(-8px);
  box-shadow:
    0 16px 32px rgba(0, 0, 0, 0.15),
    0 6px 12px rgba(0, 0, 0, 0.1);
}

/* Card flag/label styling lives inline in module.html (unified .card-flag design,
   shared visual across all card modules). The old left-side orange flag rule that
   used to live here was stale and conflicted with the inline rule — removed. */

/* Card Media Wrapper with Image Zoom */
.card-media-wrapper {
  position: relative;
  overflow: hidden;
  background: var(--color-bg-secondary);
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  border-radius: var(--border-radius, 0.5rem) var(--border-radius, 0.5rem) 0 0;
}

.card-media-wrapper[style*="height"] {
  aspect-ratio: auto;
}

.card-media-wrapper picture,
.card-media-wrapper img,
.card-media-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Image zoom on card hover */
.carousel-card:hover .card-media-wrapper img,
.carousel-card:hover .card-media-wrapper video {
  transform: scale(1.08);
}

/* Card Content */
.carousel-card .card-content {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Content Overlay (when no height set) */
.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, var(--color-bg-secondary) 100%);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
}

.card-overlay .card-title,
.card-overlay .card-richtext {
  color: var(--color-text);
}

/* Card Elements */
.card-title {
  font-size: var(--font-size-h4, 1.25rem);
  font-weight: var(--font-weight-semibold, 600);
  margin-bottom: 0.75rem;
  color: var(--color-text);
  font-family: var(--font-family-heading, inherit);
}

.card-richtext {
  margin-bottom: 1rem;
  line-height: var(--line-height-body, 1.6);
  color: var(--color-text);
  font-family: var(--font-family-body, inherit);
  font-size: var(--font-size-body, 1rem);
}

.card-richtext ul,
.card-richtext ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.card-richtext li {
  margin: 0.25rem 0;
}

.card-button-wrapper {
  margin-top: auto;
  padding-top: 1rem;
}

.carousel-btn {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  font-weight: var(--font-weight-medium, 500);
  text-decoration: none;
  border-radius: var(--radius-sm, 0.375rem);
  transition: var(--transition, all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1));
  background: var(--color-primary);
  color: var(--color-primary-contrast, white);
  border: 2px solid var(--color-primary);
  font-family: var(--font-family-body, inherit);
}

.carousel-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  filter: brightness(1.1);
}

/* Navigation Arrows */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.3s ease;
  color: var(--color-text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0;
  margin: 0;
}

.carousel-arrow {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  display: block;
  margin-top: -2px;
}

.carousel-nav:hover:not([disabled]) {
  background: var(--color-primary);
  color: #ffffff;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-color: var(--color-primary);
}

.carousel-nav-prev {
  left: 12px;
}

.carousel-nav-next {
  right: 12px;
}

.carousel-nav[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  box-shadow: none;
}

/* Dots Navigation */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  padding: 12px;
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--color-border);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
  padding: 0;
}

.carousel-dot:hover {
  background: var(--color-text);
  transform: scale(1.2);
}

.carousel-dot.active {
  width: 28px;
  border-radius: 5px;
  background: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Touch/Swipe Indicators */
@media (hover: none) and (pointer: coarse) {
  .carousel-track-wrapper {
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .carousel-track-wrapper:active {
    cursor: grabbing;
  }
}

/* Mobile Responsive */
@media (max-width: 992px) {
  .carousel-title {
    font-size: var(--font-size-h3, 1.5rem);
  }
  
  .carousel-nav {
    width: clamp(32px, 4.5vw, 36px);
    height: clamp(32px, 4.5vw, 36px);
  }
  
  .carousel-nav-prev {
    left: 5px;
  }
  
  .carousel-nav-next {
    right: 5px;
  }
  
  .card-title {
    font-size: var(--font-size-h5, 1.125rem);
  }
  
  .card-richtext {
    font-size: var(--font-size-small, 0.875rem);
  }
  
  .carousel-card .card-content {
    padding: 1rem;
  }
}

/* Reduced Motion Support for Accessibility */
@media (prefers-reduced-motion: reduce) {
  .carousel-track {
    transition: none !important;
  }
  
  .carousel-nav:hover {
    transform: translateY(-50%) !important;
    box-shadow: none !important;
  }
  
  .carousel-dot {
    transition: none !important;
  }
  
  .carousel-btn:hover {
    transform: none !important;
    transition: none !important;
  }
  
  .carousel-card {
    transition: none !important;
  }
  
  .carousel-card:hover {
    transform: none !important;
  }
}


/* Print Styles */
@media print {
  .carousel-nav,
  .carousel-dots {
    display: none !important;
  }
  
  .carousel-track {
    display: block;
  }
  
  .carousel-slide {
    display: inline-block;
    width: 33.333%;
    page-break-inside: avoid;
  }
  
  .carousel-module {
    --color-bg: var(--color-bg);
    --color-text: var(--color-text);
    --color-border: var(--color-border);
  }
}