/* Root container */
.lbdrcal {
    --lbdrcal-gap: .75rem;
    --lbdrcal-radius: .5rem;
    --lbdrcal-border: 1px solid rgba(0, 0, 0, .08);
    --lbdrcal-fg: #1f2937;
    /* slate-800 */
    --lbdrcal-muted: #6b7280;
    /* slate-500 */
    color: var(--lbdrcal-fg);
    display: block;
    /* évite les flex/inline hérités du thème */
    width: 100%;
    white-space: normal;
    /* remet le flux normal (le nowrap est dans __scroller) */
}

/* =========================
   Mobile-first: SCROLLER horizontal
   (uniquement pour la liste des mois)
   ========================= */
.lbdrcal__scroller {
    display: block;
    overflow-x: auto;
    padding-bottom: .5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    /* Firefox */
    position: relative;
    white-space: nowrap;
    /* mois à la suite */
}

/* Chaque mois = carte dans le scroller */
.lbdrcal__scroller .lbdrcal__month {
    display: inline-block;
    vertical-align: top;
    white-space: normal;
    /* contenu wrap normal */
    width: 85%;
    min-width: 320px;
    margin-right: .75rem;
    scroll-snap-align: start;
}

/* Dégradé de fin pour suggérer le scroll à droite */
.lbdrcal__scroller::after {
    content: "";
    position: sticky;
    right: 0;
    float: right;
    height: 100%;
    width: 36px;
    margin-left: -36px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
}

/* Hint "Glissez →" collé au scroller */
.lbdrcal__hint {
    position: sticky;
    left: 0;
    bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .55rem;
    margin: .25rem 0 0 .25rem;
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: .5rem;
    font-size: .85rem;
    color: var(--lbdrcal-muted);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    z-index: 1;
}

.lbdrcal__hint-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    /* flèche → */
    opacity: .8;
}

.lbdrcal.lbdrcal--hint-hidden .lbdrcal__hint {
    display: none;
}

/* =========================
   Cartes/mois & grille interne
   ========================= */
.lbdrcal__month {
    margin-bottom: 1.25rem;
    padding: .75rem;
    /* plus compact */
    border: var(--lbdrcal-border);
    border-radius: var(--lbdrcal-radius);
    background: #fff;
}

.lbdrcal__month-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: .5rem;
}

.lbdrcal__month-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    text-transform: capitalize;
    /* "août" -> "août" ok */
}

/* Grille interne */
.lbdrcal__grid {
    display: grid;
    gap: .25rem;
}

.lbdrcal__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .25rem;
    margin-bottom: .25rem;
}

.lbdrcal__weekday {
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--lbdrcal-muted);
}

/* Jours */
.lbdrcal__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .25rem;
}

.lbdrcal__cell {
    min-height: 2rem;
    /* plus dense */
    border-radius: .35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #f8fafc;
}

.lbdrcal__cell--empty {
    background: transparent;
}

.lbdrcal__cell--day {
    background: var(--lbdrcal-bg, #f8fafc);
    color: #fff;
    /* meilleur contraste sur vert/gris foncé */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
}

.lbdrcal__cell--day.is-unset {
    background: #eef2f7;
    color: #111827;
}

.lbdrcal__daynum {
    font-size: .85rem;
    /* un poil réduit */
    line-height: 1;
    font-weight: 600;
}

/* =========================
   Légende (reste fixe, hors scroller)
   ========================= */
.lbdrcal__legend {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    padding: .5rem 0 0;
    border-top: var(--lbdrcal-border);
    margin-top: .5rem;
}

.lbdrcal__legend-item {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .9rem;
}

.lbdrcal__legend-dot {
    width: .9rem;
    height: .9rem;
    border-radius: 999px;
    display: inline-block;
    background: var(--lbdrcal-bg, #cbd5e1);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .1) inset;
}

/* Erreur */
.lbdrcal--error {
    padding: 1rem;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #7f1d1d;
    border-radius: .5rem;
}

/* =========================
   ≥ 641px : grille fluide auto-fit
   (le scroller redevient une grille; la légende reste fixe)
   ========================= */
@media (min-width: 641px) {
    .lbdrcal__scroller {
        display: grid;
        gap: var(--lbdrcal-gap);
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        overflow: visible;
        white-space: normal;
        scroll-snap-type: none;
    }

    .lbdrcal__scroller .lbdrcal__month {
        display: block;
        /* retour au flux normal */
        width: auto;
        min-width: 0;
        margin-right: 0;
    }

    .lbdrcal__hint {
        display: none;
    }

    /* pas de hint en desktop */
    .lbdrcal__scroller::after {
        display: none;
    }

    /* pas de dégradé en desktop */
}