/* Responsive Styles */
@media (min-width: 769px) {
    body {
        overflow: hidden;
        min-height: 100vh;
    }

    .text-box, .text-box-content {
        overflow: hidden;
    }

    .text-box {
        right: -80vw;
        top: 50%;
        transform: translateY(-50%);
        width: 80vw;
        height: 100vh;
        left: auto;
        bottom: auto;
        overflow: visible;
        position: absolute;
        padding: 5vh 0;
    }

    .text-box.active {
        right: 0;
        transform: translateY(-50%);
    }

    .text-box-content {
        padding-right: 2vw;
    }

    .home-gallery {
        left: 20%;
        right: auto;
        justify-content: flex-start;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }

    .home-gallery-box {
        height: 75vh;
        max-width: calc(87vw - 13%);
        justify-content: flex-start;
    }

    .home-gallery-photo {
        height: 100vh;
    }

    .single-photo-container {
        left: 0%;
        right: auto;
        justify-content: flex-start;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }

    .single-photo-box {
        justify-content: flex-start;
    }

    .single-photo {
        margin-left: 0;
    }

    .grid-view {
        right: 0%;
        left: auto;
        width: 80vw;
        max-width: 80vw;
        height: 100vh;
    }

    .sqs-gallery-design-autocolumns {
        column-count: 4 !important;
        column-gap: 8px !important;
    }

    .grid-item {
        margin-bottom: 8px !important;
    }

    .footer-title {
        bottom: 89%;
        left: 2.5%;
    }

    .footer-subtitle {
        bottom: 87%;
        left: 3%;
    }

    .footer-menu {
        bottom: 67%;
        left: 3%;
    }

    .footer-menu-bottom {
        bottom: 47%;
        left: 3%;
    }

    .right-text-box {
        left: 13%;
        width: 18vw;
        max-height: 65vh;
    }

    .squares-container {
        font-size: 3.5vh;
        top: 3vh;
        right: 2%;
    }

    .mobile-footer-menu {
        display: none !important;
        position: absolute;
        top: 15dvh;
        left: 5%;
        flex-direction: column;
        gap: 0.5dvh;
        font-size: 2dvh;
        font-weight: 200;
        line-height: 1.3;
        align-items: flex-start;
    }

    .mobile-footer-menu a {
        display: none !important;
        color: #171717;
        text-decoration: none;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
    }

    .mobile-footer-menu-bottom {
        display: none !important;
        position: absolute;
        top: 15dvh;
        right: 5%;
        flex-direction: column;
        gap: 3dvh;
        align-items: flex-end;
    }

    .mobile-footer-menu-bottom .footer-menu-bottom-btn {
        display: none !important;
        background: none;
        border: none;
        color: #171717;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
        font-size: 2dvh;
        font-weight: 200;
        cursor: pointer;
        padding: 0;
        margin: 0;
        text-align: left;
    }

    .mobile-nav-close {
        display: none !important;
        position: absolute;
        top: 3dvh;
        right: 5%;
        font-size: 3dvh;
        line-height: 1;
        cursor: pointer;
        z-index: 10003;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
        font-weight: 300;
        width: 24px;
        text-align: center;
    }
    
    .home-gallery-container {
        transform: none;
        transform-origin: top left;
    }

    .nav-arrow,
    .home-nav-arrow {
        transform: scale(1.3);
        transform-origin: center center;
    }
    
    .footer-title,
    .footer-subtitle,
    .footer-menu,
    .footer-menu-bottom,
    .squares-container,
    .home-progress-bar,
    .about-panel,
    .right-text-box {
        position: fixed !important;
    }
    
    .filename-display {
        position: fixed !important;
        bottom: 3vh;
        right: 3vw;
        text-align: right;
        margin: 0;
        z-index: 100002;
    }

    .home-gallery-photo, 
    .single-photo {
        max-height: 95vh; 
    }

    .mobile-grid-close {
        display: none !important;
    }

    /* Allineamento Pannello About Desktop */
    .about-panel {
        justify-content: flex-start;
        padding-top: 1vh;
        padding-left: 4vw;
    }

    .about-content {
        align-items: flex-start;
    }

    .about-profile-image {
        margin-top: 1.8vh;
    }

    .about-panel p {
        margin-top: 1.3vh;
    }
    
    .layout-verticale .home-gallery-photo, 
    .layout-verticale .single-photo {
        height: 95vh;
        width: auto;
    }

    .layout-orizzontale .home-gallery-photo, 
    .layout-orizzontale .single-photo {
        height: 85vh !important;  
        max-width: 75vw; 
        width: auto;
        object-fit: contain;
    }
    .filename-display.desktop-vertical-caption {
        position: absolute !important;
        bottom: 0vh !important;               /* Allinea alla base dell'immagine (con un po' di margine) */
        left: calc(100% + 1.5vw) !important;  /* La posiziona subito fuori dal bordo destro dell'immagine */
        right: auto !important;               /* Rimuove il vincolo a destra del layout originale */
        text-align: left !important;          /* Giustifica il testo a sinistra */
        width: max-content !important;        
        max-width: 250px !important;          /* Evita che testi lunghi escano dallo schermo */
    }
}

