/**
 * Carosello Foto Cantante - CSS Corretto
 * File: assets/css/carousel.css
 */

/* Reset e base styles */
.photo-carousel-container * {
    box-sizing: border-box;
}

.photo-carousel-container {
    position: relative;
    margin: 2em 0;
    width: 100%;
}

.carousel-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

/* Carousel container - ALTEZZA FISSA */
.carousel-container {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 480px; /* Altezza fissa corrispondente agli item */
}

/* Carousel track - FLEX CORRETTO */
.carousel-track,
[data-carousel-track] {
    display: flex;
    gap: 20px;
    height: 100%;
    transition: transform 0.3s ease;
    cursor: grab;
    will-change: transform;
    padding: 0 20px; /* Padding per vedere le immagini ai lati */
}

.carousel-track:active,
[data-carousel-track]:active {
    cursor: grabbing;
}

/* Carousel items - ALTEZZA FISSA PER TUTTE LE FOTO */
.carousel-item {
    flex: 0 0 auto;
    height: 480px !important; /* Altezza fissa per tutte le foto */
    max-width: 600px; /* Aumentato per foto panoramiche */
    min-width: 200px; /* Minimo per foto verticali */
    position: relative;
    overflow: hidden;
    border-radius: 0px; /* BORDI TONDI RIMOSSI */
    cursor: pointer;
    transition: transform 0.3s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222; /* Sfondo scuro per le foto */
}

.carousel-item:hover {
    transform: translateY(-10px);
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover !important; /* Sempre cover per riempire il container */
    filter: grayscale(100%) !important; /* Forzato con !important */
    transition: filter 0.3s ease !important;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    pointer-events: none; /* Previene conflitti con il drag */
}

/* Hover effect con maggiore specificità */
.carousel-item:hover img,
.carousel-item img:hover {
    filter: grayscale(0%) !important;
}

/* Fallback per browser che non supportano object-fit */
.carousel-item img {
    -o-object-fit: cover;
    -webkit-object-fit: cover;
    -moz-object-fit: cover;
    -ms-object-fit: cover;
}

.carousel-item:hover img {
    filter: grayscale(0%);
}

/* Scrollbar - COLORI PERSONALIZZABILI */
.carousel-scrollbar,
[data-scrollbar] {
    margin-top: 20px;
    height: 4px;
    background: #8278B7; /* 🎨 COLORE SFONDO SCROLLBAR - Cambia qui */
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    width: 100%;
}

.scrollbar-thumb,
[data-scrollbar-thumb] {
    height: 100%;
    background: #D5AC4E; /* 🎨 COLORE THUMB SCROLLBAR - Cambia qui */
    border-radius: 3px;
    position: absolute;
    top: 0;
    left: 0;
    transition: left 0.1s ease;
    cursor: grab;
    min-width: 20px;
}

.scrollbar-thumb:active,
[data-scrollbar-thumb]:active {
    cursor: grabbing;
}

.scrollbar-thumb:hover,
[data-scrollbar-thumb]:hover {
    background: #D5AC4E; /* 🎨 COLORE THUMB HOVER - Cambia qui */
}

/* Fullscreen Gallery - STILI CORRETTI */
.fullscreen-gallery {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

.fullscreen-gallery.active {
    display: flex;
}

.fullscreen-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.fullscreen-image {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: opacity 0.3s ease;
}

.fullscreen-image.loading {
    opacity: 0.7;
}

/* Fullscreen navigation - POSIZIONAMENTO CORRETTO */
.fullscreen-nav,
.fullscreen-close {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    user-select: none;
    z-index: 100000;
}

.fullscreen-nav:hover,
.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.fullscreen-nav:active,
.fullscreen-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.fullscreen-prev {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

.fullscreen-next {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.fullscreen-close {
    top: 20px;
    right: 20px;
    font-size: 20px;
}

/* Counter fullscreen */
.fullscreen-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    font-weight: 500;
    z-index: 100000;
}

/* Badge HD */
.hd-badge {
    position: absolute;
    top: 60px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    opacity: 0.7;
    display: none;
    z-index: 100000;
    transition: opacity 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .carousel-container {
        height: 400px; /* Altezza fissa per mobile */
    }
    
    .carousel-item {
        height: 400px !important; /* Altezza fissa anche per mobile */
        max-width: 500px;
        min-width: 150px;
    }

    .carousel-track,
    [data-carousel-track] {
        gap: 15px;
        padding: 0 15px;
    }

    .fullscreen-nav,
    .fullscreen-close {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .fullscreen-prev {
        left: 10px;
    }
    
    .fullscreen-next {
        right: 10px;
    }
    
    .fullscreen-close {
        top: 10px;
        right: 10px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .carousel-container {
        height: 320px; /* Altezza fissa per piccoli schermi */
    }
    
    .carousel-item {
        height: 320px !important; /* Altezza fissa anche per piccoli schermi */
        max-width: 400px;
        min-width: 120px;
    }
    
    .carousel-track,
    [data-carousel-track] {
        gap: 10px;
        padding: 0 10px;
    }
}

/* Loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.carousel-item img[src=""] {
    background: #f0f0f0;
    animation: pulse 1.5s infinite;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .carousel-track,
    [data-carousel-track],
    .carousel-item,
    .fullscreen-image,
    .fullscreen-nav {
        transition: none;
    }
    
    .carousel-item:hover {
        transform: none;
    }
}

/* Focus styles per accessibilità */
.fullscreen-nav:focus,
.fullscreen-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* WordPress integration */
.wp-block-theme-singer-carousel {
    margin: 0;
}

/* Debug styles - rimuovi in produzione */
.carousel-container {
    /* border: 1px solid #ddd; Rimosso per produzione */
}

.carousel-track[data-carousel-track] {
    /* background: rgba(255, 0, 0, 0.1); Rimosso per produzione */
}

/* Print styles */
@media print {
    .fullscreen-gallery {
        display: none !important;
    }
    
    .carousel-item img {
        filter: none !important;
    }
    
    .carousel-scrollbar,
    [data-scrollbar] {
        display: none;
    }
}