/* Repères Betify — feuille de style éditoriale.
   Fond clair chaud, texte sombre, accent bleu sobre, tableaux lisibles.
   Aucune police externe : pile système uniquement. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #172337;
  --text-2: #455468;
  --accent: #164e9a;
  --accent-dark: #103a74;
  --border: #d4dce6;
  --warn-bg: #fff8e8;
  --warn-border: #d8b86a;
  --radius: 6px;
  --maxw: 72rem;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* --- Liens --- */

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-dark);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* --- Skip link --- */

/* Masqué visuellement sans créer de débordement horizontal. */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  background: var(--surface);
  color: var(--accent);
  padding: 0.75rem 1rem;
  z-index: 50;
  border: 2px solid var(--accent);
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  width: auto;
  height: auto;
  clip-path: none;
  overflow: visible;
}

/* --- En-tête --- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  padding: 0.35rem 0;
  display: inline-block;
  min-height: 2.2rem;
}

.brand-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.brand-tagline {
  font-size: 0.82rem;
  color: var(--text-2);
}

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.25rem 0.25rem;
  font-size: 0.97rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* --- Mise en page de la page --- */

.page {
  padding-top: 1.25rem;
  padding-bottom: 3rem;
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0;
  font-size: 0.9rem;
  color: var(--text-2);
}

.breadcrumb li + li::before {
  content: "›";
  margin-right: 0.35rem;
  color: var(--text-2);
}

.breadcrumb a {
  display: inline-block;
  padding: 0.3rem 0;
}

.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem 2rem;
}

.article-head h1 {
  font-size: 1.85rem;
  line-height: 1.25;
  margin: 0 0 0.75rem;
  max-width: min(34ch, 100%);
  overflow-wrap: break-word;
}

.lede {
  font-size: 1.08rem;
  color: var(--text);
  margin: 0 0 0.75rem;
  max-width: min(70ch, 100%);
}

.review-date {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-2);
}

.article-body {
  max-width: min(72ch, 100%);
}

/* `min()` évite qu'une colonne exprimée en `ch` dépasse un écran étroit
   ou un texte agrandi par l'utilisateur. */
.article-body > * {
  max-width: min(70ch, 100%);
}

.article-body h2 {
  font-size: 1.35rem;
  line-height: 1.3;
  margin: 2.25rem 0 0.75rem;
  padding-top: 0.25rem;
  scroll-margin-top: 1rem;
}

.article-body h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
  scroll-margin-top: 1rem;
}

.article-body p,
.article-body li {
  overflow-wrap: anywhere;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4rem;
}

.article-body li {
  margin-bottom: 0.4rem;
}

code,
td,
th {
  overflow-wrap: anywhere;
}

code {
  background: #eef1f6;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.3em;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

blockquote.modele {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  background: #f4f7fb;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

blockquote.modele p {
  margin: 0 0 0.7rem;
}

blockquote.modele p:last-child {
  margin-bottom: 0;
}

/* --- Table des matières --- */

.toc {
  margin: 1.5rem 0 0.5rem;
}

.toc-details {
  background: #f2f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
}

.toc-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.toc-list {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.6rem;
  font-size: 0.95rem;
}

/* Les intitulés longs tiennent sur deux lignes : le numéro reste aligné
   sur la première ligne, pas sur la dernière. */
.toc-list {
  list-style: none;
  counter-reset: toc;
  padding-left: 0;
}

.toc-list li {
  counter-increment: toc;
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.25rem;
  margin-bottom: 0.45rem;
  line-height: 1.4;
}

.toc-list li::before {
  content: counter(toc) ".";
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  padding-top: 0.2rem;
}

.toc-list a {
  display: inline-block;
  padding: 0.2rem 0;
}

/* --- Tableaux --- */

.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}

table {
  border-collapse: collapse;
  width: 100%;
  /* La largeur minimale garde les colonnes lisibles ; le défilement reste
     confiné au conteneur `.table-wrap`, jamais à la page entière. */
  min-width: 34rem;
  font-size: 0.95rem;
  background: var(--surface);
}

caption {
  caption-side: top;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text-2);
  padding: 0.6rem 0.75rem;
  background: #f2f5f9;
  border-bottom: 1px solid var(--border);
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: #eef1f6;
  font-size: 0.9rem;
}

tbody th[scope="row"] {
  font-weight: 600;
  background: #f8fafc;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: none;
}

/* --- Encadrés --- */

.notice {
  margin: 1.25rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: #f4f7fb;
  font-size: 0.95rem;
  max-width: min(70ch, 100%);
}

