/*
 * Calendrier d'événements interactif — page Events
 * Grille mensuelle (gauche) + sidebar contextuelle avec panneau détail (droite)
 *
 * @author LGI Sustainable Innovation
 */

.ec-component {
    --ec-p2r: var(--secondary-red, #db2e6a);
    --ec-other: var(--secondary-violet, #6a70e2);
    --ec-ink: var(--main-title-color, #383f51);
    --ec-muted: #8a93a5;
    --ec-accent: var(--main-blue-royal, #3e47f0);
    --ec-line: #dfe4ee;
}

/* Le CSS global pose z-index:10 sur tous les p/a/li ; sur un flex-item cela crée
 * un contexte d'empilement qui passerait AU-DESSUS du panneau détail. On neutralise. */
.ec-component p,
.ec-component a,
.ec-component li {
    z-index: auto;
    font-size: 1rem;
}

/* ---------- Compteur total d'événements (entête de page) ---------- */
.ec-total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1;
    flex: none;
    text-align: right;
}

.ec-total-num {
    font-family: "Lato-bold", inherit;
    font-weight: 700;
    font-size: clamp(2.2rem, 5.5vw, 3.2rem);
    letter-spacing: -0.02em;
    background: linear-gradient(
        360deg in lch,
        var(--secondary-red, #db2e6a),
        var(--secondary-violet, #6a70e2)
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(
        --secondary-red,
        #db2e6a
    ); /* repli si background-clip:text non supporté */
    font-variant-numeric: tabular-nums; /* évite les sauts de largeur pendant l'animation */
}

.ec-total-label {
    margin-top: 0.4rem;
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #8a93a5;
}

@media screen and (max-width: 450px) {
    .ec-total-label {
        letter-spacing: 0.12em;
        font-size: 0.64rem;
    }
}

/* ---------- Barre de filtres ---------- */
.ec-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 2.5rem;
}

.ec-filter {
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ec-ink);
    background: white;
    border: 1px solid var(--ec-line);
    border-radius: 999px;
    padding: 0.55em 1.4em;
    cursor: pointer;
    transition:
        background var(--def-transition-duration, 0.2s),
        color var(--def-transition-duration, 0.2s),
        border-color var(--def-transition-duration, 0.2s);
}

.ec-filter:hover {
    border-color: var(--ec-ink);
}

.ec-filter.is-active {
    background: var(--ec-ink);
    border-color: var(--ec-ink);
    color: white;
}

.ec-filter:focus-visible,
.ec-day:focus-visible,
.ec-nav:focus-visible,
.ec-see-all:focus-visible,
.ec-item:focus-visible,
.ec-back:focus-visible,
.ec-learn-more:focus-visible {
    outline: 2px solid var(--ec-accent);
    outline-offset: 2px;
}

/* ---------- Layout 2 colonnes ---------- */
.ec-wrap {
    display: flex;
    max-width: 1100px;
    margin-inline: auto;
    background: white;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(56, 63, 81, 0.16);
}

.ec-cal {
    flex: 1.55;
    min-width: 0;
    padding: 2rem 2.25rem 1.5rem;
    display: flex;
    flex-direction: column;
}

/* ---------- En-tête du mois + navigation ---------- */
.ec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ec-title {
    color: var(--ec-ink);
    font-family: "Lato-bold", inherit;
    font-size: 1.45rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-align: center;
    margin: 0;
}

.ec-nav {
    background: none;
    border: none;
    color: var(--ec-ink);
    font-size: 2rem;
    line-height: 1;
    /* padding: 0.4em 0.6em; */
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--def-transition-duration, 0.2s);
}

.ec-nav:hover:not(:disabled) {
    background: #eef1f7;
}

.ec-nav:disabled {
    opacity: 0.25;
    cursor: default;
}

.ec-see-all-row {
    text-align: center;
    margin: 0.9rem 0 1.1rem;
}

.ec-see-all {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--ec-ink);
    background: white;
    border: 1px solid var(--ec-ink);
    border-radius: 999px;
    padding: 0.45em 1.3em;
    cursor: pointer;
    transition:
        background var(--def-transition-duration, 0.2s),
        color var(--def-transition-duration, 0.2s);
}

.ec-see-all:hover {
    background: var(--ec-ink);
    color: white;
}

/* ---------- Grille ---------- */
.ec-weekdays,
.ec-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.ec-weekdays {
    margin-bottom: 4px;
}

.ec-weekdays span {
    text-align: center;
    font-family: "Lato-bold", inherit;
    font-size: 0.85rem;
    color: var(--ec-muted);
    padding-block: 0.4em;
}

.ec-day {
    position: relative;
    aspect-ratio: 16/12;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ec-ink);
    background: none;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: default;
    transition:
        background var(--def-transition-duration, 0.2s),
        border-color var(--def-transition-duration, 0.2s);
}

.ec-day.has-events {
    cursor: pointer;
}

.ec-day.has-events:hover {
    background: #eef1f7;
}

.ec-day.is-past {
    color: var(--ec-muted);
}

.ec-day.is-outside {
    color: #c4cad6;
}

.ec-day.is-today {
    border-color: var(--ec-accent);
}

.ec-day.is-selected {
    background: #e9ecfb;
    border-color: var(--ec-other);
}

/* Pastilles — max 1 par catégorie et par jour */
.ec-dots {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
}

.ec-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
}

