/**
 * Auto-Looping Video & Image Carousel Styles
 * 
 * Professional, responsive, and accessible carousel styling
 * Supports fade and slide transitions
 * 
 * @author Professional Front-End Developer
 * @date October 15, 2025
 */

/* ============================================
   CAROUSEL CONTAINER
   ============================================ */

.media-carousel {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    background-color: #000;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Maintain aspect ratio (16:9 by default) */
.media-carousel::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

/* Make carousel fill container for custom aspect ratios */
.media-carousel.aspect-auto::before {
    display: none;
}

.media-carousel.aspect-square::before {
    padding-top: 100%; /* 1:1 */
}

.media-carousel.aspect-4-3::before {
    padding-top: 75%; /* 4:3 */
}

.media-carousel.aspect-21-9::before {
    padding-top: 42.857%; /* 21:9 */
}

/* ============================================
   SLIDES CONTAINER
   ============================================ */

.carousel-slides {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   INDIVIDUAL SLIDES
   ============================================ */

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1s ease-in-out, visibility 1s ease-in-out;
    z-index: 1;
}

.carousel-slide.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

.carousel-slide.prev {
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

/* Media elements inside slides - Auto-fit with aspect ratio preservation */
.carousel-slide img,
.carousel-slide video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: auto;
    user-select: none;
    -webkit-user-select: none;
    /* Center the media */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Alternative object-fit modes */
.media-carousel.cover .carousel-slide img,
.media-carousel.cover .carousel-slide video {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.media-carousel.fill .carousel-slide img,
.media-carousel.fill .carousel-slide video {
    object-fit: fill;
    width: 100%;
    height: 100%;
}

/* Contain mode (default) - ensures full media is visible */
.media-carousel.contain .carousel-slide img,
.media-carousel.contain .carousel-slide video {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* ============================================
   SLIDE TRANSITION ANIMATIONS
   ============================================ */

/* Fade Transition (Default) */
.carousel-slides.carousel-fade .carousel-slide {
    transition: opacity 1s ease-in-out, visibility 1s ease-in-out;
}

/* Slide Transition */
.carousel-slides.carousel-slide .carousel-slide {
    transition: transform 1s ease-in-out, opacity 1s ease-in-out, visibility 1s ease-in-out;
}

.carousel-slides.carousel-slide .carousel-slide {
    transform: translateX(100%);
}

.carousel-slides.carousel-slide .carousel-slide.active {
    transform: translateX(0);
}

.carousel-slides.carousel-slide .carousel-slide.prev {
    transform: translateX(-100%);
}

/* ============================================
   NAVIGATION CONTROLS - MINIMAL & TRANSPARENT
   ============================================ */

.carousel-controls {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transform: translateY(-50%);
    padding: 0 20px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show controls only on hover */
.media-carousel:hover .carousel-controls {
    opacity: 1;
}

.carousel-control {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.carousel-control:hover {
    background-color: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.carousel-control:active {
    transform: scale(0.95);
}

.carousel-control:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.carousel-play-pause {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    font-size: 16px;
}

/* ============================================
   INDICATORS (DOTS) - MINIMAL DESIGN
   ============================================ */

.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.carousel-indicators:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.35);
}

.carousel-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    background-color: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.carousel-indicator:hover {
    background-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.3);
    border-color: rgba(255, 255, 255, 0.9);
}

.carousel-indicator.active {
    background-color: rgba(255, 255, 255, 0.95);
    transform: scale(1.4);
    border-color: rgba(255, 255, 255, 1);
}

.carousel-indicator:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Hide controls when there's only one item */
.media-carousel:has(.carousel-slide:only-child) .carousel-controls,
.media-carousel:has(.carousel-slide:only-child) .carousel-indicators {
    display: none;
}

/* ============================================
   LOADING STATE
   ============================================ */

.carousel-slide::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: carousel-spin 1s linear infinite;
    opacity: 0;
    pointer-events: none;
}

.carousel-slide.loading::after {
    opacity: 1;
}

@keyframes carousel-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablets and smaller */
@media (max-width: 768px) {
    .carousel-control {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .carousel-controls {
        padding: 0 10px;
    }

    .carousel-indicators {
        bottom: 10px;
        gap: 8px;
        padding: 8px 15px;
    }

    .carousel-indicator {
        width: 10px;
        height: 10px;
    }

    .carousel-play-pause {
        bottom: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .carousel-control {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .carousel-indicators {
        gap: 6px;
        padding: 6px 12px;
    }

    .carousel-indicator {
        width: 8px;
        height: 8px;
    }

    .carousel-play-pause {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .carousel-slide,
    .carousel-control,
    .carousel-indicator {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .carousel-control {
        background-color: #000;
        border: 2px solid #fff;
    }

    .carousel-indicator {
        border-width: 3px;
    }
}

/* ============================================
   DARK/LIGHT MODE SUPPORT
   ============================================ */

/* Light mode variant */
.media-carousel.light {
    background-color: #f5f5f5;
}

.media-carousel.light .carousel-control {
    background-color: rgba(255, 255, 255, 0.8);
    color: #000;
}

.media-carousel.light .carousel-control:hover {
    background-color: rgba(255, 255, 255, 1);
}

.media-carousel.light .carousel-indicator {
    border-color: #000;
}

.media-carousel.light .carousel-indicator.active {
    background-color: #000;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Full screen carousel */
.media-carousel.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    z-index: 9999;
}

.media-carousel.fullscreen::before {
    display: none;
}

/* No shadow variant */
.media-carousel.no-shadow {
    box-shadow: none;
}

/* Rounded corners variant */
.media-carousel.rounded {
    border-radius: 16px;
}

.media-carousel.rounded-lg {
    border-radius: 24px;
}

/* No controls visibility until hover */
.media-carousel.hide-controls .carousel-controls,
.media-carousel.hide-controls .carousel-indicators {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-carousel.hide-controls:hover .carousel-controls,
.media-carousel.hide-controls:hover .carousel-indicators {
    opacity: 1;
}
