/* ============================================================
   style.css — feuille de style commune des sites mywesh.com
   ------------------------------------------------------------
   Contraintes :
   - palette strictement limitée aux douze couleurs déclarées
     dans :root (les gradients entre ces couleurs sont admis) ;
   - police principale : Times New Roman, noire sur fond blanc.

   Organisation :
     1. Variables (couleurs, typographie, espacements)
     2. Remise à zéro et base typographique
     3. Mise en page (conteneur, prose, grilles)
     4. En-tête et navigation
     5. Bandeau d'ouverture (.hero)
     6. Règle chronologique (.ruler)
     7. Chapitres à bandeau latéral (.era)
     8. Sections ordinaires (.section)
     9. Composants : chronologie, notes, planches, tableaux,
        dépliants, glossaire, références, étiquettes
    10. Diagrammes SVG (.diagram)
    11. Pied de page
    12. Utilitaires
    13. Écrans étroits et impression
   ============================================================ */


/* 1. Variables ------------------------------------------------ */

:root {
  /* Palette (ne pas ajouter d'autres couleurs) */
  --paper: #FFFFFF;
  --ink: #14161A;
  --ink-soft: #54585F;
  --rule-strong: #14161A;
  --rule: #CFCFCB;
  --accent: #0B5FA5;
  --gold: #F2B705;
  --gold-dark: #8A6A00;
  --alert: #B01019;
  --live: #C72E32;
  --bottle-green: #0F3D2E;
  --tint: #FBF8F0;

  /* Typographie */
  --font-main: "Times New Roman", Times, "Liberation Serif", serif;
  --text-xs: 0.8125rem;   /* 13 px */
  --text-s: 0.9375rem;    /* 15 px */
  --text-m: 1.125rem;     /* 18 px — corps de texte */
  --text-l: 1.375rem;     /* 22 px */
  --text-xl: 1.75rem;     /* 28 px */
  --text-xxl: 2.25rem;    /* 36 px */
  --text-display: clamp(2.5rem, 6vw, 4.75rem);
  --leading: 1.55;

  /* Mise en page */
  --measure: none;              /* longueur de ligne maximale (none : pleine largeur) */
  --page-width: none;           /* largeur maximale de la page (none : pleine largeur) */
  --gutter: clamp(1rem, 4vw, 4rem);
  --band-width: 4.5rem;         /* largeur du bandeau latéral des chapitres */

  /* Espacements */
  --space-xs: 0.25rem;
  --space-s: 0.5rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2.5rem;
  --space-xxl: 4rem;
}


/* 2. Remise à zéro et base typographique ---------------------- */

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

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

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

body {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--text-m);
  line-height: var(--leading);
  color: var(--ink);
  background-color: var(--paper);
  -webkit-hyphens: auto;
  hyphens: auto;                        /* coupure des mots selon l'attribut lang */
  hyphenate-limit-chars: 7 3 3;         /* mots ≥ 7 lettres, ≥ 3 lettres de chaque côté */
}

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  font-weight: normal;
  line-height: 1.15;
  margin: 0 0 0.5em;
  color: var(--ink);
  text-wrap: balance;
  -webkit-hyphens: manual;
  hyphens: manual;                      /* pas de coupure dans les titres */
}
h1 { font-size: var(--text-xxl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-l); }
h4 { font-size: var(--text-m); font-weight: bold; }
h5, h6 { font-size: var(--text-s); font-weight: bold; }

p, ul, ol, dl, figure, table, blockquote, pre { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.3em; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

strong, b { font-weight: bold; }
em, i, cite, dfn { font-style: italic; }
/* Un nom latin (i) dans un passage déjà en italique repasse en romain */
em i, i i, cite i, blockquote i, figcaption i, .italic i { font-style: normal; }

abbr[title] {
  text-decoration: underline dotted;
  text-decoration-color: var(--ink-soft);
  cursor: help;
}

sup, sub { font-size: 0.75em; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }

small, .small { font-size: var(--text-s); }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-xl) 0;
}

