/*
 * Adeguamenti del tema originale al sito PHP autonomo.
 * Colori, impaginazione e tipografia rimangono nei fogli CSS originali.
 */

[hidden] {
    display: none !important;
}

html {
    scroll-padding-top: 118px;
}

/* Il tema WordPress calcolava queste altezze tramite JavaScript. */
body.et_fixed_nav #main-header {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    width: 100%;
    height: 108px;
    transition: height 0.25s ease, box-shadow 0.25s ease;
}

body #page-container {
    padding-top: 108px !important;
}

#main-header > .et_menu_container,
#main-header .logo_container {
    height: 100%;
}

#main-header #et-top-navigation {
    display: flex;
    align-items: center;
    height: 100%;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#main-header #top-menu > li > a {
    padding-bottom: 0 !important;
}

#main-header #logo {
    width: auto;
    height: auto;
    max-height: 86%;
}

body.et_fixed_nav #main-header.et-fixed-header {
    height: 54px;
}

#mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 6px;
    margin: 0;
    border: 0;
    background: transparent;
    color: #512e71;
    cursor: pointer;
}

#mobile-menu-toggle .mobile_menu_bar {
    position: relative;
    display: block;
    width: 28px;
    height: 22px;
    padding: 0 !important;
    background:
        linear-gradient(currentColor, currentColor) left top / 100% 2px no-repeat,
        linear-gradient(currentColor, currentColor) left center / 100% 2px no-repeat,
        linear-gradient(currentColor, currentColor) left bottom / 100% 2px no-repeat;
}

#mobile-menu-toggle .mobile_menu_bar::before,
#mobile-menu-toggle .mobile_menu_bar::after {
    display: none !important;
}

#mobile_menu {
    top: 100%;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

#mobile_menu[data-open="true"] {
    display: block;
    animation: sanmarco-menu-down 360ms cubic-bezier(0.22, 0.61, 0.36, 1);
    transform-origin: top center;
}

/* Il menu si scopre dall'alto verso il basso senza deformare le voci. */
@keyframes sanmarco-menu-down {
    from {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        clip-path: inset(0);
        transform: translateY(0);
    }
}

#mobile_menu a:focus-visible,
#mobile-menu-toggle:focus-visible,
#back-to-top:focus-visible,
.sanmarco-lightbox button:focus-visible,
.et_pb_contact_form input:focus-visible,
.et_pb_contact_form textarea:focus-visible,
.et_pb_contact_form button:focus-visible,
.et_pb_gallery_image a:focus-visible {
    outline: 3px solid #8761aa;
    outline-offset: 4px;
}

/* Le singole slide e le foto restano visibili senza il runtime di Divi. */
.et_pb_slider .et_pb_slide:first-child,
.et_pb_slider .et-pb-active-slide,
.et_pb_gallery .et_pb_gallery_item {
    display: block;
}

.et_pb_slide_description,
.et_animated,
.et-waypoint {
    animation: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.et_pb_slide_description {
    transform: none !important;
}

.et_parallax_bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.et_parallax_bg.et_pb_parallax_css {
    background-attachment: fixed;
}

/* La checkbox usa il controllo nativo, accessibile e validabile dal browser. */
.et_pb_contact_form .et_pb_contact_field input[type="checkbox"] {
    position: static !important;
    display: inline-block !important;
    appearance: auto;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0 8px 0 0;
    opacity: 1 !important;
    visibility: visible !important;
    clip: auto;
    clip-path: none;
    accent-color: #512e71;
    vertical-align: middle;
}

.et_pb_contact_form .et_pb_contact_field_checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.et_pb_contact_form .et_pb_contact_field_checkbox input[type="checkbox"] {
    margin-top: 3px;
}

.et_pb_contact_form .et_pb_contact_field_checkbox label {
    display: inline;
    margin: 0;
    padding-left: 0;
    cursor: pointer;
}

.et_pb_contact_form .et_pb_contact_field_checkbox label i {
    display: none !important;
}

.sanmarco-form-status {
    clear: both;
    margin: 0 0 24px 3%;
    padding: 16px 20px;
    border-left: 3px solid #512e71;
    background: #f5f2f8;
    color: #333;
    font-size: 16px;
    line-height: 1.6;
}

/* Il campo antispam non fa parte dei controlli compilabili dal visitatore. */
.contact-honeypot {
    display: none !important;
}

.contact-feedback:empty {
    display: none;
}

.contact-feedback:not(:empty) {
    clear: both;
    margin: 0 0 24px 3%;
    padding: 16px 20px;
    border-left: 3px solid #512e71;
    background: #f5f2f8;
    color: #333;
    font-size: 16px;
    line-height: 1.6;
}

/* Pulsante di chiamata mobile, indipendente dal plugin WordPress. */
#callnowbutton {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100000;
    display: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #008a00;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 40px 40px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

#callnowbutton span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

#callnowbutton:focus-visible {
    outline: 3px solid #512e71;
    outline-offset: 4px;
}

