/*
 * Identité FIRST, par-dessus le Tabler personnalisé d'upstiweb (tabler/tabler.css).
 * Version C « équilibre UPSTI / FIRST » : voir docs/decisions.md (D-005, D-011) et docs/maquettes/.
 *
 * Règles de couleur (contrastes WCAG AA) :
 *  - --first-orange (#E48C22, charte UPSTI) : accents (filets, trames, soulignements, icônes),
 *    fonds de bouton avec un texte --first-encre, grands chiffres sur fond bleu nuit ;
 *  - jamais de texte orange vif sur fond blanc : utiliser --first-orange-texte ;
 *  - jamais de texte blanc sur fond orange.
 */

/* Quicksand variable (300 à 700) : vraie graisse grasse au lieu d'un gras simulé. */
@font-face {
    font-family: 'Quicksand';
    font-display: swap;
    font-weight: 300 700;
    src: url("../fonts/Quicksand/Quicksand-VariableFont_wght.woff2") format('woff2');
}

:root {
    --first-orange: #E48C22;
    --first-orange-fonce: #D07A15;
    --first-orange-texte: #A3560A;
    --first-orange-clair: #FDF1E3;
    --first-bleu: #2A3A8C;
    --first-bleu-fonce: #1F2C6E;
    --first-ciel: #4E97CD;
    --first-encre: #1B2436;
    --first-texte-sur-bleu: #DFE5F5;
    --first-texte-doux-sur-bleu: #C5CDEA;
    --first-fond: #F5F7FB;

    /* Les utilitaires orange de Tabler (bg-orange, text-orange, badge…) prennent l'orange FIRST. */
    --upsti-orange: var(--first-orange);
    --upsti-orange-rgb: 228, 140, 34;
}

body {
    background: var(--first-fond);
}

/* Mobile : Tabler réduit la marge des conteneurs à 8 px, moins que les marges négatives
   des rangées .g-4 (12 px) : la page débordait. 16 px, plus confortable. */
@media (max-width: 767.98px) {
    :root {
        --upsti-page-padding: 1rem;
    }
}

/* Les éléments positionnés en absolu d'un tableau (texte visually-hidden…) doivent rester
   dans son cadre défilant, sinon ils élargissent la page sur mobile. */
.table-responsive {
    position: relative;
}

.page {
    min-height: 100vh;
}

a {
    text-underline-offset: .15em;
}

:focus-visible {
    outline: 3px solid var(--first-ciel);
    outline-offset: 2px;
}

.text-orange-texte { color: var(--first-orange-texte) !important; }
.text-bleu { color: var(--first-bleu) !important; }
.bg-orange-clair { background: var(--first-orange-clair) !important; }

/* ------------------------------------------------------------------ Bandeaux du haut */

.first-bandeau-env {
    background: repeating-linear-gradient(-45deg, #FFF3CD, #FFF3CD 12px, #FFE8A3 12px, #FFE8A3 24px);
    color: #5C4400;
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    padding: .2rem 1rem;
}

/* Usurpation d'un compte par le staff : bandeau orange (texte foncé), sur toutes les pages. */
.first-bandeau-usurpation {
    background: var(--first-orange);
    color: var(--first-encre);
    font-size: .875rem;
    padding: .5rem 0;
}
.first-bandeau-usurpation strong { font-weight: 700; }

.first-bandeau-upsti {
    background: var(--first-bleu);
    color: #fff;
    font-size: .82rem;
}

.first-bandeau-upsti .container-xl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2rem;
}

.first-bandeau-upsti a {
    color: #fff;
}

.first-langues,
.first-langues form {
    display: flex;
    align-items: center;
    gap: .15rem;
    margin: 0;
}

.first-langues button {
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    font-weight: 700;
    opacity: .7;
    padding: .2rem .35rem;
    border-radius: 4px;
    cursor: pointer;
}

.first-langues button:hover,
.first-langues button[aria-current="true"] {
    opacity: 1;
}

.first-langues button[aria-current="true"] {
    text-decoration: underline;
    text-decoration-color: var(--first-orange);
    text-decoration-thickness: 2px;
    text-underline-offset: .25em;
}

/* ------------------------------------------------------------------ En-tête et menu */

.first-entete {
    background: #fff;
    box-shadow: 0 1px 0 #DCE1EA;
    padding: 0;
    min-height: 0;
}

/* Ordre explicite : logo, menu, compte (bureau) ; logo, compte, bouton du menu, menu replié (mobile). */
.first-entete .navbar-brand {
    position: static;
    transform: none;
    order: 0;
    padding: .5rem 0;
    margin-right: 1.5rem;
}

.first-entete .first-compte { order: 1; }
.first-entete .navbar-toggler { order: 2; }
.first-entete .navbar-collapse { order: 3; }

