/* ==========================================================
   AGENDA SOLIDAIRE — Fondation Mère Enfant
   Reprend la charte du site (variables de style.css) : le mode
   sombre suit donc automatiquement le reste de l'application.
========================================================== */

.ag-page,
.ag-modal,
.agenda-page-header {
    --ag-bg: var(--bg);
    --ag-surface: var(--card);
    --ag-surface-2: var(--surface-muted);
    --ag-line: var(--border);
    --ag-line-strong: color-mix(in srgb, var(--border) 70%, var(--text-light));
    --ag-text: var(--text);
    --ag-muted: var(--text-light);
    --ag-accent: var(--primary);
    --ag-accent-strong: var(--primary-dark);
    --ag-accent-soft: var(--surface-accent);
    --ag-today: var(--secondary);
    --ag-now: var(--secondary);
    --ag-shadow: 0 1px 2px rgba(15, 59, 55, 0.06), 0 14px 34px -16px rgba(15, 59, 55, 0.28);
    --ag-radius: 18px;
    --ag-hour: 3.25rem;
    --ag-gutter: 4rem;
    color: var(--ag-text);
}

:root[data-theme="dark"] .ag-page,
:root[data-theme="dark"] .ag-modal {
    --ag-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}

/* Couleurs par type d'événement (charte du site) */
.ag-type--all { --ev: var(--primary); }
.ag-type--caravan { --ev: var(--primary); }
.ag-type--openday { --ev: var(--secondary); }
.ag-type--blood { --ev: var(--danger-text); }

/* ---------- Hero (même famille que les autres pages) ---------- */
.agenda-page-header {
    min-height: 340px;
    justify-content: flex-start;
    text-align: left;
    background-image:
        linear-gradient(100deg, rgba(var(--brand-deep-rgb), 0.9) 0%, rgba(var(--brand-deep-rgb), 0.7) 45%, rgba(var(--brand-deep-rgb), 0.25) 100%),
        var(--agenda-header-image);
}

.agenda-page-header,
.agenda-page-header h1,
.agenda-page-header p { color: #fff; }
.agenda-page-header__content { width: 100%; max-width: 1240px; margin: 0 auto; }
.agenda-page-header__content p { margin: 0 0 1.4rem; max-width: 620px; }
.agenda-page-header__eyebrow {
    display: inline-block;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hope-yellow);
}
.agenda-page-header .ag-legend { color: rgba(255, 255, 255, 0.92); }
.agenda-page-header .ag-legend__item {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
}
.agenda-page-header .ag-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); }

.ag-page {
    background: var(--ag-bg);
    padding: 2.5rem 1.25rem 4rem;
    min-height: 60vh;
}

.ag-sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.ag-legend { color: rgba(255, 255, 255, 0.92); }
.agenda-page-header .ag-legend__item {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
}
.agenda-page-header .ag-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); }

.ag-page {
    background: var(--ag-bg);
    padding: 2.5rem 1.25rem 4rem;
    min-height: 60vh;
}

.ag-sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ---------- En-tête ---------- */
.ag-hero {
    max-width: 1240px;
    margin: 0 auto 1.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem 2rem;
}

.ag-hero__text { max-width: 720px; }

.ag-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--ag-accent-soft);
    color: var(--ag-accent-strong);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ag-hero h1 {
    margin: 0.85rem 0 0.6rem;
    font-size: clamp(1.75rem, 3.4vw, 2.6rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ag-text);
}

.ag-hero p { color: var(--ag-muted); font-size: 1.02rem; line-height: 1.6; margin: 0; }

.ag-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.1rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.88rem;
    color: var(--ag-muted);
}

.ag-legend__item { display: inline-flex; align-items: center; gap: 0.45rem; }

.ag-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--ev);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ev) 20%, transparent);
    flex-shrink: 0;
}

/* ---------- Coque du calendrier ---------- */
.ag-shell {
    position: relative;
    max-width: 1240px;
    margin: 0 auto;
    background: var(--ag-surface);
    border: 1px solid var(--ag-line);
    border-radius: calc(var(--ag-radius) + 6px);
    box-shadow: var(--ag-shadow);
    overflow: hidden;
}

.ag-progress {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--ag-accent), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.ag-shell.is-loading .ag-progress { opacity: 1; animation: ag-loading 1s linear infinite; }