img, svg { max-width: 100%; height: auto; }

blockquote {
  padding-left: 1.25rem;
  border-left: 3px solid var(--gold-dark);
  font-style: italic;
}
blockquote cite, blockquote footer { font-style: normal; font-size: var(--text-s); color: var(--ink-soft); }

code, kbd, samp { font-family: "Courier New", Courier, monospace; font-size: 0.9em; }


/* 3. Mise en page --------------------------------------------- */

.container {
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.prose { max-width: var(--measure); }

/* Texte courant justifié (les titres, la navigation et les tableaux restent alignés à gauche) */
.prose,
.hero__lede,
.hero__meta,
.timeline,
.note,
.disclosure__body,
.glossary dd,
.references,
blockquote,
figcaption {
  text-align: justify;
}

.grid { display: grid; gap: var(--space-l); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.skip-link {
  position: absolute;
  left: var(--space-m);
  top: -100%;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--paper);
}
.skip-link:focus { top: var(--space-m); }


/* 4. En-tête et navigation ------------------------------------ */

.site-header { position: relative; }

/* Filet d'identité : un dégradé vert bouteille → or */
.site-header::after {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--bottle-green), var(--gold-dark) 55%, var(--gold));
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s) var(--space-l);
  padding-block: var(--space-m);
}

.site-title {
  margin: 0;
  font-size: var(--text-l);
  font-style: italic;
}
.site-title a { color: var(--ink); text-decoration: none; }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.site-nav li { margin: 0; }
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-s);
  padding-bottom: 0.1em;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { border-bottom-color: var(--gold-dark); }


/* 5. Bandeau d'ouverture -------------------------------------- */