@media (min-width: 992px) {
    .first-entete .navbar-collapse { order: 1; flex-grow: 1; }
    .first-entete .first-compte { order: 2; }
}

.first-entete .first-logo {
    height: 56px;
    width: auto;
}

.first-entete .navbar-nav .nav-link {
    color: var(--first-bleu);
    font-weight: 600;
    padding: 1.4rem .85rem;
    position: relative;
    border: 0;
}

.first-entete .navbar-nav .nav-link:hover,
.first-entete .navbar-nav .nav-item.active > .nav-link {
    color: var(--first-orange-texte);
    background: transparent;
}

.first-entete {
    --upsti-navbar-active-border-color: var(--first-orange);
}

@media (min-width: 992px) {
    .first-entete .navbar-nav .nav-item.active::after {
        left: .85rem;
        right: .85rem;
        bottom: 0;
        border-bottom-width: 4px;
        border-radius: 4px 4px 0 0;
    }
}

.first-entete .dropdown-menu {
    border-top: 3px solid var(--first-orange);
    margin-top: 0;
}

.first-entete .dropdown-item.active,
.first-entete .dropdown-item:active {
    background: var(--first-orange-clair);
    color: var(--first-orange-texte);
}

.first-entete .navbar-toggler {
    border: 0;
    color: var(--first-bleu);
    padding: .5rem;
}

.first-compte .avatar {
    background: var(--first-orange);
    color: var(--first-encre);
    font-weight: 700;
}

.first-compte .dropdown-toggle {
    color: var(--first-bleu);
    text-decoration: none;
}

@media (max-width: 991.98px) {
    .first-entete .first-logo {
        height: 44px;
    }

    .first-entete .navbar-collapse {
        border-top: 1px solid #DCE1EA;
        padding: .5rem 0 1rem;
    }

    .first-entete .navbar-nav .nav-link {
        padding: .65rem 0;
    }

    .first-entete .dropdown-menu {
        border: 0;
        box-shadow: none;
        padding: 0 0 0 1rem;
    }
}

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

.btn-first {
    --upsti-btn-color: var(--first-encre);
    --upsti-btn-bg: var(--first-orange);
    --upsti-btn-border-color: var(--first-orange);
    --upsti-btn-hover-color: var(--first-encre);
    --upsti-btn-hover-bg: var(--first-orange-fonce);
    --upsti-btn-hover-border-color: var(--first-orange-fonce);
    --upsti-btn-active-color: var(--first-encre);
    --upsti-btn-active-bg: var(--first-orange-fonce);
    --upsti-btn-active-border-color: var(--first-orange-fonce);
    --upsti-btn-disabled-color: var(--first-encre);
    --upsti-btn-disabled-bg: var(--first-orange);
    font-weight: 700;
}

.btn-contour-bleu {
    --upsti-btn-color: var(--first-bleu);
    --upsti-btn-bg: #fff;
    --upsti-btn-border-color: var(--first-bleu);
    --upsti-btn-hover-color: #fff;
    --upsti-btn-hover-bg: var(--first-bleu);
    --upsti-btn-hover-border-color: var(--first-bleu);
    --upsti-btn-active-color: #fff;
    --upsti-btn-active-bg: var(--first-bleu-fonce);
    font-weight: 600;
}

.btn-contour-blanc {
    --upsti-btn-color: #fff;
    --upsti-btn-bg: transparent;
    --upsti-btn-border-color: rgba(255, 255, 255, .8);
    --upsti-btn-hover-color: var(--first-bleu);
    --upsti-btn-hover-bg: #fff;
    --upsti-btn-hover-border-color: #fff;
    --upsti-btn-active-color: var(--first-bleu);
    --upsti-btn-active-bg: #fff;
    font-weight: 600;
}

/* Un bouton pleine largeur peut passer à la ligne plutôt que déborder (mobile). */
.btn.w-100 {
    white-space: normal;
}

/* ------------------------------------------------------------------ En-tête de page */

/* Les glyphes de fond (upsti-effet-large-right) gardent leur taille native, 144 × 300 px, comme sur upstiweb. */

.first-entete-page {
    background: var(--first-bleu);
    color: #fff;
    position: relative;
    overflow: hidden;
    padding: 1.5rem 0 1.75rem;
}

.first-entete-page::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 144px;
    background: url("../img/upsti-effet-large-right-orange.svg") repeat-y right top / 144px auto;
    opacity: .5;
    pointer-events: none;
}

.first-entete-page .container-xl {
    position: relative;
    z-index: 1;
}

.first-entete-page .breadcrumb {
    margin-bottom: .35rem;
    font-size: .85rem;
}

.first-entete-page .breadcrumb-item,
.first-entete-page .breadcrumb-item a,
.first-entete-page .breadcrumb-item + .breadcrumb-item::before {
    color: var(--first-texte-doux-sur-bleu);
}

