/* Le calendrier des courses et la fiche d'une course. S'appuie sur lgb-tiles.css (tuiles, puces,
   médailles, mise en page lgb-page) et sur les couleurs de chaque course (race-style-card.css). Préfixe cal-. */

.cal {
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--lgb-ink);
    font-family: 'LGB-Equip', sans-serif;
    font-size: 14px;
}

.cal-feed .lgb-main,
.cal-feed .lgb-rail {
    gap: 14px;
}

/* ---------- En-tête : titre (grand écran) et saison ---------- */

.cal-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 0 2px;
}

.cal-head-title {
    display: none;
    margin-right: auto;
}

.cal-season-select {
    flex: 0 0 auto;
    width: 150px;
}

/* ---------- Titres de section et petites phrases ---------- */

.cal-sec {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 2px 0 2px;
}

.cal-sec-t {
    margin: 0;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 21px;
    line-height: 1;
    text-transform: uppercase;
}

.cal-sec-s {
    font-size: 12px;
    color: var(--lgb-ink-2);
    text-align: right;
}

.cal-quip {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--lgb-ink-2);
}

.cal-quip b { color: var(--lgb-ink); }

/* ---------- Mois et repère du jour ---------- */

.cal-month {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 0 0;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 17px;
    line-height: 1;
    text-transform: uppercase;
    color: var(--lgb-ink);
}

.cal-month::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #DEDAE6;
}

.cal-month--past { color: #8A8496; }

.cal-today {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lgb-red);
}

.cal-today::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--lgb-red);
    box-shadow: 0 0 0 3px var(--lgb-red-soft);
}

.cal-today::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--lgb-red);
}

/* ---------- La ligne d'une course ---------- */

.cal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cal-row {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 66px;
    padding: 8px 12px 8px 8px;
    border-radius: var(--lgb-radius);
    background: var(--lgb-surface);
    box-shadow: var(--lgb-shadow);
    color: var(--lgb-ink);
    text-decoration: none;
    transition: box-shadow 0.2s var(--lgb-ease);
}

@media (hover: hover) {
    .cal-row:hover { box-shadow: var(--lgb-shadow-hover); }
}

.cal-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: var(--lgb-radius-sm);
    background: var(--race-bg);
    color: var(--race-ink);
    line-height: 1;
}

.cal-date b {
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 24px;
}