@keyframes ag-loading { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.ag-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 1.1rem 1.25rem 0.75rem;
}

.ag-nav { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; min-width: 0; }
.ag-nav__arrows { display: flex; gap: 0.25rem; }

.ag-title {
    margin: 0;
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ag-text);
}

.ag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.1rem;
    border-radius: 12px;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.18s, border-color 0.18s, color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.ag-btn--outline {
    background: var(--ag-surface);
    border-color: var(--ag-line-strong);
    color: var(--ag-text);
}

.ag-btn--outline:hover { border-color: var(--ag-accent); color: var(--ag-accent-strong); background: var(--ag-surface-2); }

.ag-btn--primary {
    background: var(--ev, var(--ag-accent));
    color: #fff;
    box-shadow: 0 8px 20px -10px var(--ev, var(--ag-accent));
}

.ag-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -10px var(--ev, var(--ag-accent)); color: #fff; }
.ag-btn--primary .ag-ico { transition: transform 0.18s; }
.ag-btn--primary:hover .ag-ico { transform: translateX(3px); }

.ag-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--ag-text);
    cursor: pointer;
    transition: background-color 0.18s;
}

.ag-icon-btn:hover { background: var(--ag-accent-soft); color: var(--ag-accent-strong); }
.ag-icon-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.ag-btn:focus-visible, .ag-icon-btn:focus-visible, .ag-views button:focus-visible, .ag-filter:focus-visible,
.ag-chip:focus-visible, .ag-block:focus-visible, .ag-more:focus-visible, .ag-day__num:focus-visible,
.ag-tg__dayhead:focus-visible, .ag-modal__close:focus-visible {
    outline: 2px solid var(--ag-accent);
    outline-offset: 2px;
}

/* Sélecteur de vue (segmenté) */
.ag-views {
    display: inline-flex;
    padding: 0.25rem;
    border-radius: 12px;
    background: var(--ag-surface-2);
    border: 1px solid var(--ag-line);
}

.ag-views button {
    border: 0;
    background: transparent;
    color: var(--ag-muted);
    font: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.45rem 0.95rem;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.ag-views button:hover { color: var(--ag-text); }

.ag-views button[aria-pressed="true"] {
    background: var(--ag-surface);
    color: var(--ag-accent-strong);
    box-shadow: 0 1px 3px rgba(15, 59, 55, 0.15);
}

/* Filtres */
.ag-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.25rem 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.ag-filters::-webkit-scrollbar { display: none; }

.ag-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--ag-line-strong);
    background: var(--ag-surface);
    color: var(--ag-text);
    font: inherit;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.ag-filter:hover { border-color: var(--ev); transform: translateY(-1px); }

.ag-filter[aria-pressed="true"] {
    background: color-mix(in srgb, var(--ev) 14%, var(--ag-surface));
    border-color: var(--ev);
    color: color-mix(in srgb, var(--ev) 65%, var(--ag-text));
}

.ag-count {
    min-width: 1.5rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--ag-surface-2);
    color: var(--ag-muted);
    font-size: 0.75rem;
    text-align: center;
}

.ag-filter[aria-pressed="true"] .ag-count { background: var(--ev); color: #fff; }

.ag-body { border-top: 1px solid var(--ag-line); min-height: 24rem; }

.ag-skeleton {
    height: 32rem;
    background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 7 - 1px), var(--ag-line) calc(100% / 7 - 1px) calc(100% / 7));
    opacity: 0.6;
}

.ag-status {
    margin: 0;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--ag-line);
    color: var(--ag-muted);
    font-size: 0.85rem;
}

.ag-shell.has-error .ag-status { color: var(--ag-now); font-weight: 600; }

/* Pictogrammes */
.ag-ico { display: inline-grid; place-items: center; flex-shrink: 0; }
.ag-ico svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Événement (puce) ---------- */
.ag-chip {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    margin: 0 4px;
    padding: 0 0.5rem;
    border: 0;
    border-radius: 7px;
    background: color-mix(in srgb, var(--ev) 15%, var(--ag-surface));
    color: color-mix(in srgb, var(--ev) 62%, var(--ag-text));
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.18s, transform 0.18s, box-shadow 0.18s;
    animation: ag-chip-in 0.35s ease both;
}

