/* ===============================================
   GALLERIA D'ARTE - FRONTEND LAYOUT STYLES
   Layout single-opera, sidebar, responsive
   =============================================== */

/* ===========================================
   LAYOUT SINGLE OPERA CON SIDEBAR
   ========================================== */

.ga-opera-layout {
    max-width: var(--gf-container-max-width);
    margin: 150px auto 0 auto; /* Aggiunto margine superiore per compensare menu fisso */
    padding: 0 var(--gf-container-margin);
}

.ga-opera-sidebar {
    flex: 0 0 320px;
    position: sticky;
    top: 120px; /* Aumentato per compensare menu più alto */
    background: var(--gf-bg-white);
    border-radius: var(--gf-radius-xl);
    box-shadow: var(--gf-shadow-md);
    border: 1px solid var(--gf-border-color);
    overflow: hidden;
    z-index: 10; /* Sopra altri contenuti ma sotto menu */
    align-self: flex-start;
}

.ga-opera-main {
    min-width: 0;
}

/* Allinea la scheda opera con la sidebar */
.ga-opera-scheda {
    margin-top: 0 !important; /* Rimuovi margin-top per allineare */
}


/* Allinea header autore con sidebar */
.ga-opera-layout .ga-autore-header,
body.admin-bar .ga-opera-layout .ga-autore-header {
    margin-top: 0 !important;
}

/* Widget styling nella sidebar */
.ga-opera-sidebar .widget {
    border-bottom: 1px solid var(--gf-border-color);
    padding: 24px;
}

.ga-opera-sidebar .widget:last-child {
    border-bottom: none;
}

.ga-opera-sidebar .widget-title {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--gf-text-primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gf-primary-color);
}

.ga-opera-sidebar .widget p,
.ga-opera-sidebar .widget ul,
.ga-opera-sidebar .widget ol {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gf-text-secondary);
}

.ga-opera-sidebar .widget ul,
.ga-opera-sidebar .widget ol {
    padding-left: 20px;
}

.ga-opera-sidebar .widget li {
    margin-bottom: 6px;
}

.ga-opera-sidebar .widget a {
    color: var(--gf-primary-color);
    text-decoration: none;
    transition: var(--gf-transition);
}

.ga-opera-sidebar .widget a:hover {
    color: var(--gf-primary-hover);
    text-decoration: underline;
}

/* Fix per admin bar */
body.admin-bar .ga-opera-layout {
    margin-top: 150px !important;
}

body.admin-bar .ga-opera-sidebar {
    top: 150px !important;
}

/* ===========================================
   FIX HEADER OPERE SINGOLE
   ========================================== */

/* Container principale per pagine opera singole */
.single-opera .ga-opera-scheda,
.ga-opera-scheda {
    position: relative;
    z-index: 1;
}

/* Header opera con margin adeguato */
.ga-opera-header {
    margin-top: 0 !important;
    position: relative;
    z-index: 2;
}

/* Titolo opera con margin corretto */
.ga-opera-titolo {
    margin-top: 0 !important;
    position: relative;
    z-index: 2;
}

/* ===========================================
   RESPONSIVE LAYOUT
   ========================================== */

/* Responsive sidebar */
@media (max-width: 1024px) {
    .ga-opera-layout {
        gap: 30px;
        margin-top: 150px;
    }
    
    .ga-opera-sidebar {
        flex: 0 0 280px;
        top: 80px;
    }
}

