/* ==========================================================
   Formation SSA — Thème graphique (surcouche Bootstrap 5.3)
   Code couleur inspiré de l'identification SSA :
   rouge / jaune (poste de secours, tenue) + bleu eau.
   Modifier les variables ci-dessous pour ajuster la charte.
   ========================================================== */
:root {
  --ssa-rouge:      #c8102e;
  --ssa-rouge-fonce:#9b0c23;
  --ssa-jaune:      #ffc72c;
  --ssa-marine:     #0b2545;
  --ssa-bleu:       #0a6fa8;
  --ssa-eau:        #e8f4fa;
  --ssa-gris:       #f4f6f8;

  /* Types de fiches RTN */
  --ssa-ac: #0a6fa8;   /* apport de connaissances */
  --ssa-pr: #c8102e;   /* procédure */
  --ssa-ft: #2b8a3e;   /* fiche technique */

  /* Surcharge Bootstrap */
  --bs-primary: var(--ssa-bleu);
  --bs-primary-rgb: 10, 111, 168;
  --bs-link-color: var(--ssa-bleu);
  --bs-link-hover-color: var(--ssa-marine);
  --bs-body-color: #1f2a37;
  --bs-border-radius: .6rem;
}

body { background: #fff; }

/* ---------- Bandeau & navigation ---------- */
.ssa-stripe {
  height: 6px;
  background: linear-gradient(to bottom, var(--ssa-rouge) 50%, var(--ssa-jaune) 50%);
}
.ssa-navbar { background: var(--ssa-marine); }
.ssa-navbar .navbar-brand,
.ssa-navbar .nav-link,
.ssa-navbar .navbar-text { color: rgba(255,255,255,.88); }
.ssa-navbar .nav-link:hover,
.ssa-navbar .nav-link.active { color: #fff; }
.ssa-navbar .nav-link.active { box-shadow: inset 0 -3px 0 var(--ssa-jaune); }
.ssa-navbar .navbar-toggler { border-color: rgba(255,255,255,.4); }
.ssa-navbar .navbar-toggler-icon { filter: invert(1); }
.ssa-brand-sub { color: var(--ssa-jaune); font-size: .75rem; }

.ssa-logo {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--ssa-rouge); color: #fff; font-size: 1.3rem;
  border: 3px solid var(--ssa-jaune);
}
.ssa-logo--sm { width: 30px; height: 30px; font-size: 1rem; border-width: 2px; }
.ssa-num { background: var(--ssa-marine); color: #fff; }

/* Méga-menu des compétences */
.ssa-mega { --bs-dropdown-padding-y: 0; border: 0; border-top: 4px solid var(--ssa-jaune); border-radius: 0 0 .75rem .75rem; }
.ssa-mega__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem 1.25rem; padding: 1.25rem; }
.ssa-mega__head { display: flex; gap: .5rem; align-items: flex-start; font-weight: 700; color: var(--ssa-marine); text-decoration: none; padding-bottom: .5rem; margin-bottom: .35rem; border-bottom: 2px solid var(--ssa-eau); line-height: 1.25; }
.ssa-mega__head:hover { color: var(--ssa-bleu); }
.ssa-mega__item { white-space: normal; font-size: .84rem; padding: .3rem .4rem; border-radius: .35rem; display: flex; gap: .45rem; line-height: 1.3; }
.ssa-mega__num { font-weight: 700; color: var(--ssa-bleu); min-width: 1.9rem; }
.ssa-mega__valid { color: #198754; font-weight: 600; margin-top: .2rem; }
@media (min-width: 1200px) {
  .ssa-navbar > .container { position: relative; }
  .ssa-navbar .ssa-mega { position: absolute; top: 100%; left: .75rem; right: .75rem; margin-top: 0; }
  .ssa-mega__grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1199.98px) {
  .ssa-mega { background: rgba(255,255,255,.98); }
  .ssa-mega__grid { grid-template-columns: 1fr; padding: .75rem; }
  .ssa-mega__col { border-bottom: 1px solid #eee; padding-bottom: .5rem; }
  .ssa-navbar .navbar-collapse { max-height: calc(100vh - 80px); overflow-y: auto; padding-bottom: .75rem; }
}

/* ---------- Barre de progression (API JA) ---------- */
.ja-progress__track { background:#e9ecef; border-radius:8px; height:14px; overflow:hidden; }
.ja-progress__bar   { background:#198754; height:100%; width:0; transition:width .4s ease; }
.ja-progress__label { font-size:.85rem; color:#495057; }
.ja-progress--mini .ja-progress__track { height:6px; background: rgba(255,255,255,.2); }
.ja-progress--mini .ja-progress__label { font-size:.7rem; color: rgba(255,255,255,.75); }
.ja-progress--hero .ja-progress__track { height:18px; }

/* ---------- En-tête de page (hero) ---------- */
.ssa-hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(255,199,44,.18), transparent 40%),
    linear-gradient(135deg, var(--ssa-marine) 0%, var(--ssa-bleu) 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.ssa-hero::after { /* vagues */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 40' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M0 20 Q 180 0 360 20 T 720 20 T 1080 20 T 1440 20 V40 H0Z'/%3E%3C/svg%3E") no-repeat bottom / 100% 100%;
}
.ssa-hero .lead { color: rgba(255,255,255,.85); }
.ssa-hero .breadcrumb { --bs-breadcrumb-divider-color: rgba(255,255,255,.6); --bs-breadcrumb-item-active-color: #fff; }
.ssa-hero .breadcrumb a { color: var(--ssa-jaune); }
.ssa-hero-card { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(4px); }
.ssa-hero-card .ja-progress__label { color: rgba(255,255,255,.9); }
.ssa-hero-card .ja-progress__track { background: rgba(255,255,255,.25); }

/* ---------- Cartes modules ---------- */
.ssa-module-card {
  border: 1px solid #e3e8ee; border-top: 5px solid var(--ssa-bleu);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ssa-module-card:hover { transform: translateY(-3px); box-shadow: 0 .75rem 1.5rem rgba(11,37,69,.12); }
.ssa-module-card.is-validated { border-top-color: #198754; }
/* Cartes entièrement cliquables (stretched-link) : les boutons internes restent accessibles */
.ssa-module-card:has(.stretched-link), a.ssa-module-card { cursor: pointer; }
.ssa-au-dessus { position: relative; z-index: 2; }
.ssa-module-card:has(.stretched-link:focus-visible) { outline: 3px solid var(--ssa-jaune); outline-offset: 2px; }
.ssa-module-icon {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  background: var(--ssa-eau); color: var(--ssa-bleu); font-size: 1.5rem;
}
.is-validated .ssa-module-icon { background: #d1e7dd; color: #198754; }
.ssa-chapter-state { font-size: .8rem; color: #6c757d; }
.is-validated .ssa-chapter-state { color: #198754; font-weight: 600; }

/* ---------- Badges de type de fiche ---------- */
.badge-type { font-weight: 600; letter-spacing: .02em; }
.type-ac { background: var(--ssa-ac) !important; }
.type-pr { background: var(--ssa-pr) !important; }
.type-ft { background: var(--ssa-ft) !important; }
.ssa-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; color: #6c757d; }

/* Liste des fiches */
.ssa-fiche-item { border-left: 4px solid transparent; }
.ssa-fiche-item[data-type="AC"] { border-left-color: var(--ssa-ac); }
.ssa-fiche-item[data-type="PR"] { border-left-color: var(--ssa-pr); }
.ssa-fiche-item[data-type="FT"] { border-left-color: var(--ssa-ft); }

/* ---------- Mise en page des fiches (cours) ---------- */
.ssa-sidebar { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; }
.ssa-sidebar .list-group-item.active { background: var(--ssa-marine); border-color: var(--ssa-marine); }
.ssa-content { font-size: 1.05rem; line-height: 1.7; }
.ssa-content h2 { font-size: 1.4rem; color: var(--ssa-marine); margin-top: 2rem; padding-bottom: .35rem; border-bottom: 2px solid var(--ssa-jaune); }
.ssa-content h3 { font-size: 1.15rem; color: var(--ssa-bleu); margin-top: 1.5rem; }

/* Emplacement d'image à fournir (includes/cours.php → illus()) */
.ssa-illus { border: 2px dashed #b6c7d6; background: repeating-linear-gradient(45deg, #f6f9fb, #f6f9fb 10px, #eef4f8 10px, #eef4f8 20px); }
.ssa-content .figure-caption { font-size: .85rem; }
.ssa-content > .figure { display: block; max-width: 720px; margin-left: auto; margin-right: auto; }

/* Encadrés pédagogiques */
.ssa-box { border-radius: var(--bs-border-radius); padding: 1rem 1.25rem; margin: 1.25rem 0; border-left: 5px solid; }
.ssa-box > :last-child { margin-bottom: 0; }
.ssa-box__title { font-weight: 700; margin-bottom: .35rem; display: flex; gap: .5rem; align-items: center; }
.ssa-box--info      { background: var(--ssa-eau); border-color: var(--ssa-bleu); }
.ssa-box--important { background: #fff5d6; border-color: var(--ssa-jaune); }
.ssa-box--danger    { background: #fde8eb; border-color: var(--ssa-rouge); }
.ssa-box--jurisprudence { background: var(--ssa-gris); border-color: var(--ssa-marine); font-size: .95rem; }

/* ---------- Capacités ---------- */
.ssa-cap-num { background: var(--ssa-jaune); color: var(--ssa-marine); font-weight: 800; border-radius: .5rem; padding: .25rem .5rem; flex-shrink: 0; }
.ssa-validation-card { position: sticky; top: 90px; border-top: 5px solid var(--ssa-jaune) !important; }

[id] { scroll-margin-top: 90px; }
.ssa-savoir { background: var(--ssa-eau); color: var(--ssa-marine); font-weight: 500; white-space: normal; text-align: left; margin-bottom: .2rem; text-decoration: none; border: 1px solid transparent; transition: background .15s, border-color .15s; }
a.ssa-savoir:hover, a.ssa-savoir:focus { background: #fff; border-color: var(--ssa-bleu); color: var(--ssa-bleu); }
/* Partie de cours ciblée par un lien « Au programme » */
.ssa-content :target { animation: ssa-cible 2.5s ease-out; border-radius: .35rem; }
@keyframes ssa-cible { 0%, 40% { background: #fff5d6; box-shadow: 0 0 0 .5rem #fff5d6; } 100% { background: transparent; box-shadow: 0 0 0 .5rem transparent; } }
.ssa-objectif { color: #2b3a4a; }
.ssa-cap-group { font-size: .7rem; letter-spacing: .03em; }

/* ---------- QCM ---------- */
.ssa-question { border: 1px solid #e3e8ee; }
.ssa-question .form-check { padding: .6rem .75rem .6rem 2.25rem; border-radius: .5rem; border: 1px solid transparent; }
.ssa-question .form-check:hover { background: var(--ssa-gris); }
.ssa-question .form-check-input:checked + .form-check-label { font-weight: 600; }
.ssa-question .form-check.is-correct { background: #d1e7dd; border-color: #a3cfbb; }
.ssa-question .form-check.is-wrong   { background: #f8d7da; border-color: #f1aeb5; }
.ssa-question .form-check.is-missed  { border-color: #198754; border-style: dashed; }
.ssa-question-num { background: var(--ssa-marine); color: #fff; width: 2rem; height: 2rem; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; }
/* QCM : une question par page (activé par qcm.js) */
.qcm-js-only { display: none; }
.qcm-js .qcm-js-only { display: block; }
.qcm-js .qcm-nojs-only { display: none !important; }
.qcm-js .ssa-question { display: none; }
.qcm-js .ssa-question.is-current { display: block; animation: ssa-apparition .25s ease-out; }
@keyframes ssa-apparition { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.qcm-js .ssa-question legend:focus { outline: none; }
.ssa-qcm-head .progress-bar { background: var(--ssa-bleu); transition: width .3s ease; }
.ssa-qcm-pager { display: flex; flex-wrap: wrap; gap: .3rem; }
.ssa-qcm-pager__btn { width: 2.1rem; height: 2.1rem; border-radius: .5rem; border: 1px solid #ced4da; background: #fff; font-size: .8rem; font-weight: 600; color: var(--ssa-marine); }
.ssa-qcm-pager__btn.is-done { background: var(--ssa-eau); border-color: var(--ssa-bleu); }
.ssa-qcm-pager__btn.is-current { background: var(--ssa-marine); border-color: var(--ssa-marine); color: #fff; }
.ssa-qcm-pager__btn:focus-visible { outline: 3px solid var(--ssa-jaune); outline-offset: 1px; }
.ssa-qcm-nav .btn { min-height: 2.75rem; }
.ssa-question .form-check.is-neutral { opacity: .75; }
.ssa-aide-btn { white-space: nowrap; }
/* Niveaux requis (annexe 3) */
.ssa-niv { font-weight: 700; letter-spacing: .02em; cursor: default; }
.ssa-niv--M { background: var(--ssa-rouge); color: #fff; }
.ssa-niv--A { background: var(--ssa-eau); color: var(--ssa-marine); border: 1px solid #b6d9ec; }
.ssa-qcm-pager__btn.is-m { position: relative; }
.ssa-qcm-pager__btn.is-m::after { content: "M"; position: absolute; top: -.45rem; right: -.35rem; font-size: .55rem; line-height: 1;
  background: var(--ssa-rouge); color: #fff; border-radius: .3rem; padding: .12rem .2rem; }
.ssa-aide-btn:focus, .ssa-aide-btn:hover { background: var(--ssa-jaune); border-color: var(--ssa-jaune); color: var(--ssa-marine); }
.ssa-tooltip { --bs-tooltip-bg: var(--ssa-marine); --bs-tooltip-font-size: .85rem; --bs-tooltip-opacity: 1; }
.ssa-aide { background: #fff5d6; border-left: 4px solid var(--ssa-jaune); border-radius: .4rem; padding: .5rem .75rem; font-size: .9rem; }
.ssa-score { font-size: 3rem; font-weight: 800; color: var(--ssa-marine); }

/* ---------- Pied de page ---------- */
.ssa-footer { background: var(--ssa-marine); color: rgba(255,255,255,.8); border-top: 6px solid var(--ssa-jaune); }
.ssa-footer a { color: #fff; }
.ssa-footer h2 { color: var(--ssa-jaune); }
.ssa-footer hr { border-color: rgba(255,255,255,.2); }


/* ==========================================================
   LECTURE DES FICHES — confort & smartphone
   ========================================================== */
.ssa-reading { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 1035; background: transparent; }
.ssa-reading__bar { height: 100%; width: 0; background: var(--ssa-jaune); transition: width .1s linear; }

.ssa-fiche-title { font-size: clamp(1.35rem, 4.5vw, 2rem); line-height: 1.25; }
.ssa-content { overflow-wrap: break-word; hyphens: auto; }
.ssa-content.is-text-lg { font-size: 1.18rem; }
.ssa-content.is-text-xl { font-size: 1.32rem; }
.ssa-content .table-responsive { margin: 1rem 0; border: 1px solid #e3e8ee; border-radius: var(--bs-border-radius); }
.ssa-content .table { margin-bottom: 0; font-size: .95em; }
.ssa-content ul, .ssa-content ol { padding-left: 1.25rem; }
.ssa-content li { margin-bottom: .3rem; }

/* Barre de navigation fixe en bas (smartphone) */
.ssa-mobilebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: grid; grid-template-columns: 1fr 1fr 1fr 1.3fr;
  background: #fff; border-top: 1px solid #dee2e6;
  box-shadow: 0 -4px 16px rgba(11,37,69,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.ssa-mobilebar__btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; border: 0; background: none; color: var(--ssa-marine);
  font-size: .72rem; font-weight: 600; text-decoration: none;
}
.ssa-mobilebar__btn i { font-size: 1.3rem; line-height: 1; }
.ssa-mobilebar__btn:active { background: var(--ssa-gris); }
.ssa-mobilebar__btn--primary { flex-direction: row; gap: .35rem; background: var(--ssa-bleu); color: #fff; font-size: .9rem; }
.ssa-mobilebar__btn--qcm { background: var(--ssa-jaune); color: var(--ssa-marine); }
.ssa-offcanvas.offcanvas-bottom { height: auto; max-height: 75vh; border-radius: 1rem 1rem 0 0; }

@media (max-width: 767.98px) {
  body.page-fiche { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  body.page-fiche .ssa-footer { margin-top: 2rem !important; }
  .ssa-hero::after { height: 22px; }
  .ssa-hero--compact .breadcrumb { font-size: .8rem; }
  .ssa-content { font-size: 1rem; line-height: 1.65; }
  .ssa-content .lead { font-size: 1.08rem; }
  .ssa-content h2 { font-size: 1.2rem; margin-top: 1.5rem; }
  .ssa-content h3 { font-size: 1.05rem; }
  .ssa-box { padding: .85rem 1rem; margin-left: -.25rem; margin-right: -.25rem; }
  .ssa-content .card-header { position: sticky; top: 64px; z-index: 1; }
  .container { --bs-gutter-x: 1.25rem; }
}

/* QCM : zones tactiles et bouton de validation accessible au pouce */
@media (max-width: 767.98px) {
  .ssa-question .form-check { padding: .85rem .85rem .85rem 2.6rem; margin-bottom: .35rem; border-color: #e9ecef; }
  .ssa-question .form-check-input { width: 1.3em; height: 1.3em; margin-left: -1.85rem; }
  .ssa-question legend { font-size: 1rem; }
  .ssa-qcm-submit {
    position: sticky; bottom: 0; z-index: 1020; background: #fff;
    margin: 1rem -1.25rem 0; padding: .75rem 1.25rem calc(.75rem + env(safe-area-inset-bottom));
    border-top: 1px solid #dee2e6; box-shadow: 0 -4px 16px rgba(11,37,69,.08);
  }
  .ssa-qcm-submit .btn-lg { width: 100%; }
  .ssa-score { font-size: 2.4rem; }
}

/* Récapitulatif des QCM (admin.php) */
.ssa-recap-q { padding: .75rem 0; border-bottom: 1px dashed #dee2e6; }
.ssa-recap-choix li { padding: .15rem .5rem; border-radius: .35rem; margin-bottom: .15rem; }
.ssa-recap-choix .is-bonne  { background: #d1e7dd; color: #0f5132; font-weight: 600; }
.ssa-recap-choix .is-fausse { color: #6c757d; }
.ssa-seul-bonnes .ssa-recap-choix .is-fausse { display: none; }
.ssa-ligne { background: var(--ssa-marine); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ssa-legende { display: inline-block; width: .9rem; height: .9rem; border-radius: .2rem; vertical-align: -2px; }
.ssa-legende--ok { background: #d1e7dd; border: 1px solid #a3cfbb; }
.ssa-legende--ko { background: #fff; border: 1px solid #ced4da; }
@media print { .ssa-recap-q { break-inside: avoid; } .ssa-recap-choix .is-bonne { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ==========================================================
   ADMINISTRATION
   ========================================================== */
.ssa-hero--admin { background: linear-gradient(135deg, #3a0a12 0%, var(--ssa-marine) 100%); }
.ssa-admin-tabs .nav-link { color: var(--ssa-marine); }
.ssa-admin-tabs .nav-link.active { background: var(--ssa-marine); }
.ssa-admin-choix { padding: .25rem .5rem; border-radius: .4rem; }
.ssa-admin-choix.is-bonne { background: #d1e7dd; font-weight: 500; }
.min-w-0 { min-width: 0; }
@media print {
  .ssa-hero--admin { background: none !important; color: #000; }
  .ssa-admin-q { break-inside: avoid; border-color: #999; }
  .ssa-mobilebar, .ssa-reading { display: none !important; }
}

/* ---------- Accessibilité : animations réduites si l'utilisateur le demande ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Impression ---------- */
@media print {
  .ssa-navbar, .ssa-footer, .ssa-sidebar, .ssa-stripe, .ssa-pager { display: none !important; }
  .ssa-hero { background: none; color: #000; }
}

/* Fil d'Ariane : pas de séparateur devant le premier élément visible */
@media (max-width: 575.98px) { .breadcrumb-item.d-none + .breadcrumb-item { padding-left: 0; } .breadcrumb-item.d-none + .breadcrumb-item::before { content: none; } }