.ag-chip:hover {
    background: color-mix(in srgb, var(--ev) 26%, var(--ag-surface));
    box-shadow: 0 4px 12px -6px var(--ev);
    transform: translateY(-1px);
}

.ag-chip__title { overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.ag-chip .ag-ico { font-size: 0.85rem; }


.ag-chip.is-cont-left { margin-left: 0; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 0.65rem; }
.ag-chip.is-cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* ---------- Vue mensuelle ---------- */
.ag-month__head {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--ag-surface-2);
    border-bottom: 1px solid var(--ag-line);
}

.ag-month__weekday {
    padding: 0.6rem 0.5rem;
    text-align: center;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ag-muted);
}

.ag-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: 2.25rem repeat(var(--lanes), 1.85rem) 1.45rem;
    row-gap: 3px;
    min-height: 8rem;
    border-bottom: 1px solid var(--ag-line);
}

.ag-week:last-child { border-bottom: 0; }

.ag-day {
    grid-row: 1 / -1;
    padding: 0.35rem 0.4rem;
    border-left: 1px solid var(--ag-line);
    transition: background-color 0.2s;
}

.ag-day:first-child { border-left: 0; }
.ag-day.is-weekend { background: color-mix(in srgb, var(--ag-surface-2) 55%, transparent); }
.ag-day.is-other { background: var(--ag-surface-2); }
.ag-day.is-other .ag-day__num { color: color-mix(in srgb, var(--ag-muted) 60%, transparent); }
.ag-day:hover { background: color-mix(in srgb, var(--ag-accent) 5%, var(--ag-surface)); }

.ag-day__num {
    display: inline-grid;
    place-items: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.3rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ag-text);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.18s, color 0.18s;
}

.ag-day__num:hover { background: var(--ag-accent-soft); color: var(--ag-accent-strong); }

.ag-day.is-today .ag-day__num {
    background: var(--ag-today);
    color: #fff;
    box-shadow: 0 6px 14px -6px var(--ag-today);
}

.ag-more {
    z-index: 2;
    justify-self: start;
    margin: 0 4px;
    padding: 0.1rem 0.45rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ag-accent-strong);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.ag-more:hover { background: var(--ag-accent-soft); }
.ag-more { white-space: nowrap; }

/* ---------- Vues semaine et jour ---------- */
.ag-tg__head,
.ag-tg__allday,
.ag-tg__body {
    display: grid;
    grid-template-columns: var(--ag-gutter) repeat(var(--days), minmax(0, 1fr));
}

.ag-tg__head { border-bottom: 1px solid var(--ag-line); background: var(--ag-surface-2); }

.ag-tg__dayhead {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.55rem 0.25rem;
    border: 0;
    border-left: 1px solid var(--ag-line);
    background: transparent;
    color: var(--ag-muted);
    font: inherit;
    cursor: pointer;
}