@media (max-width: 768px) {
    .ga-opera-layout {
        flex-direction: column;
        gap: 20px;
        margin-top: 150px;
    }
    
    .ga-opera-sidebar {
        order: 2;
        position: static;
        flex: none;
    }
    
    .ga-opera-main {
        order: 1;
    }
    
    /* Responsive fixes per opere singole */
    .single-opera .ga-opera-scheda,
    .ga-opera-scheda {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .ga-opera-layout {
        padding: 15px;
        margin-top: 150px;
    }
    
    .ga-opera-sidebar .widget {
        padding: 16px;
    }
    
    .ga-opera-sidebar .widget-title {
        font-size: 14px;
    }
    
    /* Responsive fixes per opere singole mobile */
    .single-opera .ga-opera-scheda,
    .ga-opera-scheda {
        padding: 15px;
    }
}

/* ===========================================
   GENERIC ELEMENTS
   ========================================== */
.ga-page-title {
    font-size: 70px;
    letter-spacing: -3px;
    color: var(--gf-primary-color);
    margin-top: 40px;
}



/* ===========================================
   GESTIONE RESPONSIVE GENERALE
   ========================================== */

/* Gestione responsive generale per l'accordion */
@media (max-width: 768px) {
    /* Ricalcola altezze su resize per accordion */
    .ga-accordion-content.expanded {
        transition: max-height 0.3s ease-out;
    }

    .ga-page-title {
        font-size: 60px;
        margin-top: 30px;
    }
}

/* Debounce per resize */
@media (max-width: 480px) {
    /* Ottimizzazioni specifiche per mobile molto piccolo */
    .ga-accordion-content {
        transition: max-height 0.2s ease-out;
    }

    .ga-page-title {
        font-size: 50px;
        margin-top: 20px;
    }
}

/* ===========================================
   PRINT STYLES LAYOUT
   ========================================== */

@media print {
    .ga-opera-layout {
        flex-direction: column;
        margin-top: 0 !important;
    }
    
    .ga-opera-sidebar {
        position: static !important;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .ga-opera-scheda,
    .single-opera .ga-opera-scheda {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    
    .ga-opera-layout {
        padding: 0;
    }
    
    .ga-opera-sidebar .widget {
        padding: 15px;
        border-bottom: 1px solid #ccc;
    }
    
    .ga-opera-sidebar .widget-title {
        font-size: 12pt;
        border-bottom: 1px solid #ccc;
    }
}

/* ===========================================
   UTILITY CLASSES LAYOUT
   ========================================== */

/* Classe per nascondere elementi su mobile */
.ga-hide-mobile {
    display: block;
}

@media (max-width: 768px) {
    .ga-hide-mobile {
        display: none;
    }
}

/* Classe per mostrare elementi solo su mobile */
.ga-show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .ga-show-mobile {
        display: block;
    }
}

/* Classe per centrare contenuti */
.ga-center {
    text-align: center;
}

/* Classe per allineamento verticale */
.ga-vertical-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===========================================
   OTTIMIZZAZIONI PERFORMANCE LAYOUT
   ========================================== */

/* Ottimizzazioni per scroll e performance */
.ga-opera-sidebar {
    will-change: transform;
    backface-visibility: hidden;
}

/* Prevenzione layout shift */
.ga-opera-layout {
    contain: layout style;
}

/* Smooth scrolling per anchor link */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ===========================================
   ACCESSIBILITY MIGLIORAMENTI LAYOUT
   ========================================== */

/* Focus management per elementi sticky */
.ga-opera-sidebar:focus-within {
    outline: 2px solid var(--gf-primary-color);
    outline-offset: 2px;
}

/* Skip to content per layout complessi */
.ga-skip-to-content {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--gf-primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: var(--gf-radius-sm);
    z-index: 10000;
    transition: top 0.3s;
}

.ga-skip-to-content:focus {
    top: 6px;
}

/* Screen reader only per layout */
.ga-sr-only-layout {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===========================================
   COMPATIBILITÀ BROWSER LAYOUT
   ========================================== */

/* Fallback per browser che non supportano sticky */
@supports not (position: sticky) {
    .ga-opera-sidebar {
        position: relative;
        top: auto;
    }
}

/* Fallback per browser che non supportano CSS Grid */
@supports not (display: grid) {
    .ga-opera-layout {
        display: block;
    }
    
    .ga-opera-sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .ga-opera-main {
        width: 100%;
    }
}

/* Supporto per browser legacy */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    /* Internet Explorer 10+ */
    .ga-opera-layout {
        display: -ms-flexbox;
        -ms-flex-direction: row;
        -ms-flex-align: start;
    }
    
    .ga-opera-sidebar {
        -ms-flex: 0 0 320px;
    }
    
    .ga-opera-main {
        -ms-flex: 1;
    }
}