.first-entete-page .breadcrumb-item.active {
    color: #fff;
}

.first-entete-page h1 {
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

.first-entete-page h1::before {
    content: none;
}

.first-entete-page .first-sous-titre {
    color: var(--first-texte-sur-bleu);
    margin: .4rem 0 0;
    max-width: 70ch;
}

@media (max-width: 767.98px) {
    .first-entete-page::after {
        width: 110px;
        opacity: .45;
    }

    .first-entete-page h1 {
        font-size: 1.5rem;
    }
}

/* ------------------------------------------------------------------ Contenu */

.first-contenu {
    padding: 2rem 0 3rem;
    flex: 1 0 auto;
}

.first-titre-section {
    font-weight: 700;
    color: var(--first-bleu);
    font-size: 1.6rem;
    position: relative;
    padding: 14px 0 0 58px;
    margin-bottom: 1.5rem;
    text-wrap: balance;
}

.first-titre-section::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 48px;
    height: 42px;
    background: url("../img/upsti-effet-titre-mini-orange.svg") no-repeat;
}

.first-texte {
    max-width: 75ch;
    font-size: 1.05rem;
    line-height: 1.65;
}

/* upstiweb justifie le texte des cartes : pas sur FIRST (lisibilité sur mobile). */
.card-body {
    text-align: left;
}

/* Trame des en-têtes de carte (upstiweb) en orange. */
.card-header::before {
    background-image: url("../img/upsti-effet-titre-mini-orange.svg");
}

.first-chiffre {
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--first-orange-texte);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.first-etape {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--first-orange-clair);
    color: var(--first-orange-texte);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.first-pastille-icone {
    background: var(--first-orange-clair);
    color: var(--first-orange-texte);
}