.ag-tg__dayhead span { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.ag-tg__dayhead strong {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    font-size: 1.15rem;
    color: var(--ag-text);
    transition: background-color 0.18s;
}

.ag-tg__dayhead:hover strong { background: var(--ag-accent-soft); }
.ag-tg__dayhead.is-today span { color: var(--ag-today); }
.ag-tg__dayhead.is-today strong { background: var(--ag-today); color: #fff; }

.ag-tg__gutter--label {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    align-self: center;
    padding-right: 0.5rem;
    text-align: right;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ag-muted);
}

.ag-tg__allday { border-bottom: 1px solid var(--ag-line-strong); }

.ag-tg__allday-grid {
    display: grid;
    grid-column: 2 / -1;
    grid-template-columns: repeat(var(--days), minmax(0, 1fr));
    grid-template-rows: 0 repeat(var(--lanes), 1.6rem);
    row-gap: 3px;
    padding-bottom: 0.4rem;
    background: repeating-linear-gradient(90deg, var(--ag-line) 0 1px, transparent 1px calc(100% / var(--days)));
}

.ag-tg__allday-empty { grid-row: 2; grid-column: 1 / -1; padding-left: 0.75rem; align-self: center; color: var(--ag-muted); font-size: 0.8rem; }

.ag-tg__scroll { max-height: 34rem; overflow-y: auto; overscroll-behavior: contain; }

.ag-tg__body { position: relative; height: calc(var(--hours) * var(--ag-hour)); }

.ag-tg__hours span {
    display: block;
    height: var(--ag-hour);
    padding-right: 0.55rem;
    text-align: right;
    font-size: 0.7rem;
    color: var(--ag-muted);
    font-variant-numeric: tabular-nums;
    transform: translateY(-0.45em);
}

.ag-tg__hours span:first-child { transform: none; }

.ag-tg__col {
    position: relative;
    border-left: 1px solid var(--ag-line);
    background-image: repeating-linear-gradient(to bottom, var(--ag-line) 0 1px, transparent 1px var(--ag-hour));
}

.ag-tg__col.is-today { background-color: color-mix(in srgb, var(--ag-accent) 4%, transparent); }

.ag-block {
    position: absolute;
    top: calc(var(--top) * var(--ag-hour) / 60 + 1px);
    left: calc(var(--col) * 100% / var(--cols) + 3px);
    width: calc(100% / var(--cols) - 6px);
    height: calc(var(--len) * var(--ag-hour) / 60 - 3px);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.4rem 0.5rem;
    overflow: hidden;
    border: 0;
    border-radius: 9px;
    background: color-mix(in srgb, var(--ev) 16%, var(--ag-surface));
    color: color-mix(in srgb, var(--ev) 60%, var(--ag-text));
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: box-shadow 0.18s, transform 0.18s, background-color 0.18s;
    animation: ag-chip-in 0.35s ease both;
}

.ag-block:hover { z-index: 3; background: color-mix(in srgb, var(--ev) 24%, var(--ag-surface)); box-shadow: 0 10px 22px -12px var(--ev); transform: translateY(-1px); }
.ag-block__time { font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: 0.85; }
.ag-block__title { display: flex; gap: 0.3rem; align-items: flex-start; font-size: 0.82rem; font-weight: 700; line-height: 1.25; }
.ag-block__title .ag-ico { margin-top: 0.1rem; }
.ag-block__place { font-size: 0.76rem; color: var(--ag-muted); }

.ag-now {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--top) * var(--ag-hour) / 60);
    height: 2px;
    background: var(--ag-now);
    z-index: 4;
    pointer-events: none;
}

.ag-now::before {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ag-now);
}

.ag-empty-day {
    margin: 0;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ag-line);
    text-align: center;
    color: var(--ag-muted);
}

/* Animations de changement de période */
.ag-anim-next { animation: ag-slide-next 0.32s ease both; }
.ag-anim-prev { animation: ag-slide-prev 0.32s ease both; }
.ag-anim-fade { animation: ag-fade 0.3s ease both; }

@keyframes ag-slide-next { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes ag-slide-prev { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes ag-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ag-chip-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.ag-modal {
    margin: auto;
    width: min(660px, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - 2rem);
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.ag-modal::backdrop {
    background: rgba(var(--brand-night-rgb), 0.55);
    backdrop-filter: blur(5px);
    animation: ag-fade 0.25s ease both;
}

.ag-modal[open] .ag-modal__card { animation: ag-pop 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.15) both; }
.ag-modal.is-closing .ag-modal__card { animation: ag-pop-out 0.2s ease forwards; }
.ag-modal.is-closing::backdrop { animation: ag-fade-out 0.2s ease forwards; }

@keyframes ag-pop { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes ag-pop-out { to { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes ag-fade-out { to { opacity: 0; } }

:root.ag-modal-open { overflow: hidden; }

.ag-modal__card {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--ag-surface);
    color: var(--ag-text);
    border: 1px solid var(--ag-line);
    border-radius: 22px;
    box-shadow: 0 30px 80px -20px rgba(var(--brand-night-rgb), 0.45);
}

.ag-modal__cover {
    position: relative;
    margin: 0;
    aspect-ratio: 16 / 7;
    background: color-mix(in srgb, var(--ev) 25%, var(--ag-surface-2));
}

.ag-modal__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ag-modal__cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(var(--brand-night-rgb), 0.55));
}

.ag-modal__badge,
.ag-modal__phase {
    position: absolute;
    z-index: 1;
    bottom: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.ag-modal__badge { left: 1.1rem; background: var(--ev); color: #fff; box-shadow: 0 6px 16px -6px var(--ev); }
.ag-modal__phase { right: 1.1rem; background: rgba(255, 255, 255, 0.92); color: #1E1A2E; }

.ag-modal__close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #1E1A2E;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s, background-color 0.2s;
}

.ag-modal__close:hover { transform: rotate(90deg); background: #fff; }
.ag-modal__close .ag-ico svg { stroke-width: 2.4; }

.ag-modal__body { padding: 1.4rem 1.5rem 0.5rem; }

.ag-modal__body h2 { margin: 0 0 0.4rem; font-size: 1.45rem; line-height: 1.25; letter-spacing: -0.01em; color: var(--ag-text); }
.ag-modal__lead { margin: 0 0 1.1rem; color: var(--ag-muted); line-height: 1.55; }

.ag-meta {
    display: grid;
    gap: 0.7rem;
    margin: 0 0 1.25rem;
    padding: 1rem;
    list-style: none;
    border-radius: 14px;
    background: var(--ag-surface-2);
    border: 1px solid var(--ag-line);
}

.ag-meta li { display: flex; gap: 0.75rem; align-items: flex-start; font-size: 0.92rem; line-height: 1.45; }

.ag-meta .ag-ico {
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ev) 16%, var(--ag-surface));
    color: color-mix(in srgb, var(--ev) 70%, var(--ag-text));
    font-size: 1.05rem;
}

.ag-meta strong { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ag-muted); }

.ag-modal__section { margin-bottom: 1.25rem; }
.ag-modal__section h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--ag-text); }
.ag-modal__text { margin: 0; line-height: 1.65; white-space: pre-line; color: var(--ag-text); }