.notice p {
  margin: 0 0 0.6rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

/* Avis de préversion : destiné au déploiement, replié et discret en pied de page. */
.preview-flag {
  margin: 1.25rem 0 0;
  padding: 0.5rem 0.75rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: #6b4c05;
  max-width: min(70ch, 100%);
}

/* `display: flex` supprimerait le marqueur de révélation : on garde `list-item`. */
.preview-flag > summary {
  cursor: pointer;
  min-height: 44px;
  padding: 0.6rem 0;
  list-style-position: inside;
}

.preview-flag p {
  margin: 0.5rem 0 0;
}

/* Les noms de clés de configuration sont longs : ils doivent pouvoir se couper
   plutôt que pousser la page en débordement horizontal. */
.notice-keys {
  overflow-wrap: anywhere;
}

.notice-keys code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Marqueur de réquisit non renseigné : lisible comme un champ à remplir,
   sans l'aspect d'une erreur d'exécution. */
.config-missing {
  display: inline;
  background: transparent;
  border-bottom: 1px dashed var(--warn-border);
  padding: 0 0.1em;
  font-size: 0.95em;
  font-style: italic;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* --- Accueil --- */

.hero {
  max-width: min(70ch, 100%);
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}

.hero-cta:hover {
  background: var(--accent-dark);
  color: #fff;
  text-decoration: underline;
}

.next-step {
  margin: 2rem 0 0;
  padding: 1rem 1.1rem;
  background: #f2f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: min(70ch, 100%);
}

.next-step h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

/* Mention d'une source citée sans lien sortant. */
.source-ref {
  overflow-wrap: anywhere;
}

/* Note de source rattachée au paragraphe qui précède : plus discrète que le
   corps du texte, mais toujours lisible et imprimée avec l'article. */
.article-body .source-note {
  margin: -0.4rem 0 1.1rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-2);
}

.article-body .source-note .source-ref {
  font-style: italic;
}

.sources-block {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-2);
}

.sources-block h2,
.sources-block h3 {
  color: var(--text);
}

/* --- Module de dossier local (P5) --- */

.dossier {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 1rem 1rem 1.25rem;
  max-width: 100%;
}

.dossier h3 {
  margin-top: 0.25rem;
}

.dossier-note {
  font-size: 0.92rem;
  color: var(--text-2);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  margin: 0 0 1rem;
}

.dossier-form {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 46rem) {
  .dossier-form {
    grid-template-columns: 1fr 1fr;
  }
  .dossier-field--wide {
    grid-column: 1 / -1;
  }
}

.dossier-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dossier-field label {
  font-size: 0.92rem;
  font-weight: 600;
}

/* La consigne passe sous l'intitulé : les deux restent distincts à la lecture. */
.dossier-field .hint {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--text-2);
  font-weight: 400;
}

.dossier-field input,
.dossier-field select,
.dossier-field textarea {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.6rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  width: 100%;
}

.dossier-field textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.dossier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 44px;
  min-width: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn--secondary {
  background: #fff;
  color: var(--accent);
}

.btn--secondary:hover {
  background: #eef3fa;
}

.btn--quiet {
  background: #fff;
  color: var(--text-2);
  border-color: var(--border);
}

.btn--quiet:hover {
  background: #f0f2f6;
  color: var(--text);
}

.dossier-status {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  color: var(--text-2);
  min-height: 1.5rem;
}

/* `.article-body ul` applique un retrait aux listes de texte : la liste des
   fiches est une grille de cartes et doit rester alignée sur le module. */
.article-body .dossier-entries,
.dossier-entries {
  list-style: none;
  margin: 1.25rem 0 0;
  padding-left: 0;
  display: grid;
  gap: 0.9rem;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.85rem 0.9rem;
}

.entry-card h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.entry-fields {
  margin: 0;
  display: grid;
  gap: 0.35rem 1rem;
  grid-template-columns: 1fr;
  font-size: 0.92rem;
}

@media (min-width: 40rem) {
  .entry-fields {
    grid-template-columns: 14rem 1fr;
  }
}

.entry-fields dt {
  font-weight: 600;
  color: var(--text-2);
}

.entry-fields dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.dossier-empty {
  font-size: 0.95rem;
  color: var(--text-2);
}

[hidden] {
  display: none !important;
}

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

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  font-size: 0.92rem;
  color: var(--text-2);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.footer-publisher,
.footer-frame {
  margin: 0 0 0.5rem;
  max-width: min(70ch, 100%);
}

/* --- Bureau : article + sommaire latéral --- */

@media (min-width: 64rem) {
  .article {
    padding: 2rem 2rem 2.5rem;
  }

  .article-body {
    max-width: min(74ch, 100%);
  }

  .article-head h1 {
    font-size: 2.1rem;
  }

  /* Chaque bloc reçoit sa propre rangée : rien ne recouvre le H1. */
  .article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    grid-template-areas:
      "head toc"
      "body toc";
    column-gap: 2.5rem;
  }

  .article-head {
    grid-area: head;
  }

  .article-body {
    grid-area: body;
  }

  .toc {
    grid-area: toc;
    align-self: start;
    position: sticky;
    top: 1rem;
    margin-top: 0.5rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

/* --- Mouvement réduit --- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* --- Impression : dossier lisible --- */

@media print {
  .site-header,
  .site-footer,
  .toc,
  .skip-link,
  .breadcrumb,
  .dossier-form,
  .dossier-actions,
  .dossier-status,
  .entry-actions,
  .hero-cta,
  .preview-flag {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 12pt;
  }

  .article {
    border: none;
    padding: 0;
    display: block;
  }

  .entry-card,
  .table-wrap {
    break-inside: avoid;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}