.badge-statut-accepte { background: #D5F0DA; color: #13481B; }
.badge-statut-attente { background: var(--first-orange-clair); color: var(--first-orange-texte); }
.badge-statut-refuse { background: #EEF0F4; color: #4B5670; }

/* ------------------------------------------------------------------ Étapes d'un parcours */

.first-etapes {
    display: flex;
    gap: .5rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    counter-reset: none;
}

.first-etapes li {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--upsti-secondary);
    min-width: 0;
}

.first-etapes li:not(:last-child)::after {
    content: "";
    flex: 1 1 auto;
    height: 2px;
    min-width: 1rem;
    background: #DCE1EA;
}

.first-etapes li.faite:not(:last-child)::after {
    background: var(--first-orange);
}

.first-etapes-numero {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: #fff;
    border: 2px solid #DCE1EA;
}

.first-etapes li.faite .first-etapes-numero {
    background: var(--first-orange-clair);
    border-color: var(--first-orange);
    color: var(--first-orange-texte);
}

.first-etapes li.en-cours .first-etapes-numero {
    background: var(--first-orange);
    border-color: var(--first-orange);
    color: var(--first-encre);
}

.first-etapes li.en-cours {
    color: var(--first-bleu);
    font-weight: 700;
}

.first-etapes-libelle {
    font-size: .9rem;
    line-height: 1.2;
}

@media (max-width: 767.98px) {
    .first-etapes {
        flex-direction: column;
        gap: .35rem;
    }

    .first-etapes li:not(:last-child)::after {
        display: none;
    }
}

/* Champ piège à robots (laissé vide par les humains) */
.first-champ-piege {
    position: absolute !important;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ------------------------------------------------------------------ Accueil */

.first-hero {
    background: var(--first-bleu);
    color: #fff;
    position: relative;
    overflow: hidden;
    padding: 3.5rem 0;
}

.first-hero::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 144px;
    opacity: .55;
    background: url("../img/upsti-effet-large-right-orange.svg") repeat-y left top / 144px auto;
    pointer-events: none;
}

.first-hero .container-xl {
    position: relative;
    z-index: 1;
}

.first-hero h1 {
    color: #fff;
    font-size: 2.9rem;
    font-weight: 700;
    line-height: 1.1;
    text-wrap: balance;
}

.first-hero .first-surtitre {
    color: var(--first-orange);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.first-hero .lead {
    color: var(--first-texte-sur-bleu);
}

.first-hero .first-encart {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 10px;
    color: var(--first-texte-sur-bleu);
}

.first-hero .first-note-encart {
    color: var(--first-texte-sur-bleu);
}

.first-hero .first-encart strong,
.first-hero .first-encart .first-chiffre-hero {
    color: #fff;
}

.first-hero .first-chiffre-hero {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--first-orange) !important;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 767.98px) {
    .first-hero {
        padding: 2.25rem 0;
    }

    .first-hero::before {
        display: none;
    }

    .first-hero h1 {
        font-size: 2rem;
    }
}

/* ------------------------------------------------------------------ Pied de page */

.first-pied {
    background: var(--first-bleu);
    color: var(--first-texte-sur-bleu);
    border-top: 5px solid var(--first-orange);
    margin-top: auto;
}

/* Neutralise la règle « footer .container-xl » d'upstiweb (trame et marges). */
.first-pied .container-xl {
    background-image: none;
    padding: 2.5rem calc(var(--upsti-gutter-x, 1.5rem) * .5) 2rem;
}

.first-pied h2 {
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: .75rem;
}

.first-pied a {
    color: #fff;
}

.first-pied ul {
    list-style: none;
    padding: 0;
    margin: 0;
    line-height: 2;
}

.first-pied hr {
    border-color: rgba(255, 255, 255, .25);
    opacity: 1;
}

.first-pied .first-pied-bas {
    font-size: .85rem;
}

/* ------------------------------------------------------------------ Impression */

@media print {
    .first-entete-page,
    .first-hero {
        background: none;
        color: #000;
    }

    .first-entete-page h1,
    .first-hero h1 {
        color: #000;
    }

    .first-entete-page::after,
    .first-hero::before {
        display: none;
    }
}

/* ---------------------------------------------------------------- Espace national : chiffres et répartitions */

.first-tuile { border-top: 3px solid var(--first-orange); }
.first-tuile-libelle { font-size: .875rem; font-weight: 600; color: rgb(var(--upsti-secondary-rgb)); }
.first-tuile-valeur { font-size: 2rem; font-weight: 700; line-height: 1.2; color: var(--first-bleu); font-variant-numeric: tabular-nums; }
.first-tuile-sur { font-size: 1.1rem; font-weight: 600; color: rgb(var(--upsti-secondary-rgb)); }
.first-tuile-detail { font-size: .8125rem; color: rgb(var(--upsti-secondary-rgb)); }

.first-table-chiffres td, .first-table-chiffres tfoot th { font-variant-numeric: tabular-nums; }
.first-table-chiffres thead th { white-space: normal; }

/* Barres horizontales d'une seule série : libellé, piste, valeur (le texte reste dans la couleur du texte). */
.first-barres { display: grid; gap: .5rem; }
.first-barres li {
    display: grid;
    grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) auto;
    align-items: center;
    gap: .75rem;
}
.first-barres-libelle { font-size: .875rem; overflow-wrap: anywhere; }
.first-barres-piste { height: .75rem; background: var(--first-fond); border-radius: 4px; }
.first-barres-barre {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--first-ciel);
    border-radius: 0 4px 4px 0;
}
.first-barres li:hover .first-barres-barre { background: var(--first-bleu); }
.first-barres-valeur { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 575.98px) {
    .first-barres li { grid-template-columns: minmax(0, 1fr) auto; }
    .first-barres-piste { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------------------------------------------------------------- Contenu public (D-029, D-031) */

/* Pied de page : « Sous le haut patronage de » ; les logos sont posés sur des pastilles blanches. */
.first-patronages { margin-top: 2rem; }
.first-patronages h2 { margin-bottom: .75rem; }
.first-patronage-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 4.5rem;
    padding: .5rem .75rem;
    background: #fff;
    border-radius: 6px;
}
.first-patronage-logo img { max-height: 100%; max-width: 10rem; object-fit: contain; }
.first-patronage-nom { display: inline-block; padding: .5rem .75rem; border: 1px solid var(--first-texte-doux-sur-bleu); border-radius: 6px; }

.first-carte-image { aspect-ratio: 16 / 9; object-fit: cover; background: var(--first-fond); }
.first-partenaire-logo { max-height: 3.5rem; max-width: 8rem; object-fit: contain; }
.first-temoignage-photo { width: 4rem; height: 4rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* Liens des textes saisis par l'équipe dans l'encart de l'édition (fond bleu nuit). */
.first-encart .first-texte a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.first-encart .first-texte a:hover { color: var(--first-orange); }

/* Carte publique des établissements participants (firstpublic/carte.html) */
.first-carte {
    height: 520px;
}

@media (max-width: 575.98px) {
    .first-carte {
        height: 360px;
    }
}

/* Jauge de couverture d'une académie (intervenantes actives / besoin) : couleur d'état doublée d'une icône
   et d'un texte (jamais la couleur seule). */
.first-jauge { display: grid; grid-template-columns: minmax(3rem, 6rem) auto; align-items: center; gap: .25rem .5rem; }
.first-jauge .small { grid-column: 1 / -1; }
.first-jauge-piste { height: .5rem; background: var(--first-fond); border-radius: 4px; overflow: hidden; }
.first-jauge-barre { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; }
.first-jauge-bon { background: #2E8540; }
.first-jauge-moyen { background: var(--first-orange); }
.first-jauge-faible { background: var(--tblr-red, #D63939); }
.first-jauge-valeur { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