/* Il pulsante segue il comportamento del ritorno in alto del sito originale. */
#back-to-top {
    position: fixed;
    right: 0;
    bottom: 125px;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 5px 0 0 5px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

/* Galleria a schermo intero: nessuna richiesta al vecchio sito. */
body.sanmarco-lightbox-open {
    overflow: hidden;
}

.sanmarco-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: none;
    box-sizing: border-box;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 65px 85px 35px;
    border: 0;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    overflow: hidden;
}

.sanmarco-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sanmarco-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.sanmarco-lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    max-height: 100%;
    margin: 0;
    pointer-events: none;
}

.sanmarco-lightbox-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: calc(100vh - 165px);
    max-height: calc(100dvh - 165px);
    object-fit: contain;
    pointer-events: auto;
}

.sanmarco-lightbox-caption {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    margin-top: 15px;
    color: #eee;
    font-size: 14px;
    line-height: 1.5;
}

.sanmarco-lightbox-counter {
    white-space: nowrap;
}

.sanmarco-lightbox button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 56px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 52px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
}

.sanmarco-lightbox button:hover {
    opacity: 1;
}

.sanmarco-lightbox .sanmarco-lightbox-close {
    top: 10px;
    right: 20px;
    font-size: 38px;
}

.sanmarco-lightbox-previous {
    top: calc(50% - 28px);
    left: 15px;
}

.sanmarco-lightbox-next {
    top: calc(50% - 28px);
    right: 15px;
}

@media (min-width: 1091px) {
    #main-header #et-top-navigation {
        padding-right: 40px;
    }

    #main-header #et_mobile_nav_menu {
        display: none;
    }
}

@media (max-width: 1090px) {
    html {
        scroll-padding-top: 90px;
    }

    body.et_fixed_nav #main-header,
    body.et_fixed_nav #main-header.et-fixed-header {
        height: 80px;
    }

    body #page-container {
        padding-top: 80px !important;
    }

    #main-header #top-menu-nav {
        display: none;
    }

    #main-header #et_mobile_nav_menu {
        display: block;
        float: none;
    }

    #main-header .select_page {
        display: none;
    }

    #main-header .et_mobile_menu {
        padding: 5%;
    }

    #main-header .et_mobile_menu li {
        display: block;
    }
}

@media (max-width: 980px) {
    .et_parallax_bg.et_pb_parallax_css {
        background-attachment: scroll;
    }
}

@media (max-width: 650px) {
    #callnowbutton {
        display: block;
    }
}

@media (max-width: 600px) {
    .sanmarco-lightbox {
        padding: 65px 48px 30px;
    }

    .sanmarco-lightbox .sanmarco-lightbox-close {
        right: 6px;
    }

    .sanmarco-lightbox-previous {
        left: 0;
    }

    .sanmarco-lightbox-next {
        right: 0;
    }

    .sanmarco-lightbox-caption {
        display: block;
        text-align: center;
    }

    .sanmarco-lightbox-counter {
        display: block;
        margin-top: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #mobile_menu[data-open="true"] {
        animation: none;
    }

    body.et_fixed_nav #main-header {
        transition: none;
    }

    .et_parallax_bg.et_pb_parallax_css {
        background-attachment: scroll;
    }
}

@media print {
    body.et_fixed_nav #main-header {
        position: relative !important;
    }

    body #page-container {
        padding-top: 0 !important;
    }

    #mobile-menu-toggle,
    #mobile_menu,
    #back-to-top,
    #callnowbutton,
    .sanmarco-lightbox {
        display: none !important;
    }
}
