/* ============================================================
   Doctrine — feuille de style unique
   Palette : encre ardoise / papier / vert registre / ocre fiscal
   Vert  = référentiel comptable (SYSCOHADA)
   Ocre  = référentiel fiscal (CGI)
   ============================================================ */

:root {
  --papier:      #FCFCFA;
  --papier-2:    #F3F3EF;
  --encre:       #12171C;
  --graphite:    #5A6472;
  --filet:       #DEE0DA;
  --comptable:   #174A38;
  --fiscal:      #A06D14;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --colonne: 68ch;
  --rail: 148px;
}

*, *::before, *::after { box-sizing: border-box; }

a:focus-visible {
  outline: 2px solid var(--comptable);
  outline-offset: 3px;
  border-radius: 2px;
}

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

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Enveloppe ---------- */

.enveloppe {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Bandeau ---------- */

.bandeau {
  border-bottom: 1px solid var(--filet);
}

.bandeau-corps {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding-block: 22px;
}

.sceau {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--encre);
  text-decoration: none;
}

.sceau span { color: var(--comptable); }

.navigation {
  display: flex;
  gap: 26px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.navigation a {
  color: var(--graphite);
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
}

.navigation a:hover,
.navigation a:focus-visible { color: var(--encre); border-bottom-color: var(--comptable); }

/* ---------- Chapeau de page ---------- */

.chapeau {
  padding: 84px 0 64px;
  border-bottom: 1px solid var(--filet);
}

.surtitre {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--comptable);
  margin: 0 0 22px;
}

.chapeau h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.4rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.018em;
  margin: 0 0 28px;
  max-width: 19ch;
}

.chapeau p {
  max-width: 56ch;
  color: var(--graphite);
  font-size: 1.05rem;
  margin: 0;
}

/* ---------- Sommaire des articles ---------- */

.sommaire { padding: 0 0 96px; }

.entete-liste {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 36px;
  padding: 26px 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--graphite);
}

.notice {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 36px;
  padding: 32px 0;
  border-top: 1px solid var(--filet);
  text-decoration: none;
  color: inherit;
}

.notice:hover .notice-titre,
.notice:focus-visible .notice-titre { color: var(--comptable); }

.notice:focus-visible { outline: 2px solid var(--comptable); outline-offset: 6px; }

.rail { display: flex; flex-direction: column; gap: 7px; }

.renvoi {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--graphite);
}

.renvoi::before {
  content: "";
  width: 7px; height: 7px;
  flex: 0 0 7px;
}

.renvoi.c::before { background: var(--comptable); border-radius: 50%; }
.renvoi.f::before { background: var(--fiscal); transform: rotate(45deg); }

.notice-titre {
  font-size: 1.42rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  max-width: 32ch;
}

.notice-chapo {
  margin: 0 0 14px;
  color: var(--graphite);
  font-size: 0.97rem;
  max-width: 58ch;
}

.timbre {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite);
}

/* ---------- Article ---------- */

.article-tete {
  padding: 72px 0 40px;
  border-bottom: 1px solid var(--filet);
}

.article-tete h1 {
  font-size: clamp(1.9rem, 4.4vw, 2.85rem);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.018em;
  margin: 0 0 24px;
  max-width: 24ch;
}

.article-tete .resume {
  max-width: var(--colonne);
  color: var(--graphite);
  font-size: 1.08rem;
  margin: 0 0 30px;
}

.etat {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--graphite);
}

.etat .version { color: var(--fiscal); }

.corps {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 48px;
  padding-block: 52px 96px;
  align-items: start;
}

.marge { position: sticky; top: 32px; }

.marge-titre {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--filet);
}

.marge .rail + .marge-titre { margin-top: 30px; }

.texte { max-width: var(--colonne); }

.texte h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.01em;
  margin: 58px 0 18px;
}

.texte h2:first-child { margin-top: 0; }

.texte h3 {
  font-size: 1.14rem;
  font-weight: 600;
  margin: 38px 0 12px;
}

.texte p { margin: 0 0 20px; }

.texte a { color: var(--comptable); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.texte ul, .texte ol { margin: 0 0 22px; padding-left: 22px; }
.texte li { margin-bottom: 9px; }

.texte strong { font-weight: 600; }

/* Encadré d'alerte / réserve */
.reserve {
  border-left: 3px solid var(--fiscal);
  background: var(--papier-2);
  padding: 18px 22px;
  margin: 0 0 26px;
  font-size: 0.95rem;
}

.reserve p { margin: 0 0 10px; }
.reserve p:last-child { margin-bottom: 0; }

.reserve-titre {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fiscal);
  display: block;
  margin-bottom: 8px;
}

/* Tableaux : écritures et barèmes */
.texte table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 28px;
  font-size: 0.9rem;
}

.texte caption {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--graphite);
  text-align: left;
  padding-bottom: 9px;
}

.texte th {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--graphite);
  text-align: left;
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--encre);
}

.texte td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--filet);
  vertical-align: top;
}

.texte td.compte {
  font-family: var(--mono);
  font-size: 0.83rem;
  color: var(--comptable);
  white-space: nowrap;
  width: 1%;
}

.texte th.montant, .texte td.montant {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  white-space: nowrap;
  padding-right: 0;
}

.calcul {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--graphite);
  margin: -18px 0 28px;
}

/* Signature de fin */
.colophon {
  margin-top: 64px;
  padding-top: 26px;
  border-top: 1px solid var(--encre);
  font-size: 0.92rem;
  color: var(--graphite);
}

.colophon strong { color: var(--encre); }

/* ---------- Pied ---------- */

.pied {
  border-top: 1px solid var(--filet);
  padding: 40px 0 60px;
}

.pied-corps {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--graphite);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 30px;
  justify-content: space-between;
}

.pied a { color: var(--graphite); }

/* ---------- Page à propos ---------- */

.prose-simple { max-width: var(--colonne); padding: 56px 0 96px; }
.prose-simple h2 { font-size: 1.35rem; font-weight: 600; margin: 46px 0 14px; }
.prose-simple h2:first-child { margin-top: 0; }
.prose-simple p { margin: 0 0 18px; }
.prose-simple ul { padding-left: 22px; margin: 0 0 20px; }
.prose-simple li { margin-bottom: 8px; }

/* ---------- Légende du codage des références ---------- */

.legende {
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
  margin-top: 6px;
}

.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende span::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; }
.legende .c::before { background: var(--comptable); border-radius: 50%; }
.legende .f::before { background: var(--fiscal); transform: rotate(45deg); }

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

@media print {
  .bandeau, .pied, .navigation { display: none; }
  body { font-size: 11pt; background: #fff; }
  .corps { grid-template-columns: 1fr; padding: 0; }
  .marge { position: static; margin-bottom: 18pt; }
  .rail { flex-direction: row; flex-wrap: wrap; gap: 6pt 14pt; }
  .texte { max-width: none; }
  .texte h2 { margin-top: 22pt; page-break-after: avoid; }
  table, .reserve { page-break-inside: avoid; }
  .article-tete { padding-top: 0; }
}

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
  body { font-size: 17px; }
  .sceau { font-size: 11px; letter-spacing: 0.09em; }
  .navigation { gap: 20px; font-size: 11.5px; }
  .enveloppe { padding: 0 20px; }
  .chapeau { padding: 52px 0 40px; }

  .entete-liste { display: none; }

  .notice, .corps {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .corps { padding-top: 34px; }

  .marge { position: static; }
  .marge-titre { display: none; }

  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 18px;
  }

  .notice-titre { font-size: 1.24rem; }
}

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