/* Menu Gallery System with Italian Flag Border Styling */

/* Italian Flag Gradient Definition */
:root {
    --italian-flag-gradient: linear-gradient(90deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%);
    --italian-flag-gradient-vertical: linear-gradient(180deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%);
    --section-spacing: 20px;
    --item-spacing: 20px;
}

/* Unified Menu Grid - Same layout for all categories */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 20px;
    width: 100%;
    max-width: 100%;
    justify-content: center;
    min-width: 0;
    box-sizing: border-box;
}

/* Mobile fix for menu-grid alignment */
@media (max-width: 1200px) {
    .menu-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        justify-content: center;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }

    .menu-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .menu-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .menu-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
        min-width: 0;
    }
}

/* Category Gallery - Reusing Homepage Gallery Logic with 16:9 Landscape */
.category-gallery-wrapper {
    width: 100%;
    margin-top: var(--section-spacing);
    margin-bottom: var(--section-spacing);
    position: relative;
    overflow: hidden;
    clear: both;
    box-sizing: border-box;
}

.category-gallery-viewport {
    width: 140px !important;
    height: 90px !important;
    max-width: 140px !important;
    max-height: 90px !important;
    overflow: hidden !important;
    position: relative !important;
    border: 3px solid transparent;
    border-image: linear-gradient(90deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%) 1;
    border-image-slice: 1;
    border-radius: 0;
    background: linear-gradient(90deg, #008c45 0%, #f4f5f0 50%, #cd212a 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.3s ease;
    box-sizing: border-box;
    margin: 0 auto;
}

.category-gallery-viewport:hover {
    box-shadow: 0 8px 24px rgba(0, 146, 70, 0.4);
}

/* Category Gallery Slide - Using homepage fade transition approach */
.category-slide {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    transition: opacity 0.5s ease-in-out;
    z-index: 1 !important;
    visibility: hidden !important;
    background: transparent !important;
    border-radius: 0;
}

.category-slide.active {
    opacity: 1 !important;
    z-index: 2 !important;
    visibility: visible !important;
}

.category-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    background: transparent !important;
    cursor: pointer;
}

/* Menu Item Layout */
.menu-item-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Menu Item Image Display */
.menu-item-image-slot {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-item-image-border {
    display: flex;
    padding: 3px;
    border-radius: 12px;
    background: var(--italian-flag-gradient);
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.menu-item-image-border:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 146, 70, 0.4);
}

.menu-item-image-wrapper {
    width: 100%;
    background: #111;
    border-radius: 9px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.menu-item-image {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
}

.menu-item-image-border:hover .menu-item-image {
    transform: scale(1.05);
}

/* Carousel Styles */
.menu-item-carousel {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.menu-item-slide {
    grid-area: 1 / 1;
    width: 100%;
    height: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item-slide.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

@media (min-width: 1401px) {
    .menu-item-image-border {
        max-width: 50%;
    }
}


/* Responsive Design */
@media (max-width: 1200px) {
    :root {
        --section-spacing: 16px;
        --item-spacing: 16px;
    }

    .menu-item-layout {
        gap: 16px;
        padding: 16px;
    }

    .menu-item-image-border {
        max-width: 140px;
    }
}

@media (max-width: 768px) {
    :root {
        --section-spacing: 14px;
        --item-spacing: 14px;
    }

    .menu-item-layout {
        gap: 14px;
        padding: 14px;
    }

    .menu-item-image-border {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    :root {
        --section-spacing: 12px;
        --item-spacing: 12px;
    }

    .menu-grid {
        gap: 12px;
    }

    .menu-item-layout {
        gap: 10px;
        padding: 10px;
    }

    .menu-item-image-border {
        max-width: 100%;
        width: 100%;
    }

    .menu-item-image-wrapper {
        width: 100%;
    }
}


/* Lightbox Styles */
.gallery-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.gallery-lightbox.show {
    display: block;
}

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: 0 auto;
    top: 50%;
    transform: translateY(-50%);
    position: relative;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: block;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 10;
}

.lightbox-close:hover {
    color: var(--accent-red, #CE2B37);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 48px;
    cursor: pointer;
    padding: 20px;
    transition: background 0.2s ease;
    border-radius: 50%;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: -60px;
}

.lightbox-next {
    right: -60px;
}

.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    font-weight: 500;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Touch swipe indicators */
.swipe-indicator {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    .swipe-indicator {
        display: block;
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 12px;
        pointer-events: none;
    }
}
