/* ===============================
   C.E.S.I - Header & Nav
   Prefisso: cesi-
   Versione: Futuristica (v3 - senza particelle)
   =============================== */

.cesi-header,
.cesi-header *,
.cesi-nav,
.cesi-nav * {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
}

/* =========================================================
   HEADER BIANCO — FUTURISTICO
   ========================================================= */
.cesi-header {
    position: relative;
    background: #ffffff;
    z-index: 100;
    overflow: hidden;
    transition: transform .3s ease;
    will-change: transform;

    box-shadow:
        inset 0 -1px 0 rgba(58, 178, 243, .25),
        0 2px 28px rgba(58, 178, 243, .14),
        0 0 60px rgba(58, 178, 243, .06);
}

.cesi-header.is-hidden {
    transform: translateY(-100%);
}

/* LED sweep inferiore */
.cesi-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        rgba(58, 178, 243, 0) 0%,
        rgba(58, 178, 243, .75) 50%,
        rgba(58, 178, 243, 0) 100%
    );
    animation: cesiLedSweep 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes cesiLedSweep {
    0%, 100% { opacity: .55; transform: scaleX(.85); }
    50%      { opacity: 1;   transform: scaleX(1); }
}

/* =========================================================
   DECORAZIONI SFONDO (onda + glow)
   ========================================================= */
.cesi-header__bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

/* --- Onda blu gradiente --- */
.cesi-header__wave {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    width: 100%;
    height: 100%;
    min-height: 140px;
    opacity: .95;
}

.cesi-header__wave-path {
    transform-origin: center bottom;
}

.cesi-header__wave-path--back {
    animation: cesiWaveBack 11s ease-in-out infinite;
}

.cesi-header__wave-path--front {
    animation: cesiWaveFront 8s ease-in-out infinite;
}

@keyframes cesiWaveBack {
    0%, 100% { transform: translateX(-2%) scaleY(1); }
    50%      { transform: translateX(2%)  scaleY(1.15); }
}

@keyframes cesiWaveFront {
    0%, 100% { transform: translateX(2%)  scaleY(1); }
    50%      { transform: translateX(-2%) scaleY(1.1); }
}

/* --- Alone luminoso centrale --- */
.cesi-header__glow {
    position: absolute;
    top: 50%;
    left: 18%;
    width: 420px;
    height: 220px;
    transform: translateY(-50%);
    background: radial-gradient(
        ellipse at center,
        rgba(58, 178, 243, .28) 0%,
        rgba(58, 178, 243, .12) 35%,
        rgba(58, 178, 243, 0) 70%
    );
    filter: blur(28px);
    animation: cesiGlowMove 9s ease-in-out infinite;
    pointer-events: none;
}

@keyframes cesiGlowMove {
    0%, 100% { opacity: .7; transform: translate(0, -50%) scale(1); }
    50%      { opacity: 1;  transform: translate(40px, -50%) scale(1.1); }
}

/* =========================================================
   INNER HEADER
   ========================================================= */