@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .footer-title {
        font-size: 7dvh;
        bottom: auto;
        top: 5dvh;
        left: 5%;
        z-index: 100002;
    }

    .footer-subtitle {
        font-size: 2dvh;
        bottom: auto;
        top: 9dvh;
        left: 5%;
        z-index: 100002;
    }

    .footer-menu {
        bottom: auto;
        top: 15dvh;
        left: 5%;
        font-size: 2dvh;
        gap: 0.5dvh;
    }

    .footer-menu-bottom {
        bottom: auto;
        top: 15dvh;
        left: auto;
        right: 5%;
        gap: 3dvh;
        align-items: flex-end; 
    }

    .footer-menu-bottom-btn {
        text-align: right;
        font-size: 2dvh;
    }

    .home-gallery, .single-photo-container {
        display: block !important;
        position: fixed !important; 
        top: 58dvh !important;
        bottom: 0 !important;
        height: 100dvh !important;
        left: 0;   
        right: 0;  
        width: 100%;
        padding: 5dvh 5vw;
        box-sizing: border-box;
        overflow-y: auto; 
        overflow-x: hidden;
        z-index: 10;
    }

    .home-gallery-box,
    .single-photo-box {
        top: 0; 
        width: 90vw; 
        max-width: none;
        height: auto;
    }

    .image-container {
        width: 100%;
        display: block;
    }

    .home-gallery-photo, .single-photo {
        width: 100%; 
        height: auto; 
        max-height: none !important; 
        margin: 0;
        display: block; 
    }

    .text-box {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100dvh;
        padding: 0;
        background: #ececec;
        transform: none !important;
        opacity: 0;
        visibility: hidden;
        z-index: 200;
        transition: opacity 0.3s ease;
    }

    .text-box.active {
        transform: none !important;
        opacity: 1;
        visibility: visible;
    }

    .right-text-box {
        bottom: 5dvh;
        max-height: 30dvh;
        padding: 2dvh 3vw;
    }

    .grid-view {
        top: 2dvh;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100dvh;
        max-width: none;
        background: #ececec;
        z-index: 10003;
        padding: 5dvh 5vw 15dvh 5vw;
        transform: translateY(100%) scale(1);
    }
    
    .grid-view.active {
        transform: translateY(0) scale(1);
    }

    .sqs-gallery-design-autocolumns {
        display: block !important;
        column-count: 2 !important;
        column-gap: 12px !important;
    }

    .grid-item {
        margin-bottom: 12px !important;
        width: 100%;
        display: inline-block;
    }

    .grid-photo {
        touch-action: pan-y;
    }

    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 3dvh;
        right: 5%;
        width: 24px;
        height: 18px;
        flex-direction: column;
        justify-content: space-between;
        cursor: pointer;
        z-index: 100002;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 2px;
        background: #171717;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
    }

    .mobile-menu-toggle.open span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    
    .mobile-menu-toggle.open span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0); 
    }
    
    .mobile-menu-toggle.open span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .mobile-nav-panel {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 30dvh;
        max-height: 48dvh;
        background: #ececec;
        z-index: 10003;
        transform: translateY(-100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mobile-nav-panel.active {
        transform: translateY(0);
    }

    .mobile-nav-close {
        display: none;
        position: absolute;
        top: 3dvh;
        right: 5%;
        font-size: 3dvh;
        line-height: 1;
        cursor: pointer;
        z-index: 10004;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
        font-weight: 300;
        width: 24px;
        text-align: center;
    }

    .mobile-nav-content {
        position: relative;
        width: 100%;
        height: 100%;
    }

    .mobile-footer-menu {
        display: flex;
        position: absolute;
        top: 10dvh;
        left: 5%;
        flex-direction: column;
        gap: 0.5dvh;
        font-size: 2.3dvh;
        font-weight: 200;
        line-height: 1.3;
        align-items: flex-start;
    }

    .mobile-footer-menu a {
        color: #171717;
        text-decoration: none;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
    }

    .mobile-footer-menu-bottom {
        display: flex;
        position: absolute;
        top: 10dvh;
        right: 5%;
        flex-direction: column;
        gap: 1.5dvh;
        align-items: flex-end;
    }

    .mobile-footer-menu-bottom .footer-menu-bottom-btn {
        background: none;
        border: none;
        color: #171717;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
        font-size: 2.3dvh;
        font-weight: 200;
        cursor: pointer;
        padding: 0;
        margin: 0;
        text-align: left;
    }

    .footer-menu,
    .footer-menu-bottom {
        display: none !important;
    }
    
    .home-progress-bar {
        position: absolute;
        bottom: 4.5%;
        left: 0;
        width: 100%;
        height: 4px;
        background: transparent;
        z-index: 10;
        margin-top: 2px;
    } 
    
    .about-panel {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100dvh; 
        background: #ececec;
        z-index: 100002;
        padding: 15dvh 5vw 5dvh 5vw; 
        justify-content: flex-start; 
        overflow-y: auto; 
    }

    .about-content {
        display: flex;
        flex-direction: column; 
        align-items: flex-start;
    }

    .about-profile-image {
        width: 100%;
        max-height: 60dvh;
        object-fit: cover;
        margin-bottom: 3dvh; 
        border-radius: 4px;
    }

    .about-panel p {
        font-size: 2.3dvh; 
        line-height: 1.5;
        margin-right: 0; 
    }
    
    /* Disattiva l'impostazione "margin-right: 30vw" (pensata per desktop) su mobile */
    .text-content-wrapper {
        margin-right: 0;
    }

    .filename-display {
        position: relative !important; 
        bottom: auto !important;
        left: 0 !important; 
        margin-top: 2vh; 
        margin-left: 0 !important; 
        font-size: 2.3dvh; 
        max-width: 100%;
        text-align: left !important; 
        opacity: 1 !important; 
        visibility: visible !important;
        pointer-events: none;
        padding-bottom: 5vh; 
    }

    .back-button {
        top: 1.5dvh;
        left: 4%;
        font-size: 1.8dvh;
        padding: 1dvh;
    }

    .squares-container {
        top: 3dvh;
        bottom: auto;
        left: auto;
        right: 12%;
        transform: none;
        font-size: 3dvh;
        z-index: 100002; 
    }

    body.grid-active .squares-container {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    body.grid-active .footer-title,
    body.grid-active .footer-subtitle,
    body.grid-active .footer-menu,
    body.grid-active .footer-menu-bottom {
        z-index: 10 !important; 
    }

    body.grid-active .home-gallery,
    body.grid-active .single-photo-container,
    body.grid-active .text-box.active {
        opacity: 1 !important;
        visibility: visible !important;
    }
.mobile-grid-close {
        display: none;
        position: fixed;
        top: 3dvh;      /* Esattamente la stessa altezza del panino */
        right: 5%;      /* Esattamente lo stesso margine destro */
        width: 24px;    /* Stessa larghezza del panino */
        height: 18px;   /* Stessa altezza del panino */
        cursor: pointer;
        z-index: 100005;
        color: transparent; /* Nasconde il carattere &times; scritto in HTML */
        font-size: 0;       
    }

    /* Disegniamo le due righe identiche a quelle del menu aperto */
    .mobile-grid-close::before,
    .mobile-grid-close::after {
        content: '';
        position: absolute;
        left: 0;
        top: 8px;       /* Centrate verticalmente (18px / 2 = 9px - 1px di metà spessore) */
        width: 100%;
        height: 2px;    /* Stesso spessore delle linee del panino */
        background: #171717; /* Stesso colore */
    }

    /* Le incliniamo esattamente a 45 gradi come fa l'animazione del panino */
    .mobile-grid-close::before {
        transform: rotate(45deg);
    }

    .mobile-grid-close::after {
        transform: rotate(-45deg);
    }

    body.grid-active .mobile-grid-close {
        display: block;
    }

    body.grid-active .squares-container {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .footer-title {
        font-size: 6dvh;
        top: 2dvh;
        bottom: auto;
    }

    .footer-subtitle {
        font-size: 1.8dvh;
        top: 7.8dvh;
        bottom: auto;
    }

    .footer-menu {
        top: 13dvh;
        bottom: auto;
        font-size: 1.8dvh;
    }
    
    .footer-menu-bottom {
        top: 13dvh; 
        bottom: auto;
        left: auto;
        right: 5%;
    }

    .home-gallery-box,
    .single-photo-box {
        top: 0;
        width: 90vw; 
        max-width: none;
        height: auto;
    }

    .image-container {
        width: 100%;
    }

    .home-gallery-photo,
    .single-photo {
        width: 100%;
        height: auto;
        max-height: none;
    }

    .grid-view {
        width: 100vw; 
        right: 0;
        z-index: 100003;
    }

    .sqs-gallery-design-autocolumns {
        display: block !important;
        column-count: 2 !important;
        column-gap: 10px !important;
    }

    .grid-item {
        margin-bottom: 10px !important;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .home-gallery-box,
    .single-photo-box {
        height: 70dvh;
    }

    .home-gallery-photo,
    .single-photo {
        height: 70dvh;
    }

    .sqs-gallery-design-autocolumns {
        column-count: 3 !important;
    }

    /* Exhibitions sidebar: titoli allineati con il footer menu */
    .exhibitions-sidebar {
        padding-top: 30vh;
        justify-content: flex-start;
    }
/* Allinea il logo Instagram nel menu mobile sotto la voce contact */
    .instagram-mobile-btn {
        display: inline-flex;
        justify-content: flex-end;
        align-items: center;
        margin-top: 1dvh; /* Dona un po' di respiro rispetto a "contact" */
        width: 100%;
        color: #171717; /* Mantiene lo stesso colore del tema */
    }

    /* Aumentiamo leggermente le dimensioni dell'icona per favorire il tocco su schermi touch */
    .instagram-mobile-btn svg {
        width: 22px; 
        height: 22px;
        transition: stroke 0.3s ease;
    }

    /* Hover per i dispositivi mobili che lo supportano o al momento del tocco */
    .instagram-mobile-btn:active svg,
    .instagram-mobile-btn:hover svg {
        stroke: #777;
    }
}

.home-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 4px;
    background: transparent;
    z-index: 1000;
    margin: 0;
}

.home-progress-fill {
    height: 100%;
    width: 0%;
    background: #171717;
}

/* === EXHIBITIONS RESPONSIVE === */
@media (max-width: 768px) {
    #exhibitions-panel.about-panel {
        padding: 0;
        overflow-y: auto;
    }

    .exhibitions-layout {
        flex-direction: column;
    }

    .exhibitions-sidebar {
        width: 100%;
        max-width: none;
        min-width: auto;
        border-right: none;
        border-bottom: none;
        padding: 12dvh 5vw 8dvh 5vw;
        max-height: none;
        flex-shrink: 0;
        overflow-y: visible;
    }

    .exhibitions-sidebar-label {
        font-size: 2.8dvh;
        font-weight: 300;
        margin-bottom: 4dvh;
        text-transform: lowercase;
    }

    .exhibitions-titles-list {
        gap: 0;
    }

    .exhibition-title-item {
        font-size: 2.5dvh;
        font-weight: 200;
        padding: 2dvh 0;
        border-bottom: none;
        cursor: pointer;
        transition: opacity 0.2s;
    }

    .exhibition-title-item:hover {
        opacity: 0.6;
    }

    .exhibition-title-item.active {
        font-weight: 400;
        opacity: 1;
    }

    /* Nascondi lo stage desktop su mobile */
    .exhibitions-stage {
        display: none !important;
    }

    /* Contenuto mobile accordion */
    .exhibit-mobile-content {
        margin: 2dvh 0 5dvh;
        animation: fadeInExhibit 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes fadeInExhibit {
        from { opacity: 0; transform: translateY(12px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .exhibit-mobile-media-wrapper {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #171717;
        border-radius: 4px;
        overflow: hidden;
    }

    .exhibit-mobile-media-wrapper img,
    .exhibit-mobile-media-wrapper video {
        max-width: 100%;
        max-height: 45dvh;
        width: auto;
        height: auto;
        object-fit: contain;
        display: block;
    }

    .exhibit-mobile-skip {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin-top: 2dvh;
        padding: 0;
        background: none;
        border: none;
        color: #171717;
        font-family: 'IBM Plex Sans Condensed', sans-serif;
        font-size: 2dvh;
        font-weight: 200;
        cursor: pointer;
        text-transform: lowercase;
    }

    .exhibit-mobile-skip:hover {
        opacity: 0.6;
    }

    .exhibit-mobile-skip svg {
        width: 2dvh;
        height: 2dvh;
    }

    .exhibit-mobile-caption {
        margin-top: 2dvh;
        font-size: 2dvh;
        font-weight: 200;
        line-height: 1.5;
        color: #171717;
    }

    .exhibit-mobile-caption:empty {
        display: none;
    }
}