/* carousel.css - Styling for the Virtual Fairgrounds image carousel */

/* Main carousel container that holds all carousel elements */
.carousel-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    background: #f8f8f8;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Image wrapper that maintains aspect ratio */
.carousel-image-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 aspect ratio by default */
    overflow: hidden;
    background: #000;
}

/* Adjust aspect ratio for different image sets if needed */
.carousel-image-wrapper.aspect-16-9 {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.carousel-image-wrapper.aspect-4-3 {
    padding-bottom: 75%; /* 4:3 aspect ratio */
}

.carousel-image-wrapper.aspect-square {
    padding-bottom: 100%; /* 1:1 aspect ratio */
}

/* Individual carousel images */
.carousel-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Maintain aspect ratio without cropping */
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    background: #000; /* Background color for letterboxing */
}

/* Active image is visible */
.carousel-image.active {
    opacity: 1;
}

/* Navigation buttons */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid transparent;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.3s ease;
    z-index: 2;
    user-select: none;
}

.carousel-nav:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav:active:not(:disabled) {
    transform: translateY(-50%) scale(0.95);
}

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

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

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Navigation symbols with better browser support */
.carousel-nav.prev::before {
    content: '❮';
}

.carousel-nav.next::before {
    content: '❯';
}

/* Image indicators/dots */
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    z-index: 2;
}

.carousel-indicator {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-indicator:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: scale(1.2);
}

.carousel-indicator.active {
    background: white;
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.3);
}

/* Caption area */
.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 20px 20px 60px 20px; /* Extra bottom padding for indicators */
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.carousel-caption:empty {
    display: none;
}

/* Thumbnail navigation (hidden by default, shown when enabled) */
.carousel-thumbnails {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    padding: 10px;
    overflow-x: auto;
    white-space: nowrap;
    z-index: 3;
}

.carousel-thumbnails.active {
    display: block;
}

.carousel-thumbnail {
    display: inline-block;
    width: 80px;
    height: 60px;
    margin: 0 5px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
}

.carousel-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.carousel-thumbnail.active {
    opacity: 1;
    border-color: white;
}

/* Loading state */
.carousel-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    text-align: center;
    z-index: 1;
}

.carousel-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 10px auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: carousel-spin 1s linear infinite;
}

@keyframes carousel-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Autoplay progress bar */
.carousel-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    width: 0;
    transition: width linear;
    z-index: 3;
}

.carousel-progress.active {
    width: 100%;
}

/* Fullscreen mode adjustments */
.carousel-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    max-height: none;
    z-index: 9999;
    border-radius: 0;
}

.carousel-container.fullscreen .carousel-image-wrapper {
    padding-bottom: 0;
    height: 100%;
}

.carousel-container.fullscreen .carousel-nav {
    font-size: 36px;
    padding: 20px 25px;
}

/* Responsive design */
@media (max-width: 768px) {
    .carousel-container {
        max-width: 100%;
        margin: 10px;
    }
    
    .carousel-nav {
        padding: 10px 15px;
        font-size: 20px;
    }
    
    .carousel-indicators {
        bottom: 10px;
        padding: 8px 12px;
    }
    
    .carousel-indicator {
        width: 8px;
        height: 8px;
        margin: 0 4px;
    }
    
    .carousel-thumbnails {
        padding: 8px;
    }
    
    .carousel-thumbnail {
        width: 60px;
        height: 45px;
        margin: 0 3px;
    }
}

/* Slide transition support */
.carousel-container.slide-transition .carousel-image {
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out;
    transform: translateX(100%);
}

.carousel-container.slide-transition .carousel-image.active {
    transform: translateX(0);
}

.carousel-container.slide-transition .carousel-image.prev {
    transform: translateX(-100%);
}

/* Print styles */
@media print {
    .carousel-nav,
    .carousel-indicators,
    .carousel-thumbnails,
    .carousel-progress {
        display: none !important;
    }
    
    .carousel-image {
        position: static;
        opacity: 1;
        page-break-inside: avoid;
    }
}

/* Accessibility improvements */
.carousel-container:focus-within {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

.carousel-nav:focus,
.carousel-indicator:focus,
.carousel-thumbnail:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Loading error state */
.carousel-image-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #ccc;
    padding: 20px;
}

.carousel-image-error svg {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}