.cal-date small {
    margin-top: 3px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cal-row--past .cal-date {
    background: color-mix(in srgb, var(--race-bg) 28%, #FFFFFF);
    color: var(--lgb-ink);
}

.cal-row--past .cal-name { color: #3B3747; }

.cal-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cal-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.cal-name > span:first-child {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-sub {
    font-size: 12px;
    line-height: 1.3;
    color: var(--lgb-ink-2);
}

.cal-sub b { color: var(--lgb-ink); font-weight: 700; }

.cal-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    text-align: right;
}

.cal-rank {
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 24px;
    line-height: 1;
    white-space: nowrap;
}

.cal-rank small {
    font-family: 'LGB-Equip', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: var(--lgb-ink-2);
}

.cal-rank sup,
.cal-bib-n sup,
.cal-btn sup,
.cal-me-t sup {
    font-family: 'LGB-Equip', sans-serif;
    font-size: 0.5em;
    vertical-align: super;
    line-height: 0;
}

.cal-side-note {
    font-size: 11px;
    color: var(--lgb-ink-2);
    white-space: nowrap;
}

.cal-dns {
    font-size: 12px;
    font-style: italic;
    color: #8A8496;
    white-space: nowrap;
}

/* Puces de statut, plus hautes que celles de lgb-tiles pour se lire de loin */
.cal-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}

.cal-pill--join { background: #FF9F1C; color: #3D1F00; }
.cal-pill--soon { background: #ECEAF1; color: #4A4556; }
.cal-pill--live { background: var(--lgb-red); color: #FFFFFF; }
.cal-pill--in   { background: var(--lgb-green-soft); color: var(--lgb-green-ink); }

.cal-pill--live::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Petite médaille dans une ligne */
.cal-medal {
    width: 40px;
    height: 40px;
    border-width: 2px;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 21px;
}

.cal-gender {
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #FFE3EE;
    color: #A0124A;
    font-size: 10.5px;
    font-weight: 700;
}

/* Les courses passées, repliées en une ligne tant que la saison roule */
.cal-fold {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 8px 14px;
    border: 0;
    border-radius: var(--lgb-radius);
    background: var(--lgb-surface);
    box-shadow: var(--lgb-shadow);
    color: var(--lgb-ink);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.cal-fold .mud-icon-root {
    flex-shrink: 0;
    color: var(--lgb-ink-2);
    transition: transform 0.2s var(--lgb-ease);
}

.cal-fold--open .mud-icon-root { transform: rotate(180deg); }
.cal-fold b { font-weight: 700; }
.cal-fold-t { flex: 1; min-width: 0; }
.cal-fold .cal-rank { font-size: 18px; }

/* ---------- Boutons ---------- */

.cal-btns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.cal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--lgb-radius);
    background: #FF9F1C;
    color: #3D1F00;
    font-family: 'LGB-Equip', sans-serif;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.cal-btn .mud-icon-root { width: 20px; height: 20px; }
.cal-btn--violet { background: var(--lgb-violet); color: #FFFFFF; }

.cal-btn--ghost {
    background: transparent;
    color: var(--lgb-violet);
    box-shadow: inset 0 0 0 1.5px var(--lgb-lilac-2);
}

.cal-btn--light { background: rgba(255, 255, 255, 0.16); color: #FFFFFF; }

/* ---------- L'affiche du prochain départ ---------- */

.cal-next {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 14px 16px;
    border-radius: var(--lgb-radius);
    background: var(--race-bg);
    color: var(--race-ink);
    overflow: hidden;
}

.cal-next .cal-next-art {
    position: absolute;
    z-index: -1;
    top: 0;
    right: 0;
    width: 52%;
    height: 178px;
    background-size: cover;
    background-position: right center;
    background-repeat: no-repeat;
    clip-path: polygon(26% 0, 100% 0, 100% 100%, 0 100%);
}

.cal-next-k {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--race-muted);
}

.cal-next-j {
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 76px;
    line-height: 0.85;
    text-transform: uppercase;
}

.cal-next-name {
    margin: 0;
    max-width: 54%;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 27px;
    line-height: 0.95;
    text-transform: uppercase;
}

.cal-next-name a {
    color: inherit;
    text-decoration: none;
}

.cal-next-sub { font-size: 13px; line-height: 1.35; color: var(--race-muted); }
.cal-next-sub b { color: var(--race-ink); }

.cal-next-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cal-next-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--lgb-ink);
    font-size: 12px;
    font-weight: 700;
}

.cal-next-meta .mud-icon-root { width: 16px; height: 16px; }

.cal-next .cal-btns { margin-top: 4px; }
.cal-next .cal-btn--ghost { background: rgba(255, 255, 255, 0.7); color: var(--lgb-ink); box-shadow: none; }

/* Intersaison : la saison est bouclée */
.cal-off {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px 16px 16px;
    border-radius: var(--lgb-radius);
    background: linear-gradient(135deg, var(--lgb-night) 0%, var(--lgb-violet-deep) 60%, var(--lgb-violet) 100%);
    color: #FFFFFF;
    overflow: hidden;
}

.cal-off .cal-next-k { color: var(--lgb-lilac); }
.cal-off .cal-next-name { max-width: none; font-size: 32px; }
.cal-off .cal-next-sub { color: var(--lgb-lilac); }
.cal-off .cal-next-sub b { color: #FFFFFF; }

.cal-off-star {
    position: absolute;
    z-index: -1;
    right: -30px;
    bottom: -40px;
    width: 170px;
    height: 170px;
    color: #FFFFFF;
    opacity: 0.08;
}

/* ---------- Tes dossards : un dossard par course de la saison ---------- */

.cal-bibs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.cal-bib {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 0 0 9px 0;
    border: 0;
    border-radius: var(--lgb-radius-sm);
    background: var(--lgb-surface);
    box-shadow: 0 1px 0 rgba(21, 18, 31, 0.06), 0 6px 14px -10px rgba(21, 18, 31, 0.4);
    color: var(--lgb-ink);
    font-family: inherit;
    text-decoration: none;
    overflow: hidden;
    cursor: pointer;
}

/* Les quatre épingles : deux en haut (pseudo-éléments), deux en bas */
.cal-bib::before,
.cal-bib::after,
.cal-bib-pin {
    content: "";
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #CFCAD8;
}

.cal-bib::before,
.cal-bib::after { top: 26px; }
.cal-bib::before { left: 6px; }
.cal-bib::after { right: 6px; }
.cal-bib-pin { bottom: 8px; }
.cal-bib-pin--l { left: 6px; }
.cal-bib-pin--r { right: 6px; }

.cal-bib-top {
    align-self: stretch;
    display: block;
    height: 20px;
    padding: 0 6px;
    background: var(--race-bg);
    color: var(--race-ink);
    font-size: 9.5px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-bib-n {
    margin-top: 8px;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 40px;
    line-height: 0.9;
}

.cal-bib-s {
    max-width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
    font-size: 11px;
    color: var(--lgb-ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-bib--gold .cal-bib-n { color: #8A6200; }
.cal-bib--gold { box-shadow: inset 0 0 0 2px #F5C542, 0 6px 14px -10px rgba(21, 18, 31, 0.4); }
.cal-bib--silver { box-shadow: inset 0 0 0 2px #B9C0CB, 0 6px 14px -10px rgba(21, 18, 31, 0.4); }
.cal-bib--bronze { box-shadow: inset 0 0 0 2px #D9925A, 0 6px 14px -10px rgba(21, 18, 31, 0.4); }

.cal-bib--dns {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px #C9C3D4;
}

.cal-bib--dns .cal-bib-top { background: #ECEAF1; color: #8A8496; }
.cal-bib--dns .cal-bib-n { margin-top: 14px; font-size: 24px; color: #A49EAF; }

.cal-bib--live { box-shadow: inset 0 0 0 2px var(--lgb-red), 0 6px 14px -10px rgba(21, 18, 31, 0.4); }
.cal-bib--live .cal-bib-s { color: var(--lgb-red); font-weight: 700; }

.cal-bib--empty {
    justify-content: center;
    min-height: 92px;
    padding: 8px;
    border: 1.5px dashed #D3CEDC;
    background: transparent;
    box-shadow: none;
    color: #6E6878;
    font-size: 11.5px;
    line-height: 1.3;
    text-align: center;
}

.cal-bib--empty::before,
.cal-bib--empty::after { display: none; }

/* ---------- Fiche d'une course ---------- */

.cal-poster .lgb-race-band { min-height: 168px; }
.cal-poster .lgb-race-name { font-size: 1.9rem; }

.cal-me,
.cal-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: var(--lgb-radius);
    background: var(--lgb-surface);
    box-shadow: var(--lgb-shadow);
}

.cal-me-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cal-me-ico {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #FFF0DB;
    color: #9A5200;
}

.cal-me-ico--in { background: var(--lgb-green-soft); color: var(--lgb-green-ink); }
.cal-me-ico--off { background: #ECEAF1; color: #6E6878; }
.cal-me-ico .mud-icon-root { width: 22px; height: 22px; }

.cal-me-t {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.cal-me-s {
    margin: 2px 0 0 0;
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--lgb-ink-2);
}

/* Mes ligues sur cette course */
.cal-my {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 6px 2px;
    border-top: 1px solid var(--lgb-line);
    color: var(--lgb-ink);
    text-decoration: none;
}

.cal-my-name { min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-my-name small { display: block; font-size: 11.5px; font-weight: 400; color: var(--lgb-ink-2); }
.cal-my .cal-rank { font-size: 21px; }
.cal-my .mud-icon-root { color: var(--lgb-ink-2); }

.cal-tile-h {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.cal-tile-t {
    margin: 0;
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 19px;
    line-height: 1;
    text-transform: uppercase;
}

.cal-tile-s { font-size: 12px; color: var(--lgb-ink-2); }

/* Le profil de la course : une barre par étape, hauteur selon le terrain */
.cal-sky {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 58px;
    padding: 0 2px;
    border-bottom: 2px solid #DEDAE6;
}

.cal-sky-bar {
    flex: 1;
    min-width: 0;
    max-width: 48px;
    border-radius: 3px 3px 0 0;
    background: var(--t);
}

.cal-sky-bar--p { --t: #0E8048; height: 14px; }
.cal-sky-bar--h { --t: #B8620A; height: 27px; }
.cal-sky-bar--m { --t: #D42B2B; height: 52px; }
.cal-sky-bar--c { --t: #6B42FE; height: 20px; border-radius: 50% 50% 0 0; }
.cal-sky-bar--done { opacity: 0.35; }
.cal-sky-bar--today { box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px var(--lgb-red); }

.cal-sky-nums {
    display: flex;
    gap: 3px;
    padding: 0 2px;
    font-size: 9.5px;
    color: var(--lgb-ink-2);
}

.cal-sky-nums span { flex: 1; min-width: 0; max-width: 48px; text-align: center; }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: #3B3747;
}

.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--t); }
.cal-legend b { font-weight: 700; }

/* Une étape */
.cal-stage {
    display: grid;
    grid-template-columns: 26px 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 6px 0;
    border-top: 1px solid var(--lgb-line);
}

.cal-stage:first-child { border-top: 0; }
.cal-stage--done { opacity: 0.55; }

.cal-stage-n {
    font-family: 'LGB-Garaje', sans-serif;
    font-weight: 900;
    font-size: 19px;
    line-height: 1;
    text-align: center;
}

.cal-ty {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--t) 14%, #FFFFFF);
    color: var(--t);
}

.cal-ty svg { width: 18px; height: 18px; }
.cal-ty--p { --t: #0E8048; }
.cal-ty--h { --t: #B8620A; }
.cal-ty--m { --t: #D42B2B; }
.cal-ty--c { --t: #6B42FE; }

.cal-stage-name {
    min-width: 0;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-stage-sub { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 400; color: var(--lgb-ink-2); }
.cal-stage-sub--live { color: var(--lgb-red); font-weight: 700; }

.cal-stage-km {
    font-size: 12.5px;
    font-weight: 700;
    color: #3B3747;
    white-space: nowrap;
}

/* Les équipes au départ : une rangée de maillots */
.cal-teams {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.cal-teams img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.cal-lock {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--lgb-radius);
    background: var(--lgb-lilac-soft);
    color: var(--lgb-violet-deep);
    font-size: 13px;
    line-height: 1.35;
}

.cal-lock .mud-icon-root { flex-shrink: 0; width: 22px; height: 22px; }
.cal-lock b { color: var(--lgb-ink); }

/* ---------- Grand écran ---------- */

@container page (min-width: 640px) {
    .cal-head-title { display: block; }

    .cal-btns {
        grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
    }

    .cal-next {
        min-height: 300px;
        padding: 22px 26px;
    }

    .cal-next .cal-next-art {
        width: 46%;
        height: 100%;
    }

    /* Le texte reste à gauche de l'illustration, qui prend toute la hauteur */
    .cal-next > :not(.cal-next-art) {
        max-width: 56%;
    }

    .cal-next-name { font-size: 34px; }
    .cal-poster .lgb-race-band { min-height: 210px; }
}

@container page (min-width: 980px) {
    .cal-bibs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cal-rail-sticky { position: sticky; top: 0; }
}
