/* ============================================
   CASSIOPEIA EXTENDED - USER.CSS
   TEMPLATE OTTIMIZZATO v2.4
   ============================================ */

/**
 * STRUTTURA:
 * 1. VARIABILI CSS
 * 2. BASE (HTML, BODY, IMMAGINI)
 * 3. TIPOGRAFIA
 * 4. TOPBAR - TELEFONO + SELETTORE LINGUE
 * 5. HEADER - LOGO + MENU
 * 6. MENU PRINCIPALE + DROPDOWN
 * 7. FOOTER
 *    (Menu mobile hamburger/off-canvas gestito da Cassiopeia nativo)
 * 8. MOBILE - REGOLE GENERALI (non menu)
 * 9. ACCESSIBILITÀ
 * 10. PERFORMANCE
 * 11. PRINT STYLES
 * + Bottone leggi tutto blog
 * + Sidebar blog
 * + Sezioni home Servizi/Settori
 */

/* ============================================
   1. VARIABILI CSS
   ============================================ */

:root {
    /* TRANSIZIONI */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* SPACING */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 3rem;

    /* SHADOW */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: -2px 0 10px rgba(0, 0, 0, 0.2);

    /* Z-INDEX SCALE */
    --z-base: 1;
    --z-dropdown: 100;
    --z-fixed: 500;
    --z-modal: 998;
    --z-modal-backdrop: 999;
    --z-toast: 1000;

    /* COLORI LOCALI (non gestiti da Joomla) */
    --color-border: #e0e0e0;
    --color-border-light: #f0f0f0;
    --color-bg: #f8f9fa;
}

/* ============================================
   2. BASE - RESET, HTML, BODY, IMMAGINI
   ============================================ */