.ag-needs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }

.ag-needs li {
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ev) 12%, var(--ag-surface));
    border: 1px solid color-mix(in srgb, var(--ev) 30%, transparent);
    color: color-mix(in srgb, var(--ev) 55%, var(--ag-text));
    font-size: 0.84rem;
    font-weight: 600;
}

.ag-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 0.75rem; margin: 0 0 1.25rem; }
.ag-facts div { padding: 0.75rem 0.9rem; border: 1px solid var(--ag-line); border-radius: 12px; }
.ag-facts dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ag-muted); margin-bottom: 0.25rem; }
.ag-facts dd { margin: 0; font-size: 0.92rem; font-weight: 600; white-space: pre-line; }

.ag-bar { display: block; height: 6px; margin-top: 0.5rem; border-radius: 999px; background: var(--ag-surface-2); overflow: hidden; }
.ag-bar span { display: block; height: 100%; border-radius: inherit; background: var(--ev); transition: width 0.6s ease; }

.ag-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }

.ag-steps li {
    position: relative;
    padding: 0.45rem 0 0.45rem 2.1rem;
    font-size: 0.9rem;
    color: var(--ag-muted);
    counter-increment: step;
}

.ag-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.4rem;
    display: grid;
    place-items: center;
    width: 1.45rem;
    height: 1.45rem;
    border-radius: 50%;
    background: var(--ag-surface-2);
    border: 1px solid var(--ag-line-strong);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ag-muted);
}

.ag-steps li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 0.7rem;
    top: 1.9rem;
    bottom: -0.4rem;
    width: 1px;
    background: var(--ag-line-strong);
}

.ag-steps li.is-current { color: var(--ag-text); font-weight: 700; }
.ag-steps li.is-current::before { background: var(--ev); border-color: var(--ev); color: #fff; }

.ag-modal__actions {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 1rem 1.5rem 1.25rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--ag-surface) 0%, transparent), var(--ag-surface) 30%);
    border-top: 1px solid var(--ag-line);
}

.ag-modal__actions .ag-btn { flex: 1 1 200px; }