.hero {
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(1.5rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
}

.hero__title {
  font-size: var(--text-display);
  font-style: italic;
  line-height: 1.02;
  letter-spacing: -0.012em;
  max-width: 16ch;
  margin-bottom: 0.4em;
}

.hero__lede {
  font-size: var(--text-l);
  line-height: 1.4;
  max-width: var(--measure);
}

.hero__meta {
  font-size: var(--text-s);
  color: var(--ink-soft);
  max-width: var(--measure);
}


/* 6. Règle chronologique -------------------------------------- */
/* Les largeurs sont proportionnelles à la durée : chaque segment
   reçoit sa durée dans la variable --span (ex. style="--span: 53.4"). */

.ruler { margin: var(--space-xl) 0 0; }

.ruler__track {
  display: flex;
  width: 100%;
  height: 2.25rem;
  border: 1px solid var(--rule-strong);
}

.ruler__era {
  display: flex;
  flex: var(--span, 1) 1 0;
  min-width: 0;
  color: var(--paper);
  border-left: 2px solid var(--paper);
}
.ruler__era:first-child { border-left: 0; }

.ruler__era--ink { background: linear-gradient(90deg, var(--ink), var(--ink-soft)); }
.ruler__era--green { background: var(--bottle-green); }
.ruler__era--gold-dark { background: var(--gold-dark); }
.ruler__era--gold { background: var(--gold); color: var(--ink); }

.ruler__period {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: var(--span, 1) 1 0;
  min-width: 0.3rem;
  overflow: hidden;
  border-left: 1px solid var(--paper);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.ruler__period:first-child { border-left: 0; }
.ruler__period abbr { text-decoration: none; }

/* Filet continu : le temps « coule » du noir de l'Archéen à l'or du présent */
.ruler__flow {
  height: 0.4rem;
  margin-top: 0.3rem;
  background: linear-gradient(90deg, var(--ink), var(--bottle-green) 22%, var(--gold-dark) 62%, var(--gold));
}

.ruler__scale {
  display: flex;
  margin-top: 0.35rem;
  font-size: var(--text-xs);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.ruler__scale > span {
  flex: var(--span, 1) 1 0;
  min-width: 0;
  white-space: nowrap;
}
.ruler__scale > span:last-child {
  display: flex;
  justify-content: space-between;
}

.ruler__legend {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: var(--text-s);
}
.ruler__legend li { margin: 0; }
.ruler__legend abbr { font-weight: bold; text-decoration: none; }


/* 7. Chapitres à bandeau latéral ------------------------------ */
/* Le bandeau (.era__band) reste visible pendant le défilement
   du chapitre et porte le nom de la période, écrit verticalement. */

.era {
  display: grid;
  grid-template-columns: var(--band-width) minmax(0, 1fr);
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
  padding-block: clamp(2rem, 5vw, 3.5rem);
}
.era + .era { border-top: 1px solid var(--rule); }

.era__band {
  position: sticky;
  top: var(--space-l);
  align-self: start;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  min-height: 16rem;
  max-height: calc(100vh - 3rem);
  padding: 1.25rem 0.4rem;
  color: var(--paper);
  background: var(--band, var(--ink));
}
.era__band > * {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin: 0;
}
.era__band-name {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: var(--text-l);
  line-height: 1;
}
.era__band-age {
  font-size: var(--text-xs);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Variantes de bandeau (couleurs de la palette, gradients admis) */
.era--ink            { --band: linear-gradient(180deg, var(--ink), var(--ink-soft)); }
.era--green          { --band: var(--bottle-green); }
.era--green-gold     { --band: linear-gradient(180deg, var(--bottle-green) 0 70%, var(--gold-dark)); }
.era--gold-dark      { --band: var(--gold-dark); }
.era--gold-dark-gold { --band: linear-gradient(180deg, var(--gold-dark) 0 82%, var(--gold)); }
.era--gold           { --band: var(--gold); }
.era--gold .era__band { color: var(--ink); }

.era__body { min-width: 0; }

.era__title {
  font-size: var(--text-xxl);
  line-height: 1.08;
  margin-bottom: 0.35em;
  max-width: 24ch;
}
.era__dates {
  font-size: var(--text-s);
  color: var(--ink-soft);
  margin-bottom: var(--space-l);
  font-variant-numeric: tabular-nums;
}
.era__body h3 { margin-top: var(--space-xl); }


/* 8. Sections ordinaires -------------------------------------- */

.section {
  padding-block: clamp(2rem, 5vw, 3.5rem);
  border-top: 1px solid var(--rule-strong);
}
.section__title {
  font-size: var(--text-xxl);
  line-height: 1.08;
  margin-bottom: 0.6em;
}


/* 9. Composants ----------------------------------------------- */

/* Chronologie : liste verticale à repères */
.timeline {
  list-style: none;
  margin: var(--space-l) 0 var(--space-xl);
  padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--bottle-green);
  max-width: var(--measure);
}
.timeline li { position: relative; margin: 0 0 1rem; }
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1.5rem - 0.375rem - 1px);
  top: 0.5em;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bottle-green);
}
.timeline__date {
  display: block;
  font-size: var(--text-s);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* Notes en marge du texte */
.note {
  max-width: var(--measure);
  margin: var(--space-l) 0;
  padding: 0.9rem 1.1rem;
  border-left: 4px solid var(--gold-dark);
  background: var(--tint);
  font-size: var(--text-s);
}
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.note--accent { border-left-color: var(--accent); }
.note--alert { border-left-color: var(--alert); }
.note--green { border-left-color: var(--bottle-green); }
.note__title { display: block; font-weight: bold; margin-bottom: 0.25rem; }

/* Planches (figures encadrées) */
.plate {
  margin: var(--space-xl) 0;
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--rule-strong);
  background: var(--paper);
}
.plate--tint { background: linear-gradient(180deg, var(--paper), var(--tint)); }
.plate figcaption,
figure > figcaption {
  margin-top: 0.9rem;
  font-size: var(--text-s);
  color: var(--ink-soft);
  line-height: 1.45;
}
.plate figcaption strong, figure > figcaption strong { color: var(--ink); }

