.site-footer.compact-footer {
    background: var(--color-surface-elevated, #f8f9fa);
    color: var(--color-text-primary, #212529);
    border-top: 4px solid var(--color-primary-pale);
    position: relative;
    padding-top: 2.5rem;
    padding-bottom: 2rem;
    margin-top: 0;
}

/* Accent line above the footer for elegant separation */
.site-footer.compact-footer::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary-dark);
    opacity: 0.8;
}

/* Explicit color bindings mirroring previous footer palette */
.site-footer.compact-footer .footer-heading {
    color: var(--color-text-secondary, #6c757d);
    font-weight: 600;
    /* Allineato al peso degli altri titoli */
    text-transform: uppercase;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
}

.site-footer.compact-footer .footer-subheading {
    color: var(--color-text-secondary, #6c757d);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
}

.footer-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.footer-nav .footer-subheading {
    text-align: center;
    width: 100%;
}

.site-footer.compact-footer .footer-text {
    color: var(--color-text-secondary, #6c757d);
}

.site-footer.compact-footer .footer-link {
    color: var(--color-text-secondary, #6c757d);
}

.site-footer.compact-footer .footer-link:hover {
    color: var(--color-primary, #0d6efd);
}

/* Footer contact icons keep the original secondary color */
.site-footer.compact-footer .footer-icon {
    color: var(--color-secondary-light, #6c757d) !important;
}

.site-footer.compact-footer .footer-bottom .footer-text {
    color: var(--color-text-secondary, #6c757d);
}

.site-footer.compact-footer .footer-bottom {
    border-top-color: var(--color-border-strong, #dee2e6);
}

/* Grid layout: stack on mobile, 3 columns on larger screens */
.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem 2rem;
    align-items: start;
}

.footer-brand {
    text-align: center;
}

.footer-brand .footer-heading {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
}

.footer-text {
    margin: 0 0 0.5rem 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.25;
}

.footer-brand .footer-text {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    max-width: 320px;
}

.social-links {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    justify-content: center;
}

.footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid transparent;
    color: var(--color-primary);
    font-size: 0.95rem;
    transition: background .15s ease, transform .15s ease, color .15s ease;
}

.footer-social-link .bi,
.footer-social-link svg {
    color: inherit;
    fill: currentColor;
}

.footer-social-link:focus,
.footer-social-link:hover {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    transform: translateY(-2px);
}

.footer-social-link:focus .bi,
.footer-social-link:hover .bi,
.footer-social-link:focus svg,
.footer-social-link:hover svg {
    color: var(--color-text-inverse, #ffffff);
    fill: currentColor;
}

.site-footer.compact-footer .social-links .footer-social-link,
.site-footer.compact-footer .social-links .footer-social-link .bi,
.site-footer.compact-footer .social-links .footer-social-link svg {
    color: var(--color-primary) !important;
    background: transparent !important;
}

.site-footer.compact-footer .social-links .footer-social-link:hover,
.site-footer.compact-footer .social-links .footer-social-link:focus {
    background: var(--color-primary) !important;
    color: var(--color-text-inverse) !important;
}

.site-footer.compact-footer .social-links .footer-social-link:hover .bi,
.site-footer.compact-footer .social-links .footer-social-link:focus .bi,
.site-footer.compact-footer .social-links .footer-social-link:hover svg,
.site-footer.compact-footer .social-links .footer-social-link:focus svg {
    color: var(--color-text-inverse, #ffffff) !important;
    fill: currentColor !important;
}

/* Navigation */
.footer-nav-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.3rem 1.5rem;
    margin: 0 auto;
    /* Centra il blocco delle due colonne */
    width: fit-content;
    /* Stringe il contenitore al contenuto per centrarlo meglio */
}

@media (max-width: 576px) {
    .footer-nav-list {
        grid-template-columns: repeat(2, 1fr);
        /* Mantiene 2 colonne anche su mobile per risparmiare altezza */
        gap: 0.4rem 1rem;
        text-align: left;
        /* Allineamento interno ai link */
    }
}

.footer-subheading {
    margin-bottom: 0.35rem;
    color: var(--color-text-primary);
}

.footer-link {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.footer-link:hover,
.footer-link:focus {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Contact list */
.footer-contact-list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    justify-items: center;
    /* Centra gli item dei contatti */
}

.footer-contact .footer-subheading {
    text-align: center;
}

.footer-icon {
    /* contact icons: use primary color to match social icons */
    color: var(--color-primary);
    margin: 0;
    /* Rimosso margin-right per centratura */
}

.footer-icon .bi,
.footer-icon svg {
    color: inherit;
    fill: currentColor;
}

/* High-specificity override to ensure the footer's local scheme wins over site defaults */
.site-footer.compact-footer .footer-icon {
    color: var(--color-primary, #28a745) !important;
}

/* Logos */
.footer-logos-wrap {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.footer-logos {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    margin: 0 auto;
}

/* --- Equal Visual Space for All Logos --- */
/* Each logo gets the SAME width box. The logo scales within it. */
.footer-logo {
    width: 100px !important;
    /* Fixed width for all */
    height: 70px !important;
    /* Fixed height for all */
    max-width: 100px !important;
    max-height: 70px !important;
    object-fit: contain !important;
    /* Scale proportionally within the box */
    object-position: center !important;
    opacity: 0.95;
    transition: opacity .15s ease, transform .15s ease, filter .15s ease;
}

.footer-logo:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* --- Individual Logo Adjustments --- */
/* Cesta: wide logo */
.footer-logo.logo-cesta {
    width: 200px !important;
    max-width: 200px !important;
    height: 105px !important;
    max-height: 105px !important;
}

/* Mineo: slightly bigger */
.footer-logo.logo-mineo {
    width: 110px !important;
    max-width: 110px !important;
    height: 80px !important;
    max-height: 80px !important;
}

/* Regione Sicilia: needs larger box */
.footer-logo.logo-regione {
    width: 120px !important;
    max-width: 120px !important;
    height: 80px !important;
    max-height: 80px !important;
}

/* Licodia: smaller */
.footer-logo.logo-licodia {
    width: 70px !important;
    max-width: 70px !important;
    height: 50px !important;
    max-height: 50px !important;
}

/* Mobile: Scale all logos proportionally (~70% of desktop) */
@media (max-width: 768px) {
    .footer-logos {
        gap: 0.5rem;
    }

    /* Base size */
    .footer-logo {
        width: 70px !important;
        height: 50px !important;
        max-width: 70px !important;
        max-height: 50px !important;
    }

    /* Keep proportions for individual logos */
    .footer-logo.logo-cesta {
        width: 110px !important;
        max-width: 110px !important;
        height: 60px !important;
        max-height: 60px !important;
    }

    .footer-logo.logo-regione {
        width: 85px !important;
        max-width: 85px !important;
        height: 55px !important;
        max-height: 55px !important;
    }

    .footer-logo.logo-mineo {
        width: 75px !important;
        max-width: 75px !important;
        height: 55px !important;
        max-height: 55px !important;
    }

    .footer-logo.logo-licodia {
        width: 50px !important;
        max-width: 50px !important;
        height: 35px !important;
        max-height: 35px !important;
    }
}

/* Small mobile: Scale further (~55% of desktop) */
@media (max-width: 576px) {
    .footer-logos {
        gap: 0.4rem;
    }

    .footer-logo {
        width: 55px !important;
        height: 40px !important;
        max-width: 55px !important;
        max-height: 40px !important;
    }

    .footer-logo.logo-cesta {
        width: 88px !important;
        max-width: 88px !important;
        height: 48px !important;
        max-height: 48px !important;
    }

    .footer-logo.logo-regione {
        width: 66px !important;
        max-width: 66px !important;
        height: 44px !important;
        max-height: 44px !important;
    }

    .footer-logo.logo-mineo {
        width: 60px !important;
        max-width: 60px !important;
        height: 44px !important;
        max-height: 44px !important;
    }

    .footer-logo.logo-licodia {
        width: 40px !important;
        max-width: 40px !important;
        height: 28px !important;
        max-height: 28px !important;
    }
}

/* For inline SVGs prefer original colors; don't override */
.footer-logo svg {
    fill: inherit !important;
    color: inherit !important;
}

/* Make social icons use the primary color (non-hardcoded) */
.footer-social-link {
    color: var(--color-primary);
    border-color: transparent;
}

.footer-social-link:focus,
.footer-social-link:hover {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    transform: translateY(-2px);
}

/* Bottom bar */
.footer-bottom {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding-top: 0.25rem;
    border-top: 1px solid var(--color-border-strong);
    margin-top: 0.5rem;
}

.footer-bottom .footer-links {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

/* Responsive rules */
@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 2.5rem;
    }

    .footer-logo {
        max-height: 64px !important;
    }
}

@media (min-width: 992px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr 1fr;
        /* Perfetta simmetria */
        gap: 4rem;
    }

    .footer-logos {
        gap: 1.5rem;
        /* Più spazio tra i loghi */
    }
}

@media (max-width: 576px) {
    .site-footer.compact-footer {
        padding-top: 2rem !important;
        /* Ripristinato spazio di respiro equilibrato */
        padding-bottom: 2rem;
    }

    .footer-grid {
        gap: 2.5rem;
        /* Più spazio tra le sezioni impilate */
    }

    .footer-logo {
        max-height: 44px !important;
        max-width: 40% !important;
    }

    .footer-bottom {
        justify-content: center;
        gap: 0.75rem;
        text-align: center;
    }

    .footer-text {
        font-size: 0.9rem;
    }

    .footer-logos {
        gap: 0.75rem;
    }

    .footer-brand .footer-text {
        max-width: 100%;
        /* Sfrutta tutta la larghezza su mobile */
    }
}

/* Reduce vertical paddings to keep footer compact */
.site-footer.py-3 {
    padding-top: 2.5rem !important;
    /* Aumentato da 0.5rem */
    padding-bottom: 1.5rem !important;
}

/* Slightly reduce divider spacing */
.footer-divider {
    margin-top: 0.5rem !important;
    margin-bottom: 0.75rem !important;
}

/* Navigation and contact columns: tighter spacing */
.site-footer .footer-subheading,
.site-footer .footer-heading {
    margin-bottom: 0.35rem;
}

.site-footer .list-unstyled {
    padding-left: 0;
}

.site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.site-footer .footer-link {
    padding: 3px 6px;
    display: inline-block;
}

@media (max-width: 576px) {
    .site-footer .footer-text {
        font-size: 0.95rem;
        line-height: 1.3;
        text-align: center;
    }
}

/* Larger and more prominent social icons */
.site-footer .social-links .footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 1.25rem;
    /* Icon size increased */
}

/* Ensure inline-styled logo doesn't break the compact layout */
.footer-logo[style] {
    max-height: 80px !important;
    max-width: 18% !important;
}

/* High-specificity enforcement: force contact icons and social icons to use the footer action color token
   (maps to primary) and ensure icon elements inherit the color and switch to white on hover/focus.
   This overrides theme-level rules that set social icons to inverse colors. */
.site-footer.compact-footer .footer-icon,
.site-footer.compact-footer .footer-icon .bi,
.site-footer.compact-footer .footer-icon svg,
.site-footer.compact-footer .social-links .footer-social-link,
.site-footer.compact-footer .social-links .footer-social-link .bi,
.site-footer.compact-footer .social-links .footer-social-link svg {
    color: var(--color-primary) !important;
    fill: currentColor !important;
}

.site-footer.compact-footer .social-links .footer-social-link:hover,
.site-footer.compact-footer .social-links .footer-social-link:focus {
    background: var(--color-primary, #28a745) !important;
    color: var(--color-text-inverse, #ffffff) !important;
}

.site-footer.compact-footer .social-links .footer-social-link:hover .bi,
.site-footer.compact-footer .social-links .footer-social-link:focus .bi,
.site-footer.compact-footer .social-links .footer-social-link:hover svg,
.site-footer.compact-footer .social-links .footer-social-link:focus svg,
.site-footer.compact-footer .footer-icon .bi,
.site-footer.compact-footer .footer-icon svg {
    color: var(--color-text-inverse, #ffffff) !important;
    fill: currentColor !important;
}