/**
 * Enhanced Carousel Styles - Core Web Vitals Optimized
 * MenuMicro Portal
 */

/* Base carousel styles with performance optimizations */
.hero-carousel {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 500px;
    overflow: hidden;
    background: #1e293b;
    /* Prevent layout shift */
    contain: layout style paint;
    /* GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
}

.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
    /* Prevent reflow during transitions */
    contain: strict;
}

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent text selection during transitions */
    user-select: none;
    /* Ensure content doesn't overflow */
    overflow: hidden;
}

.carousel-slide.active {
    opacity: 1;
    user-select: auto;
}

/* Background handling */
.slide-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Performance optimization */
    transform: translateZ(0);
    will-change: transform;
}

/* Slide content */
.slide-content {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    padding: 0 2rem;
    text-align: center;
    color: white;
    /* Prevent layout shift */
    contain: layout;
}

.slide-content h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    /* Prevent font loading issues */
    font-display: swap;
}

.slide-content p {
    font-size: clamp(1rem, 3vw, 1.3rem);
    line-height: 1.6;
    margin-bottom: 2.5rem;
    opacity: 0.95;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
}

/* CTA Button with enhanced interactivity */
.slide-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    /* Performance */
    transform: translateZ(0);
    will-change: transform, background-color, border-color;
}

.slide-cta:hover,
.slide-cta:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    outline: none;
}

.slide-cta:active {
    transform: translateY(0) scale(0.98);
}

/* Navigation Controls */
.carousel-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 10;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    cursor: pointer;
    transition: all 300ms ease;
    /* Remove default button styles */
    padding: 0;
    margin: 0;
    /* Performance */
    will-change: transform, background-color, border-color;
}

.carousel-dot:hover,
.carousel-dot:focus {
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: 4px;
}

.carousel-dot.active {
    background: white;
    border-color: white;
    transform: scale(1.1);
}

/* Navigation Arrows */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 300ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
    backdrop-filter: blur(10px);
    /* Performance */
    will-change: transform, background-color, border-color;
}

.carousel-prev {
    left: 2rem;
}

.carousel-next {
    right: 2rem;
}

.carousel-nav:hover,
.carousel-nav:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-50%) scale(1.1);
    outline: none;
}

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

/* Transition Effects */
.hero-carousel.transitioning-next .carousel-slide.active {
    animation: slideInRight 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-carousel.transitioning-prev .carousel-slide.active {
    animation: slideInLeft 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Progress Indicator (optional) */
.carousel-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.carousel-progress-bar {
    height: 100%;
    background: white;
    width: 0%;
    transition: width linear;
}

/* Accessibility improvements */
.carousel-slide[aria-hidden="true"] {
    pointer-events: none;
}

.carousel-slide:focus-within {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: -3px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .carousel-slide,
    .carousel-dot,
    .carousel-nav,
    .slide-cta {
        transition: none !important;
        animation: none !important;
    }
    
    .hero-carousel.transitioning-next .carousel-slide.active,
    .hero-carousel.transitioning-prev .carousel-slide.active {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .carousel-dot {
        border-width: 3px;
    }
    
    .carousel-nav {
        border-width: 3px;
    }
    
    .slide-cta {
        border-width: 3px;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .hero-carousel {
        height: 60vh;
        min-height: 400px;
    }
    
    .slide-content {
        padding: 0 1.5rem;
    }
    
    .carousel-nav {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .carousel-prev {
        left: 1.5rem;
    }
    
    .carousel-next {
        right: 1.5rem;
    }
}

@media (max-width: 768px) {
    .hero-carousel {
        height: 50vh;
        min-height: 350px;
    }
    
    .slide-content {
        padding: 0 1rem;
    }
    
    .slide-content h1 {
        margin-bottom: 1rem;
    }
    
    .slide-content p {
        margin-bottom: 1.5rem;
    }
    
    .slide-cta {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .carousel-controls {
        bottom: 1.5rem;
    }
    
    .carousel-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .carousel-prev {
        left: 1rem;
    }
    
    .carousel-next {
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .hero-carousel {
        height: 45vh;
        min-height: 300px;
    }
    
    .carousel-controls {
        bottom: 1rem;
        gap: 0.75rem;
    }
    
    .carousel-dot {
        width: 10px;
        height: 10px;
    }
    
    .carousel-nav {
        display: none; /* Hide arrows on very small screens */
    }
    
    .slide-cta {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .carousel-nav:hover,
    .carousel-dot:hover,
    .slide-cta:hover {
        transform: none;
    }
    
    .carousel-nav:active,
    .carousel-dot:active {
        transform: scale(0.95);
    }
}

/* Print styles */
@media print {
    .hero-carousel {
        height: auto;
        min-height: auto;
        page-break-inside: avoid;
    }
    
    .carousel-slide:not(.active) {
        display: none;
    }
    
    .carousel-controls,
    .carousel-nav {
        display: none;
    }
    
    .slide-content {
        color: black !important;
        text-shadow: none !important;
    }
}

/* Loading states */
.carousel-loading {
    position: relative;
}

.carousel-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: carousel-spin 1s linear infinite;
    z-index: 100;
}

@keyframes carousel-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Performance optimizations */
.hero-carousel * {
    /* Promote to GPU layer for smoother animations */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Content Security optimizations */
.slide-content img {
    max-width: 100%;
    height: auto;
    /* Prevent layout shift */
    aspect-ratio: attr(width) / attr(height);
}

/* Advanced background effects */
.carousel-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.1) 0%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
    z-index: 1;
    pointer-events: none;
}