/**
 * MG2025 Theme - Full Page Masonry Layout
 * Layout masonry con grid-sizer e gutter-sizer
 * Responsive: 1-6 colonne con gutter variabile
 */

/* ============================================
   FULL PAGE CONTAINER
   ============================================ */

.mg2025-full-page-layout {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000000 !important;
    color: #ffffff;
    min-height: 100vh;
}

.mg2025-full-page-layout .container,
.mg2025-full-page-layout .container-fluid {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ============================================
   MASONRY GRID CONTAINER
   ============================================ */

.mg-masonry-grid {
    position: relative;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background: #000000;
    
    /* USA FLEXBOX invece di Masonry */
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    
    /* Elimina completamente spazi e whitespace */
    line-height: 0 !important;
    font-size: 0 !important;
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
}

/* ============================================
   GRID SIZER & GUTTER SIZER
   ZERO GAP - Nessuno spazio tra le immagini
   ============================================ */

.grid-sizer,
.mg-card {
    /* Mobile: 1 colonna (<480px) - ZERO gap - USA flex-basis per Flexbox */
    width: 100%;
    flex: 0 0 100%;
}

/* Mobile: FORZA larghezza 100% senza max-width */
@media (max-width: 767px) {
    .grid-sizer,
    .mg-card,
    .pt,
    .mg2025-photo {
        width: 100% !important;
        max-width: none !important;
    }
    
    /* Immagini complete senza taglio */
    .mg-card-img {
        object-fit: contain !important;
        background-color: #000 !important;
    }
}

.gutter-sizer {
    width: 0 !important;
}

/* ============================================
   MG CARD - Item della gallery
   ============================================ */

.mg-card {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
    position: relative;
    overflow: hidden;
    display: block;
    box-sizing: border-box;
    line-height: 0;
    flex-shrink: 0 !important;
}

.mg-card-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    position: relative;
}

/* ============================================
   CARD IMAGE - No border-radius
   ============================================ */

.mg-card-img {
    /* Display block per eliminare whitespace */
    display: block !important;
    
    /* Full width, auto height */
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    
    /* Zero margins, padding, borders, border-radius */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    
    /* Object fit cover */
    object-fit: cover !important;
    
    /* Smooth lazy loading */
    opacity: 1;
    transition: opacity 0.3s ease;
    
    /* Elimina spazi sotto l'immagine */
    vertical-align: top;
}

/* Placeholder per lazy loading */
.mg-card-img[loading="lazy"]:not([src]) {
    opacity: 0;
    background: rgba(255, 255, 255, 0.05);
    min-height: 200px;
}

/* ============================================
   CARD OVERLAY - Hover effect
   ============================================ */

.mg-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 1;
}

.mg-card:hover .mg-card-overlay {
    opacity: 1;
}

.mg-card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 8px 0;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    display: block;
}

.mg-card-author {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    margin: 0;
    text-align: center;
    color: #ffffff;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    display: block;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   Larghezza .grid-sizer e .mg-card cambia
   ============================================ */

/* Tablet: 2 colonne (480-767px) - ZERO gap */
@media (min-width: 480px) and (max-width: 767px) {
    .grid-sizer,
    .mg-card {
        width: 50% !important;
        flex: 0 0 50% !important;
    }
    
    .gutter-sizer {
        width: 0 !important;
    }
}

/* Tablet Large: 3 colonne (768-1199px) - ZERO gap */
@media (min-width: 768px) and (max-width: 1199px) {
    .grid-sizer,
    .mg-card {
        width: 33.333% !important;
        flex: 0 0 33.333% !important;
    }
    
    .gutter-sizer {
        width: 0 !important;
    }
}

/* Desktop: 4 colonne (1200-1439px) - ZERO gap */
@media (min-width: 1200px) and (max-width: 1439px) {
    .grid-sizer,
    .mg-card {
        width: 25% !important;
        flex: 0 0 25% !important;
    }
    
    .gutter-sizer {
        width: 0 !important;
    }
}

/* Desktop Large: 5 colonne (1440-1599px) - ZERO gap */
@media (min-width: 1440px) and (max-width: 1599px) {
    .grid-sizer,
    .mg-card {
        width: 20% !important;
        flex: 0 0 20% !important;
    }
    
    .gutter-sizer {
        width: 0 !important;
    }
}

/* Desktop XL: 6 colonne (≥1600px) - ZERO gap */
@media (min-width: 1600px) {
    .grid-sizer,
    .mg-card {
        width: 16.666% !important;
        flex: 0 0 16.666% !important;
    }
    
    .gutter-sizer {
        width: 0 !important;
    }
}

/* ============================================
   COMPATIBILITÀ CON CLASSI ESISTENTI
   ============================================ */

/* Supporto per classi legacy .pt e .mg2025-photo */
.mg-masonry-grid .pt,
.mg-masonry-grid .mg2025-photo {
    /* Stessi stili di .mg-card */
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    position: relative;
    overflow: hidden;
    display: block;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.mg-masonry-grid .pt img,
.mg-masonry-grid .mg2025-photo img,
.mg-masonry-grid .mg2025-photo-img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    object-fit: cover !important;
    vertical-align: top;
}

/* ============================================
   UTILITIES
   ============================================ */

.mg2025-full-page-layout * {
    box-sizing: border-box !important;
}

/* Reset eventuali stili globali */
.mg-masonry-grid * {
    /* Previeni float che possono interferire */
    float: none;
}

/* Nasconde i sizer elements visivamente */
.grid-sizer,
.gutter-sizer {
    height: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}