.ec-dot.p2r {
    background: var(--ec-p2r);
}

.ec-dot.other {
    background: var(--ec-other);
}

/* ---------- Légende ---------- */
.ec-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.1rem;
    font-size: 0.8rem;
    color: var(--ec-muted);
}

.ec-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

/* ---------- Sidebar (colonne droite) ---------- */
.ec-side {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: white;
    background:
        linear-gradient(165deg, rgba(35, 42, 66, 0.73), rgba(56, 63, 81, 0.68)),
        url(../../images/home/bg-home-news.webp) center / cover no-repeat;
}

.ec-side-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 2.25rem 1.9rem 1.6rem;
}

.ec-side-title {
    color: white;
    font-family: "Lato-bold", inherit;
    font-size: 1.15rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0 0 0.8rem;
}

.ec-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.ec-list li {
    color: white !important;
    list-style: none;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.ec-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    color: white;
    font-family: inherit;
    text-align: left;
    padding: 0.95rem 0.2rem;
    cursor: pointer;
    transition: background var(--def-transition-duration, 0.2s);
}

.ec-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ec-item .ec-dot {
    margin-top: 5px;
}

.ec-item-title {
    display: block;
    font-family: "Lato-bold", inherit;
    font-size: 0.93rem;
    line-height: 1.35;
}

.ec-item-date {
    display: block;
    font-size: 0.78rem;
    opacity: 0.75;
    margin-top: 3px;
}

/* Scrollbar moderne : thumb "flottant" arrondi, discret sur le panneau sombre.
 * La bordure transparente + background-clip:padding-box donne un pouce fin avec
 * des marges latérales, qui s'épaissit et s'éclaircit au survol. */
.ec-list::-webkit-scrollbar,
.ec-detail-scroll::-webkit-scrollbar {
    width: 10px;
}

.ec-list::-webkit-scrollbar-track,
.ec-detail-scroll::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

.ec-list::-webkit-scrollbar-thumb,
.ec-detail-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
    transition: background-color var(--def-transition-duration, 0.2s);
}

.ec-list::-webkit-scrollbar-thumb:hover,
.ec-detail-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
    background-clip: padding-box;
}

.ec-list::-webkit-scrollbar-thumb:active,
.ec-detail-scroll::-webkit-scrollbar-thumb:active {
    background-color: rgba(255, 255, 255, 0.62);
    background-clip: padding-box;
}

