/* GPAT — Calendrier d'horaires (front, shortcode [gpat-calendar])
 *
 * Styles scopés sous .gpat-cal-wrapper pour ne pas leaker dans le thème.
 * Variable CSS principale : --gpat-cal-color (bleu de marque GPAT par défaut).
 *
 * Structure DOM :
 *   <div class="gpat-cal-wrapper">
 *     <div class="gpat-cal-header">   ← navigation : ‹ avril 2026 ›
 *     <div class="gpat-cal-card">     ← carte arrondie avec ombre
 *       <table class="gpat-cal-grid">
 *         <thead> L M M J V S D       ← bandeau bleu
 *         <tbody> 6 rangées × 7 cells ← grille blanche ; chaque cell :
 *           <td class="gpat-cal-day"><span num><span pills>…</span></td>
 */

.gpat-cal-wrapper {
    --gpat-cal-color: #145077;            /* bleu officiel GPAT */
    --gpat-cal-text: #1a2433;
    --gpat-cal-muted: #cbd5e1;
    --gpat-cal-closed: #94a3b8;
    --gpat-cal-card-radius: 24px;

    box-sizing: border-box;
    max-width: 600px;
    margin: 1.5rem auto;
    background: transparent;
    color: var(--gpat-cal-text);
    font-family: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-weight: 400;
    line-height: 1.25;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.gpat-cal-wrapper *,
.gpat-cal-wrapper *::before,
.gpat-cal-wrapper *::after {
    box-sizing: inherit;
}

/* ------------------------------------------------------------------ */
/* Barre de navigation : titre + chevrons prev/next                     */
/* ------------------------------------------------------------------ */

.gpat-cal-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 0.5rem;
    padding: 0 4px 14px;
}

.gpat-cal-title {
    margin: 0;
    text-align: center;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: 0.01em;
    line-height: 1.2;
    color: var(--gpat-cal-color);
}

.gpat-cal-nav {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    color: var(--gpat-cal-color);
    background: transparent;
    font-size: 1.45rem;
    line-height: 1;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Anti-underline robuste face aux thèmes WP (.entry-content a, Elementor…). */
.gpat-cal-wrapper .gpat-cal-nav,
.gpat-cal-wrapper .gpat-cal-nav:link,
.gpat-cal-wrapper .gpat-cal-nav:visited,
.gpat-cal-wrapper .gpat-cal-nav:hover,
.gpat-cal-wrapper .gpat-cal-nav:focus,
.gpat-cal-wrapper .gpat-cal-nav:active {
    text-decoration: none !important;
    box-shadow: none !important;
}

.gpat-cal-nav:hover,
.gpat-cal-nav:focus-visible {
    background-color: rgba(20, 80, 119, 0.08);
    color: var(--gpat-cal-color);
    outline: none;
}

.gpat-cal-nav:focus {
    outline: 2px solid var(--gpat-cal-color);
    outline-offset: 2px;
}

.gpat-cal-nav--prev { justify-self: start; }
.gpat-cal-nav--next { justify-self: end; }

/* ------------------------------------------------------------------ */
/* Carte arrondie contenant le tableau                                  */
/* ------------------------------------------------------------------ */

.gpat-cal-card {
    background: #ffffff;
    border-radius: var(--gpat-cal-card-radius);
    overflow: hidden;
    box-shadow: 0 4px 22px rgba(15, 23, 42, 0.08);
}

/* ------------------------------------------------------------------ */
/* Tableau : bandeau bleu (thead) + grille blanche (tbody)              */
/* ------------------------------------------------------------------ */

.gpat-cal-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: transparent;
}

.gpat-cal-grid thead {
    background: var(--gpat-cal-color);
}

.gpat-cal-grid thead th {
    padding: 1rem 0;
    background-color: var(--gpat-cal-color); /* anti-reset Elementor */
    color: #ffffff;
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.04em;
    border: 0;
}

.gpat-cal-grid tbody {
    background: #ffffff;
    opacity: 1;
    will-change: opacity;
}

/* CELLULE — clé de l'alignement :
 * vertical-align:top + padding-top constant garantit que TOUS les numéros
 * d'une même rangée s'alignent à la même hauteur, qu'ils aient une pastille
 * en dessous ou non. (L'ancien vertical-align:middle décalait les numéros
 * des jours avec pastille vers le haut → désalignement.) */
.gpat-cal-grid tbody td {
    width: 14.2857%;
    height: 96px;
    vertical-align: top;
    text-align: center;
    padding: 14px 4px 10px;
    border: 0;
    background: transparent;
}

.gpat-cal-num {
    display: block;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1;
    color: var(--gpat-cal-text);
}

/* Jours du mois précédent / suivant : grisés. */
.gpat-cal-day.is-adjacent .gpat-cal-num {
    color: var(--gpat-cal-muted);
    font-weight: 400;
}

.gpat-cal-day.is-active .gpat-cal-num {
    color: var(--gpat-cal-text);
    font-weight: 500;
}

/* Conteneur des pastilles — empilées verticalement et centrées.
 * Supporte plusieurs pastilles (plages multiples le même jour). */
.gpat-cal-pills {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.gpat-cal-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--gpat-cal-color);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.2;
}

/* Pastille « Fermé » (exception de fermeture) : outline neutre. */
.gpat-cal-pill--closed {
    background: transparent;
    color: var(--gpat-cal-closed);
    border: 1px solid var(--gpat-cal-muted);
    font-weight: 600;
}

.gpat-cal-day.is-active:hover .gpat-cal-pill:not(.gpat-cal-pill--closed) {
    filter: brightness(1.08);
}

/* ------------------------------------------------------------------ */
/* Responsive : compaction progressive                                  */
/* ------------------------------------------------------------------ */

@media (max-width: 1023px) {
    .gpat-cal-grid tbody td { height: 84px; padding-top: 12px; }
    .gpat-cal-num { font-size: 1.1rem; }
}

@media (max-width: 767px) {
    .gpat-cal-wrapper {
        max-width: 100%;
        margin: 1rem 0;
        --gpat-cal-card-radius: 18px;
    }
    .gpat-cal-header { padding: 0 2px 10px; }
    .gpat-cal-title { font-size: 1.05rem; }
    .gpat-cal-nav { width: 32px; height: 32px; font-size: 1.25rem; }
    .gpat-cal-grid thead th { padding: 0.7rem 0; font-size: 1rem; letter-spacing: 0.03em; }
    .gpat-cal-grid tbody td { height: 68px; padding: 10px 2px 8px; }
    .gpat-cal-num { font-size: 0.95rem; }
    .gpat-cal-pills { margin-top: 5px; gap: 3px; }
    .gpat-cal-pill { font-size: 0.6rem; padding: 2px 8px; }
}

@media (max-width: 380px) {
    .gpat-cal-grid tbody td { height: 58px; padding-top: 8px; }
    .gpat-cal-num { font-size: 0.9rem; }
    .gpat-cal-pill { font-size: 0.55rem; padding: 2px 6px; }
}