/* Tableaux */
.table-wrap { overflow-x: auto; margin: var(--space-l) 0 var(--space-xl); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-s);
  line-height: 1.4;
}
caption {
  caption-side: top;
  text-align: left;
  font-weight: bold;
  padding: 0 0 0.6rem;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
}
thead th { border-bottom: 2px solid var(--rule-strong); }
tbody th { font-weight: bold; }
tbody tr:hover { background: var(--tint); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Dépliants (details/summary) */
.disclosure {
  max-width: var(--measure);
  margin: var(--space-l) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.disclosure summary {
  position: relative;
  cursor: pointer;
  padding: 0.75rem 0 0.75rem 1.5rem;
  font-weight: bold;
  list-style: none;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before {
  content: "+";
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 1rem;
  text-align: center;
  color: var(--gold-dark);
  font-weight: bold;
}
.disclosure[open] summary::before { content: "\2212"; } /* signe moins */
.disclosure__body { padding: 0 0 1rem 1.5rem; font-size: var(--text-s); }
.disclosure__body > :last-child { margin-bottom: 0; }

/* Glossaire */
.glossary {
  display: grid;
  grid-template-columns: minmax(10rem, max-content) 1fr;
  gap: 0.6rem 1.75rem;
  max-width: var(--measure);
}
.glossary dt { font-weight: bold; scroll-margin-top: var(--space-xl); }
.glossary dt:target { background: var(--gold); }
.glossary dd { margin: 0; }

/* Termes définis : le mot est souligné (élément <u>, donc souligné même
   sans cette feuille) ; sa définition apparaît dans une bulle au survol de
   la souris ou au focus clavier, sous le mot. Le mot n'est pas un lien.
   Balisage :
   <u class="term" tabindex="0" aria-describedby="def-1">mot
     <span class="term__def" id="def-1" role="tooltip" hidden>Définition.</span></u>
   L'attribut hidden garantit que la définition reste invisible tant que
   cette feuille n'est pas chargée. */
p, li, dd, td, th, figcaption { position: relative; }   /* ancêtres de positionnement des bulles */

.term {
  cursor: help;
  text-decoration: underline solid;
  text-decoration-color: var(--gold-dark);   /* souligné or foncé : distinct des liens (bleus) */
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}
.term:hover,
.term:focus-visible {
  text-decoration-thickness: 2.5px;
}
.term__def {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  width: max-content;                   /* boîte ajustée au texte… */
  max-width: 100%;                      /* …sans jamais dépasser le paragraphe */
  z-index: 20;
  margin-top: 0.3rem;                   /* juste sous la ligne du mot survolé */
  padding: 0.5rem 0.8rem;
  font-size: var(--text-s);
  line-height: 1.4;
  font-style: normal;
  font-weight: normal;
  text-align: left;
  text-decoration: none;
  -webkit-hyphens: manual;
  hyphens: manual;
  color: var(--ink);
  background: var(--tint);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--gold-dark);
}
.term:hover .term__def,
.term:focus .term__def { display: block; }

/* Navigateurs qui connaissent le positionnement par ancre : la bulle
   s'accroche sous le mot lui-même (vers la droite, ou vers la gauche si la
   place manque, ou au-dessus en bas de fenêtre). Ailleurs, elle s'aligne
   au bord gauche du paragraphe, sous la ligne du mot. */
@supports (anchor-name: --x) and (anchor-scope: --x) {
  .term {
    anchor-name: --term;
    anchor-scope: --term;               /* chaque bulle ne voit que son propre mot */
  }
  .term__def {
    position: fixed;                    /* rapportée à la fenêtre : la place ne manque jamais */
    position-anchor: --term;
    left: auto;
    right: auto;
    position-area: block-end span-inline-end;          /* sous le mot, vers la droite… */
    position-try-fallbacks: flip-inline, flip-block;   /* …sinon vers la gauche, sinon au-dessus */
    min-width: 14rem;
    max-width: 28rem;
  }
}

/* Références bibliographiques */
.references {
  font-size: var(--text-s);
  padding-left: 2.2em;
  max-width: var(--measure);
}
.references li { margin-bottom: 0.55em; padding-left: 0.2em; }
.references li::marker { color: var(--ink-soft); }

/* Étiquettes */
.tag {
  display: inline-block;
  font-size: var(--text-xs);
  line-height: 1.3;
  padding: 0.1em 0.5em;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  vertical-align: middle;
  white-space: nowrap;
}
.tag--debate { border-color: var(--alert); color: var(--alert); }
.tag--green { border-color: var(--bottle-green); color: var(--bottle-green); }
.tag--accent { border-color: var(--accent); color: var(--accent); }


/* 10. Diagrammes SVG ------------------------------------------ */

.diagram {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font-main);
}
.diagram__line { fill: none; stroke: var(--bottle-green); stroke-width: 2; stroke-linecap: square; }
.diagram__line--soft { stroke: var(--rule); }
.diagram__label { fill: var(--ink); font-size: 14px; }
.diagram__label--sub { fill: var(--ink-soft); font-size: 11px; }
.diagram__label--branch { fill: var(--ink-soft); font-size: 11px; font-style: italic; }
.diagram__label--title { fill: var(--ink); font-size: 13px; font-style: italic; }
.diagram__node { fill: var(--gold); stroke: var(--bottle-green); stroke-width: 2; }
.diagram__box { fill: var(--tint); stroke: var(--rule-strong); stroke-width: 1.5; }
.diagram__arrow { fill: none; stroke: var(--gold-dark); stroke-width: 2; }
.diagram__arrowhead { fill: var(--gold-dark); }


/* 11. Pied de page -------------------------------------------- */

.site-footer {
  margin-top: var(--space-xxl);
  padding-block: var(--space-xl);
  border-top: 1px solid var(--rule-strong);
  font-size: var(--text-s);
  color: var(--ink-soft);
}
.site-footer p { margin-bottom: 0.4em; }


/* 12. Utilitaires --------------------------------------------- */

.muted { color: var(--ink-soft); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sc { font-variant: small-caps; letter-spacing: 0.05em; }
.lead { font-size: var(--text-l); line-height: 1.4; }
.flow > * + * { margin-top: 1em; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}


/* 13. Écrans étroits et impression ---------------------------- */

@media (max-width: 47.99em) {
  .era { grid-template-columns: 1fr; }
  .era__band {
    position: static;
    min-height: 0;
    max-height: none;
    justify-content: flex-start;
    gap: 1rem;
    padding: 0.5rem 1rem;
    margin-bottom: var(--space-l);
  }
  .era__band > * { writing-mode: horizontal-tb; transform: none; }
  .glossary { grid-template-columns: 1fr; gap: 0.15rem; }
  .glossary dd { margin-bottom: 0.75rem; padding-left: 1rem; }
  .ruler__period { font-size: 0.7rem; }
  .ruler__legend { font-size: var(--text-xs); }
  .term__def {                          /* sur écran étroit : bandeau fixe en bas de l'écran */
    position: fixed;
    position-anchor: auto;
    position-area: none;
    position-try-fallbacks: none;
    left: var(--gutter);
    right: var(--gutter);
    bottom: var(--space-m);
    width: auto;
    min-width: 0;
    max-width: none;
    margin-top: 0;
  }
}

@media print {
  .skip-link, .site-nav { display: none; }
  .era__band { position: static; }
  a { color: inherit; text-decoration: none; }
  h2, h3 { break-after: avoid; }
  .plate, .note, table, .timeline li { break-inside: avoid; }
  .term { text-decoration: none; }
  .term__def { display: none !important; }
}