.cesi-header__inner {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* =========================================================
   BRAND
   ========================================================= */
.cesi-brand {
    display: inline-flex;
    align-items: center;
    gap: 20px;
    text-decoration: none;
    color: inherit;
    padding: 6px 0;
    margin-left: -40px;
    transition: transform .25s ease;
}

.cesi-brand:hover {
    transform: translateY(-1px);
}

.cesi-brand__logo-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Alone luminoso dietro al logo */
.cesi-brand__logo-wrap::before {
    content: "";
    position: absolute;
    inset: -14px;
    background: radial-gradient(
        circle,
        rgba(58, 178, 243, .40) 0%,
        rgba(58, 178, 243, .18) 40%,
        rgba(58, 178, 243, 0) 70%
    );
    filter: blur(12px);
    opacity: .9;
    z-index: 0;
    animation: cesiLogoPulse 3.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes cesiLogoPulse {
    0%, 100% { opacity: .7; transform: scale(1); }
    50%      { opacity: 1;  transform: scale(1.06); }
}

.cesi-brand__logo {
    position: relative;
    z-index: 1;
    height: 110px;
    width: 110px;
    object-fit: cover;
    display: block;
    background: #fff;
    padding: 2px;
    border-radius: 4px;
    box-shadow:
        0 6px 20px rgba(58, 178, 243, .35),
        0 0 28px rgba(58, 178, 243, .22),
        inset 0 0 0 1px rgba(58, 178, 243, .15);
    transition: transform .3s ease, box-shadow .3s ease;
}

.cesi-brand:hover .cesi-brand__logo {
    transform: scale(1.04);
    box-shadow:
        0 8px 28px rgba(58, 178, 243, .55),
        0 0 44px rgba(58, 178, 243, .45),
        inset 0 0 0 1px rgba(58, 178, 243, .35);
}

.cesi-brand__text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.1;
    min-width: 0;
}

.cesi-brand__name {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 1.5px;
    color: #0d0d0d;
    text-shadow:
        0 1px 0 rgba(255,255,255,.85),
        0 2px 4px rgba(0,0,0,.06);
    transition: color .25s ease, text-shadow .25s ease;
}

.cesi-brand:hover .cesi-brand__name {
    color: #0a0a0a;
    text-shadow:
        0 1px 0 rgba(255,255,255,.9),
        0 2px 4px rgba(0,0,0,.08),
        0 0 16px rgba(58,178,243,.35);
}

.cesi-brand__slogan {
    font-family: Arial, Helvetica, sans-serif;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    color: #5c6470;
    text-transform: uppercase;
    transition: color .25s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cesi-brand:hover .cesi-brand__slogan {
    color: #1a8fcc;
}

/* =========================================================
   BURGER
   ========================================================= */
.cesi-burger {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #0d0d0d;
    cursor: pointer;
    padding: 8px 10px;
    transition: color .2s ease;
}

.cesi-burger:hover { color: #3ab2f3; }

/* =========================================================
   SOTTOHEADER NERO — STICKY
   ========================================================= */
.cesi-nav {
    background: #0d0d0d;
    color: #fff;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 90;
}

.cesi-nav__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 10px;
    width: 100%;
}

.cesi-nav__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: stretch;
    gap: 4px;
    flex: 0 0 auto;
}

.cesi-nav__list--right {
    margin-left: 0;
    flex: 0 0 auto;
}

.cesi-nav__item {
    display: flex;
}

.cesi-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 14px;
    color: #eaeaea;
    text-decoration: none;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
    white-space: nowrap;
}

.cesi-nav__link i {
    font-size: 1rem;
    opacity: .9;
}

.cesi-nav__link:hover,
.cesi-nav__link:focus-visible {
    background: #1c1c1c;
    color: #3ab2f3;
    border-bottom-color: #3ab2f3;
    outline: none;
}

.cesi-nav__link:hover i,
.cesi-nav__link:focus-visible i {
    color: #3ab2f3;
}

/* =========================================================
   BARRA DI RICERCA
   ========================================================= */
.cesi-search {
    flex: 1 1 auto;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    height: 34px;
}

.cesi-search__input {
    flex: 1;
    width: 100%;
    padding: 8px 14px;
    border: 1px solid #2a2a2a;
    border-right: none;
    background: #1c1c1c;
    color: #eaeaea;
    border-radius: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: .9rem;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.cesi-search__input::placeholder {
    color: #8a8f98;
    font-family: Arial, Helvetica, sans-serif;
}

.cesi-search__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: #1c1c1c;
    border: 1px solid #2a2a2a;
    color: #8a8f98;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .18s ease, color .18s ease,
                border-color .18s ease;
}

.cesi-search__btn:hover,
.cesi-search__btn:focus-visible {
    background: #3ab2f3;
    color: #fff;
    border-color: #3ab2f3;
    outline: none;
}

.cesi-search:hover .cesi-search__input {
    border-color: #3ab2f3;
}

.cesi-search__input:focus {
    border-color: #3ab2f3;
    box-shadow: 0 0 0 2px rgba(58,178,243,.25);
    background: #222;
}

.cesi-search__input:focus + .cesi-search__btn {
    border-color: #3ab2f3;
}

/* =========================================================
   NOTIFICHE
   ========================================================= */