/* Liste de secours (sans JavaScript) */
.ag-upcoming { max-width: 1240px; margin: 1.5rem auto 0; }
.ag-upcoming ul { margin: 0; padding-left: 1.2rem; line-height: 1.9; }
.ag-upcoming a { color: var(--ag-accent-strong); }
.ag-js .ag-upcoming { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ag-fallback { max-width: 1240px; margin: 1.5rem auto 0; color: var(--ag-muted); }

/* ---------- Tablette ---------- */
@media (max-width: 980px) {
    .ag-page, .ag-modal { --ag-gutter: 3.2rem; }
    .ag-week { min-height: 7rem; }
}

/* ---------- Téléphone ---------- */
@media (max-width: 720px) {
    .ag-page { padding: 1.75rem 0.75rem 3rem; }
    .ag-page, .ag-modal { --ag-gutter: 2.6rem; --ag-hour: 3rem; }
    .ag-hero { margin-bottom: 1.25rem; }
    .ag-shell { border-radius: var(--ag-radius); }
    .ag-toolbar { padding: 0.9rem 0.9rem 0.65rem; }
    .ag-nav { width: 100%; justify-content: space-between; }
    .ag-title { order: -1; width: 100%; }
    .ag-views { width: 100%; }
    .ag-views button { flex: 1; }
    .ag-filters { padding: 0 0.9rem 0.85rem; }

    .ag-week { grid-template-rows: 2rem repeat(var(--lanes), 2.1rem) 1.2rem; min-height: 5.6rem; row-gap: 2px; }
    /* Titre sur deux lignes : la case est étroite sur téléphone */
    .ag-chip { white-space: normal; align-items: center; }
    .ag-chip__title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }
    .ag-day { padding: 0.25rem 0.15rem; cursor: pointer; }
    .ag-day__num { min-width: 1.5rem; height: 1.5rem; font-size: 0.78rem; }
    .ag-month__weekday { padding: 0.5rem 0.1rem; font-size: 0.66rem; letter-spacing: 0.02em; }
    .ag-chip { margin: 0 2px; padding: 0 0.3rem; font-size: 0.66rem; border-radius: 4px; }
    .ag-chip .ag-ico { display: none; }
    .ag-more { margin: 0 2px; padding: 0 0.2rem; font-size: 0.64rem; }
    .ag-more__word { display: none; }

    .ag-tg__dayhead strong { width: 1.8rem; height: 1.8rem; font-size: 0.95rem; }
    .ag-tg__dayhead span { font-size: 0.62rem; letter-spacing: 0.02em; }
    .ag-tg--week .ag-block { padding: 0.25rem; }
    .ag-tg--week .ag-block__time, .ag-tg--week .ag-block .ag-ico { display: none; }
    .ag-tg--week .ag-block__title { font-size: 0.66rem; }
    .ag-tg__scroll { max-height: 28rem; }

    /* Le modal devient une feuille qui remonte du bas de l'écran */
    .ag-modal { width: 100vw; max-height: 92dvh; margin: auto 0 0; }
    .ag-modal__card { max-height: 92dvh; border-radius: 22px 22px 0 0; border-bottom: 0; }
    .ag-modal[open] .ag-modal__card { animation-name: ag-sheet; }
    .ag-modal.is-closing .ag-modal__card { animation-name: ag-sheet-out; }
    .ag-modal__body { padding: 1.15rem 1.1rem 0.25rem; }
    .ag-modal__body h2 { font-size: 1.25rem; }
    .ag-modal__actions { padding: 0.85rem 1.1rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
}

@keyframes ag-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ag-sheet-out { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
    .ag-page *, .ag-modal, .ag-modal *, .ag-modal::backdrop { animation: none !important; transition: none !important; }
}

.ag-more--toggle { margin: 0; padding: 0.1rem 0.4rem; background: var(--ag-accent-soft); }

/* Mode sombre : les couleurs de la charte deviennent claires, le texte posé dessus passe en foncé */
:root[data-theme="dark"] .agenda-page-header {
    background-image:
        linear-gradient(100deg, rgba(var(--brand-night-rgb), 0.92) 0%, rgba(var(--brand-night-rgb), 0.72) 45%, rgba(var(--brand-night-rgb), 0.3) 100%),
        var(--agenda-header-image);
    background-size: cover;
    background-position: center;
}
:root[data-theme="dark"] .ag-btn--primary,
:root[data-theme="dark"] .ag-btn--primary:hover,
:root[data-theme="dark"] .ag-modal__badge,
:root[data-theme="dark"] .ag-filter[aria-pressed="true"] .ag-count,
:root[data-theme="dark"] .ag-day.is-today .ag-day__num,
:root[data-theme="dark"] .ag-tg__dayhead.is-today strong,
:root[data-theme="dark"] .ag-steps li.is-current::before { color: #0E1A1A; }