.ec-empty {
    padding: 1rem 0.2rem;
    font-style: italic;
    opacity: 0.85;
}

.ec-share {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
}

.ec-share a {
    color: white !important;
    font-style: italic;
    border-bottom: none;
}

.ec-share a:hover {
    text-decoration: underline;
}

/* ---------- Panneau de détail (slide-in) ---------- */
.ec-detail {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 1.6rem 1.9rem;
    background: linear-gradient(165deg, #232a42 0%, #383f51 100%);
    transform: translateX(12%);
    opacity: 0;
    /* Glissement doux + fondu ; visibility retardée à la fermeture pour laisser jouer le slide-out */
    transition:
        transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.4s ease,
        visibility 0s linear 0.5s;
    visibility: hidden;
    overflow: hidden;
}

.ec-detail.is-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    transition:
        transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.4s ease;
}

/* Respecte les préférences d'animation réduite : fondu simple, sans glissement */
@media (prefers-reduced-motion: reduce) {
    .ec-detail {
        transform: none;
        transition:
            opacity 0.2s ease,
            visibility 0s linear 0.2s;
    }

    .ec-detail.is-open {
        transform: none;
        transition: opacity 0.2s ease;
    }
}

.ec-back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.3em 0.2em;
    margin-bottom: 0.9rem;
    cursor: pointer;
    opacity: 0.85;
}

.ec-back:hover {
    opacity: 1;
    text-decoration: underline;
}

.ec-detail-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
    padding-right: 4px;
}

.ec-detail-img {
    width: 100%;
    /* aspect-ratio: 16 / 9; */
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.ec-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-family: "Lato-bold", inherit;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: white;
    border-radius: 999px;
    padding: 0.35em 1em;
    margin-bottom: 0.7rem;
}

.ec-badge.p2r {
    background: var(--ec-p2r);
}

.ec-badge.other {
    background: var(--ec-other);
}

.ec-detail-title {
    color: white;
    font-family: "Lato-bold", inherit;
    font-size: 1.15rem;
    line-height: 1.35;
    margin: 0 0 0.35rem;
}

.ec-detail-date {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-bottom: 0.9rem;
    color: white !important;
}

.ec-detail-desc {
    font-size: 0.9rem;
    line-height: 1.55;
    opacity: 0.92;
    color: white !important;
}

.ec-learn-more {
    align-self: flex-start;
    margin-top: 1rem;
    background: var(--ec-p2r);
    color: white !important;
    font-size: 1rem !important;
    font-family: "Lato-bold", inherit;
    border-radius: 999px;
    padding: 0.2em 1.2em;
    border-bottom: none;
    transition: filter var(--def-transition-duration, 0.2s);
}

.ec-learn-more:hover {
    filter: brightness(1.12);
}

/* ---------- Responsive ---------- */
@media screen and (max-width: 900px) {
    .ec-wrap {
        flex-direction: column;
    }

    .ec-side {
        min-height: 420px;
    }
}

@media screen and (max-width: 750px) {
    .ec-cal {
        padding: 1.4rem 1.1rem 1.1rem;
    }

    .ec-title {
        font-size: 1.15rem;
    }

    .ec-day {
        font-size: 0.9rem;
        border-radius: 9px;
    }

    .ec-weekdays span {
        font-size: 0.75rem;
    }

    .ec-side-list,
    .ec-detail {
        padding: 1.6rem 1.2rem 1.2rem;
    }
}

@media screen and (max-width: 450px) {
    .ec-filters {
        gap: 8px;
    }

    .ec-filter {
        font-size: 0.8rem;
        padding: 0.5em 1em;
    }

    .ec-title {
        font-size: 0.95rem;
        letter-spacing: 0.1em;
    }

    .ec-day {
        font-size: 0.8rem;
    }

    .ec-dot {
        width: 5px;
        height: 5px;
    }

    .ec-see-all {
        font-size: 0.75rem;
    }
}