html {
    box-sizing: border-box;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.site-grid {
    width: 100%;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

@media (min-width: 768px) { .site-grid { max-width: 720px; } }
@media (min-width: 992px) { .site-grid { max-width: 960px; } }
@media (min-width: 1200px) { .site-grid { max-width: 1140px; } }
@media (min-width: 1400px) { .site-grid { max-width: 1320px; } }

/* ============================================
   3. TIPOGRAFIA
   ============================================ */

p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

/* ============================================
   4. TOPBAR - TELEFONO + SELETTORE LINGUE
   ============================================ */

.container-topbar {
    background-color: #dde0e2;
    width: 100%;
    padding: 0.4rem 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.container-topbar .mod-custom a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--headercolor, #333);
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 0.875rem;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    transition: color var(--transition-fast), border-bottom-color var(--transition-fast);
}

.container-topbar .mod-custom a:hover,
.container-topbar .mod-custom a:focus-visible {
    color: var(--link-hover-color, var(--link-color));
    border-bottom-color: var(--link-hover-color, var(--link-color));
}

.container-topbar .mod-custom a:focus-visible {
    outline: 2px solid var(--link-hover-color, var(--link-color));
    outline-offset: 2px;
}

.container-topbar .mod-custom a i {
    font-size: 0.85em;
}

@media (min-width: 768px) { .container-topbar { padding-left: calc((100% - 720px) / 2); padding-right: calc((100% - 720px) / 2); } }
@media (min-width: 992px) { .container-topbar { padding-left: calc((100% - 960px) / 2); padding-right: calc((100% - 960px) / 2); } }
@media (min-width: 1200px) { .container-topbar { padding-left: calc((100% - 1140px) / 2); padding-right: calc((100% - 1140px) / 2); } }
@media (min-width: 1400px) { .container-topbar { padding-left: calc((100% - 1320px) / 2); padding-right: calc((100% - 1320px) / 2); } }

.container-topbar .mod-languages {
    list-style: none;
    margin: 0;
    padding: 0;
}

.container-topbar .mod-languages ul {
    display: flex;
    gap: 0.15rem;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.container-topbar .mod-languages li {
    display: flex;
    align-items: center;
}

.container-topbar .mod-languages a {
    display: block;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 3px;
    transition: all var(--transition-fast);
    line-height: 0;
}

.container-topbar .mod-languages a:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.container-topbar .mod-languages img {
    display: block;
    width: 22px;
    height: auto;
}

.container-topbar .mod-languages li:not(.lang-active) a img {
    filter: grayscale(70%);
    opacity: 0.55;
    transition: all var(--transition-fast);
}

.container-topbar .mod-languages li:not(.lang-active) a:hover img,
.container-topbar .mod-languages li:not(.lang-active) a:focus-visible img {
    filter: grayscale(0%);
    opacity: 1;
}

.container-topbar .mod-languages li.lang-active a {
    border-color: var(--btnbg);
}

.container-topbar .mod-languages li.lang-active a img {
    filter: none;
    opacity: 1;
}

/* ============================================
   5. HEADER - LOGO + MENU + SEARCH
   ============================================ */

header.header.container-header {
    background-color: var(--headerbg);
    box-shadow: var(--shadow-sm);
    position: relative;
}

header.header.container-header > .grid-child {
    width: 100%;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.navbar-brand img {
    max-width: 100%;
    height: auto;
    width: auto;
    display: block;
}

@media (min-width: 1200px) {
    .navbar-brand img {
        max-width: 250px;
        max-height: 70px;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .navbar-brand img {
        max-width: 180px;
        max-height: 60px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .navbar-brand img {
        max-width: 150px;
        max-height: 50px;
    }
}

.container-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.container-nav .mod-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--spacing-sm);
}

.container-search {
    flex-shrink: 0;
}

/* ============================================
   6. MENU PRINCIPALE + DROPDOWN
   ============================================ */

.mod-menu a {
    color: var(--headercolor, #333);
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    transition: color var(--transition-normal), border-bottom var(--transition-normal);
    border-bottom: 2px solid transparent;
    display: inline-block;
}

header.header.container-header .container-nav .mod-menu .nav-item > a:hover,
header.header.container-header .container-nav .mod-menu .nav-item > a:focus-visible {
    color: var(--link-hover-color, var(--link-color));
    border-bottom-color: var(--link-hover-color, var(--link-color));
}

header.header.container-header .container-nav .mod-menu .nav-item > a:focus-visible {
    outline: 2px solid var(--link-hover-color, var(--link-color));
    outline-offset: 2px;
}

header.header.container-header .container-nav .mod-menu .nav-item.active > a,
header.header.container-header .container-nav .mod-menu .nav-item.current > a {
    color: var(--link-color);
    border-bottom-color: var(--link-color);
}

/* Dropdown desktop: gestito dal template Cassiopeia nativo */

/* Fix dropdown mobile:
   Cassiopeia forza il testo del sottomenu a bianco sotto i 992px
   dando per scontato un header scuro. Con header chiaro il testo
   diventa invisibile: rimettiamo il colore del corpo testo. */
@media (max-width: 991.98px) {
    header.container-header .mod-menu .mod-menu__sub a,
    header.container-header .mod-menu .mod-menu__sub span {
        color: var(--headercolor);
    }
}

/* ============================================
   7. FOOTER
   ============================================ */

footer.container-footer {
    background-color: var(--footerbg);
    color: var(--footercolor);
}

footer.container-footer > .grid-child {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 15px;
    box-sizing: border-box;
    text-align: center;
}

footer.container-footer a {
    color: var(--footercolor, #ecf0f1);
    transition: color var(--transition-normal);
}

footer.container-footer a:hover {
    color: var(--btnbg);
}

footer.container-footer a:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ============================================
   8. MOBILE - REGOLE GENERALI (non menu)
   ============================================ */

@media (max-width: 767px) {
    .container-topbar {
        padding: 0.5rem 15px;
    }

    header.header.container-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 15px;
        gap: 1rem;
    }

    header.header.container-header > .grid-child {
        width: auto;
        max-width: none;
    }

    .navbar-brand {
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }

    .navbar-brand img {
        max-width: 140px;
        max-height: 60px;
    }

    main {
        padding: 2rem 0;
    }
}

/* ============================================
   9. ACCESSIBILITÀ - WCAG 2.1 AA
   ============================================ */

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--headerbg);
    color: var(--headercolor);
    padding: 8px 16px;
    z-index: var(--z-toast);
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.skip-to-content:focus,
.skip-to-content:focus-visible {
    top: 0;
    outline: none;
}

a:focus-visible {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
    border-radius: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* ============================================
   10. PERFORMANCE - PREFERS-REDUCED-MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   11. PRINT STYLES
   ============================================ */

@media print {
    .container-topbar,
    footer {
        display: none;
    }

    body {
        color: black;
        background: white;
    }
}

/* ============================================
   BOTTONE "LEGGI TUTTO" BLOG
   ============================================ */

.com-content-category-blog__read-more a,
p.readmore a.btn.btn-secondary {
    background-color: #a4d65e;
    border: 2px solid #a4d65e;
    color: white;
    border-radius: 4px;
    padding: 0.4rem 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-block;
}

.com-content-category-blog__read-more a:hover,
p.readmore a.btn.btn-secondary:hover {
    background-color: var(--link-color);
    border-color: var(--link-color);
    color: white;
}

/* ============================================
   SIDEBAR BLOG
   ============================================ */

.blog-sidebar.moduletable {
    border-left: 3px solid var(--footerbg, #1d7989);
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

.blog-sidebar.moduletable h3 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--footerbg, #1d7989);
}

.blog-sidebar.moduletable ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blog-sidebar.moduletable ul li {
    padding: 0;
    border-bottom: 1px solid var(--color-border-light);
}

.blog-sidebar.moduletable ul li a {
    display: block;
    padding: 0.65rem 0.25rem;
    color: var(--link-color, var(--color-text, #2c3e50));
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-bottom-color var(--transition-fast), padding-left var(--transition-fast);
}

.blog-sidebar.moduletable ul li a:hover,
.blog-sidebar.moduletable ul li a:focus-visible {
    color: var(--link-hover-color, var(--link-color));
    border-bottom-color: var(--link-hover-color, var(--link-color));
    padding-left: 0.5rem;
}

/* ============================================
   SIDEBAR BLOG - selettori corretti Joomla 6
   ============================================ */

.sidebar-right.blog-sidebar {
    border: none;
    border-left: 3px solid var(--footerbg, #1d7989);
    border-radius: 0;
    padding-left: 1rem;
}

.sidebar-right.blog-sidebar h3.card-header {
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--footerbg, #1d7989);
}

.sidebar-right.blog-sidebar .card-body {
    padding: 0;
}

.sidebar-right.blog-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-right.blog-sidebar ul li {
    padding: 0;
    border-bottom: 1px solid var(--color-border-light);
}

.sidebar-right.blog-sidebar ul li a {
    display: block;
    padding: 0.65rem 0.25rem;
    color: var(--link-color, var(--bodycolor, #707372));
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-bottom-color var(--transition-fast), padding-left var(--transition-fast);
}

.sidebar-right.blog-sidebar ul li a:hover,
.sidebar-right.blog-sidebar ul li a:focus-visible {
    color: var(--link-hover-color, var(--link-color));
    border-bottom-color: var(--link-hover-color, var(--link-color));
    padding-left: 0.5rem;
}

.sidebar-right.blog-sidebar ul li a:focus-visible {
    outline: none;
}

/* ============================================
   SEZIONI HOME - SERVIZI E SETTORI
   ============================================ */

.home-section-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--bodycolor, #707372);
    position: relative;
    padding-bottom: 0.75rem;
}

.home-section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--link-color);
    border-radius: 2px;
}

/* ---- SERVIZI ---- */
.home-servizi {
    padding: 3rem 0;
}

.home-servizi-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

.home-servizi-card {
    flex: 1;
    min-width: 250px;
    max-width: 350px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 2rem 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--bodycolor, #707372);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.home-servizi-card:hover {
    border-color: var(--link-color);
    box-shadow: 0 4px 16px rgba(29, 121, 137, 0.15);
    transform: translateY(-4px);
    color: var(--bodycolor, #707372);
}

.home-servizi-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: #a4d65e;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    transition: background-color 0.3s ease;
}

.home-servizi-card:hover .home-servizi-icon {
    background-color: var(--link-color);
}

.home-servizi-icon i {
    font-size: 1.8rem;
    color: white;
    transition: color 0.3s ease;
}

.home-servizi-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--link-color);
}

.home-servizi-card p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.home-servizi-link {
    color: var(--link-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ---- SETTORI ---- */
.home-mercato {
    padding: 3rem 0;
}

.home-mercato-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

.home-mercato-card {
    flex: 1;
    min-width: 200px;
    max-width: 250px;
    text-align: center;
    padding: 1.5rem 1rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.home-mercato-card:hover {
    border-color: var(--link-color);
    box-shadow: 0 4px 16px rgba(29, 121, 137, 0.15);
    transform: translateY(-4px);
}

.home-mercato-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #a4d65e;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.home-mercato-icon i {
    font-size: 1.5rem;
    color: white;
}

.home-mercato-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--link-color);
}

.home-mercato-card p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--bodycolor, #707372);
    margin: 0;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 767px) {
    .home-servizi-grid,
    .home-mercato-grid {
        flex-direction: column;
        align-items: center;
    }
    .home-servizi-card,
    .home-mercato-card {
        max-width: 100%;
    }
}