.cesi-notif-btn {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 16px 14px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid transparent;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.cesi-notif-btn i {
    font-size: 1.1rem;
    opacity: .95;
    color: #ffffff;
    transition: color .18s ease, transform .18s ease;
}

.cesi-notif-btn:hover,
.cesi-notif-btn:focus-visible {
    background: #1c1c1c;
    border-bottom-color: #3ab2f3;
    outline: none;
}

.cesi-notif-btn:hover i,
.cesi-notif-btn:focus-visible i {
    color: #3ab2f3;
    transform: scale(1.08);
}

.cesi-notif-badge {
    position: absolute;
    top: 8px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #e63946;
    color: #ffffff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border-radius: 999px;
    pointer-events: none;
    box-shadow: 0 0 0 2px #0d0d0d;
    font-family: Arial, Helvetica, sans-serif;
}

@keyframes cesiNotifPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

.cesi-notif-badge.is-new {
    animation: cesiNotifPulse .8s ease infinite;
}

/* =========================================================
   Z-INDEX GUARDS
   ========================================================= */
.cesi-modal {
    z-index: 9999 !important;
}

.leaflet-pane {
    z-index: 1 !important;
}

.leaflet-top,
.leaflet-bottom,
.leaflet-control {
    z-index: 400 !important;
}

.leaflet-popup {
    z-index: 700 !important;
}

.leaflet-container {
    z-index: 1;
}

/* =========================================================
   RESPONSIVE — TABLET
   ========================================================= */
@media (max-width: 900px) {
    .cesi-header__inner { padding: 10px 16px; }

    .cesi-brand {
        gap: 16px;
        margin-left: -10px;
    }
    .cesi-brand__logo  { height: 76px; width: 76px; }
    .cesi-brand__name  { font-size: 1.65rem; }
    .cesi-brand__slogan{ font-size: .74rem; letter-spacing: 1px; }

    .cesi-burger { display: inline-flex; }

    .cesi-header__glow { width: 300px; height: 160px; }
}

@media (max-width: 560px) {
    .cesi-header__inner { padding: 8px 12px; }

    .cesi-brand {
        gap: 12px;
        margin-left: 0;
    }
    .cesi-brand__logo  { height: 60px; width: 60px; }
    .cesi-brand__name  { font-size: 1.35rem; }
    .cesi-brand__slogan{ font-size: .64rem; letter-spacing: .8px; }

    .cesi-brand__logo-wrap::before { inset: -8px; }

    .cesi-header__glow { width: 200px; height: 120px; opacity: .7; }
}

/* =========================================================
   RESPONSIVE — MOBILE (NAV A TENDINA)
   ========================================================= */
@media (max-width: 900px) {

    .cesi-header__inner {
        padding: 12px 10px;
    }

    .cesi-brand__logo {
        height: 52px;
        width: 52px;
    }

    .cesi-brand__name {
        font-size: 1.25rem;
        letter-spacing: 2px;
    }

    .cesi-brand__slogan {
        font-size: 0.8rem;
    }

    .cesi-burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .cesi-nav {
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease;
    }

    .cesi-nav.is-open {
        max-height: 800px;
    }

    .cesi-nav__inner {
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        gap: 0;
    }

    .cesi-search {
        order: -1;
        max-width: 100%;
        min-width: 0;
        flex: 0 0 auto;
        margin: 12px 14px 0;
        width: calc(100% - 28px);
    }

    .cesi-search__input {
        border-right: none;
    }

    .cesi-search__btn {
        padding: 0 14px;
    }

    .cesi-nav__list {
        flex-direction: column;
        gap: 0;
    }

    .cesi-nav__list--right {
        border-top: 1px solid #1c1c1c;
    }

    .cesi-nav__item {
        width: 100%;
    }

    .cesi-nav__link {
        width: 100%;
        justify-content: flex-start;
        padding: 16px 20px;
        border-bottom: 1px solid #1c1c1c;
        border-left: 3px solid transparent;
    }

    .cesi-nav__link:hover,
    .cesi-nav__link:focus-visible {
        border-bottom-color: #1c1c1c;
        border-left-color: #3ab2f3;
    }

    .cesi-notif-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 16px 20px;
        font-size: 1rem;
        gap: 12px;
        border-bottom: 1px solid #1c1c1c;
        border-left: 3px solid transparent;
        border-bottom-color: #1c1c1c;
    }

    .cesi-notif-btn i {
        font-size: 1.15rem;
        min-width: 22px;
        text-align: center;
    }

    .cesi-notif-btn::after {
        content: "Notifiche";
        color: #ffffff;
        font-size: 1rem;
        font-weight: 500;
    }

    .cesi-notif-btn:hover,
    .cesi-notif-btn:focus-visible {
        background: #1c1c1c;
        border-left-color: #3ab2f3;
        border-bottom-color: #1c1c1c;
    }

    .cesi-notif-btn:hover i,
    .cesi-notif-btn:focus-visible i {
        color: #3ab2f3;
    }

    .cesi-notif-badge {
        position: static;
        margin-left: auto;
        margin-right: 4px;
        min-width: 22px;
        height: 22px;
        line-height: 22px;
        font-size: .75rem;
        box-shadow: none;
    }
}

@media (max-width: 420px) {
    .cesi-brand__slogan {
        display: none;
    }
}

/* =========================================================
   RIDUZIONE MOVIMENTO (accessibilità)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    .cesi-header__wave-path--back,
    .cesi-header__wave-path--front,
    .cesi-header__glow,
    .cesi-brand__logo-wrap::before,
    .cesi-header::after {
        animation: none !important;
    }
}