/* Machine Noétique — charte de la famille histoire-des-sciences.eu
   Cormorant Garamond (titres) + Inter (texte), acier & or sur ardoise sombre */
:root {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #0e1626;
  --ink: #e8ecf4;
  --ink-soft: rgba(232, 236, 244, .72);
  --ink-faint: rgba(232, 236, 244, .45);
  --line: rgba(232, 236, 244, .13);
  --line-soft: rgba(232, 236, 244, .07);
  --gold: #e0a33c;
  --gold-soft: #f2c979;
  --steel: #6fb3d8;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(224, 163, 60, .35); }
.wrap { max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, .brand-title { font-family: var(--serif); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 17, 32, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: flex; align-items: center; justify-content: center;
  width: 2.3rem; height: 2.3rem; border-radius: .55rem;
  background: var(--gold); color: #131a2b; font-family: var(--serif); font-weight: 700; font-size: 1.15rem;
}
.brand-title { display: block; font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.brand-sub { display: block; font-size: .68rem; color: var(--ink-faint); line-height: 1.2; }
.nav { margin-left: auto; display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.nav a {
  padding: .35rem .8rem; border-radius: 999px; font-size: .87rem; font-weight: 500;
  color: var(--ink-soft); text-decoration: none;
}
.nav a:hover { background: rgba(232, 236, 244, .08); color: var(--ink); }
.nav a.active { background: var(--gold); color: #131a2b; font-weight: 600; }
.lang-toggle {
  border: 1px solid rgba(224, 163, 60, .55) !important;
  color: var(--gold-soft) !important;
  font-family: var(--mono); font-size: .72rem !important; font-weight: 700 !important;
  letter-spacing: .08em; padding: .3rem .65rem !important; margin-left: .4rem;
}
.lang-toggle:hover { background: rgba(224, 163, 60, .15) !important; }
.menu-toggle { display: none; margin-left: auto; font-size: 1.2rem; background: none; border: none; cursor: pointer; color: var(--ink); }
@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .nav.open { display: flex; }
}
.main { padding: 2rem 1rem 3rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface-2); }
.footer-row {
  display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; padding: 1.4rem 1rem .6rem;
  font-size: .75rem; color: var(--ink-faint);
}
.footer-right { margin-left: auto; }
.footer-eco {
  padding: 0 1rem 1.3rem; font-size: .72rem; color: var(--ink-faint); line-height: 1.6;
}
.footer-eco a { color: var(--steel); }

/* ---------- composants ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: .75rem;
  padding: 1.4rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  border-radius: 999px; border: 1px solid; padding: .15rem .65rem;
  font-size: .68rem; font-weight: 600; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge .dot { width: .4rem; height: .4rem; border-radius: 999px; }
.badge-green  { background: rgba(16, 185, 129, .13); color: #6ee7b7; border-color: rgba(110, 231, 183, .4); }
.badge-green .dot { background: #34d399; }
.badge-amber  { background: rgba(245, 158, 11, .13); color: #fcd34d; border-color: rgba(252, 211, 77, .4); }
.badge-amber .dot { background: #f59e0b; }
.badge-violet { background: rgba(139, 92, 246, .15); color: #c4b5fd; border-color: rgba(196, 181, 253, .4); }
.badge-violet .dot { background: #8b5cf6; }
.badge-red    { background: rgba(239, 68, 68, .13); color: #fca5a5; border-color: rgba(252, 165, 165, .4); }
.badge-red .dot { background: #ef4444; }
.badge-slate  { background: rgba(148, 163, 184, .13); color: #cbd5e1; border-color: rgba(148, 163, 184, .4); }
.badge-slate .dot { background: #94a3b8; }
.chip {
  display: inline-block; border-radius: .35rem; background: rgba(232, 236, 244, .08);
  padding: .1rem .55rem; font-family: var(--mono); font-size: .7rem; font-weight: 600;
  color: var(--ink-soft);
}
.chip-domain { background: rgba(111, 179, 216, .14); color: var(--steel); font-family: inherit; }
.ext-link { font-size: .78rem; font-weight: 500; }
.ext-ico { font-size: .7rem; }
.inv-num {
  display: flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 999px;
  background: rgba(224, 163, 60, .15); color: var(--gold-soft);
  font-family: var(--serif); font-weight: 700; margin-bottom: .5rem;
}

/* ---------- tableaux ---------- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .74rem; }
.data-table th {
  text-align: left; padding: .4rem .65rem; font-weight: 600; color: var(--ink);
  border-bottom: 1px solid var(--line); background: rgba(232, 236, 244, .05); white-space: nowrap;
}
.data-table td {
  padding: .25rem .65rem; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: .7rem; color: var(--ink-soft);
  max-width: 20rem; overflow: hidden; text-overflow: ellipsis;
}
.data-table tr:hover td { background: rgba(224, 163, 60, .05); }
.truncated-note {
  margin: 0; padding: .3rem .65rem; background: rgba(245, 158, 11, .1);
  font-size: .68rem; color: #fcd34d;
}

/* ---------- pliables ---------- */
.collapse { border: 1px solid var(--line); border-radius: .5rem; background: var(--surface-2); margin-bottom: .5rem; }
.collapse-head {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .55rem .85rem; background: none; border: none; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: var(--ink); text-align: left;
  font-family: var(--sans);
}
.collapse-head:hover { background: rgba(232, 236, 244, .04); }
.collapse-head .chev { color: var(--gold-soft); font-size: .8rem; }
.collapse-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collapse-badge {
  margin-left: auto; flex-shrink: 0; border-radius: .3rem; background: rgba(232, 236, 244, .1);
  padding: .1rem .4rem; font-family: var(--mono); font-size: .62rem; color: var(--ink-faint);
}
.collapse-body { border-top: 1px solid var(--line); padding: .8rem; }

/* ---------- héro accueil ---------- */
.hero {
  position: relative; border-radius: 1rem; overflow: hidden;
  background: linear-gradient(160deg, #131c33 0%, #0d1425 100%);
  border: 1px solid var(--line); color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.hero-body { padding: 2.5rem 2.5rem 2rem; }
.hero-kicker {
  font-size: .68rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold-soft); margin-bottom: .8rem;
}
.hero h1 { font-size: 2.15rem; line-height: 1.15; margin: 0 0 1rem; max-width: 46rem; font-weight: 600; }
.hero h1 em { color: var(--gold-soft); font-style: italic; }
.hero h1::after {
  content: ''; display: block; width: 4.5rem; height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent); margin-top: 1rem;
}
.hero p { max-width: 42rem; font-size: .92rem; color: var(--ink-soft); }
.hero p strong { color: var(--ink); }
.operator {
  display: inline-flex; align-items: center; gap: .7rem; margin-top: 1.2rem;
  background: rgba(224, 163, 60, .08); border: 1px solid rgba(224, 163, 60, .25);
  border-radius: .7rem; padding: .9rem 1.2rem;
  font-family: var(--mono); font-size: .9rem;
}
.operator .arrow { color: var(--gold-soft); }
.operator .verdict { color: var(--gold-soft); }
.hero-actions { margin-top: 1.6rem; display: flex; gap: .7rem; flex-wrap: wrap; }
.btn {
  display: inline-block; border-radius: 999px; padding: .6rem 1.3rem;
  font-size: .87rem; font-weight: 700; text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--gold); color: #131a2b; }
.btn-primary:hover { background: var(--gold-soft); text-decoration: none; }
.btn-ghost { border-color: rgba(232, 236, 244, .3); color: var(--ink); }
.btn-ghost:hover { background: rgba(232, 236, 244, .08); text-decoration: none; }
.hero-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--line-soft); border-top: 1px solid var(--line-soft); }
.hero-stats > div { background: #0d1425; padding: .9rem 1rem; }
.hero-stats .n { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--gold-soft); }
.hero-stats .l { font-size: .64rem; color: var(--ink-faint); line-height: 1.3; }
@media (max-width: 900px) { .hero-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .hero-stats { grid-template-columns: repeat(2, 1fr); } .hero-body { padding: 1.6rem; } }

/* ---------- grilles ---------- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- bilan ---------- */
.bilan { border-radius: .75rem; border: 1px solid; padding: 1.2rem; }
.bilan .big { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; }
.bilan p { font-size: .83rem; margin: .4rem 0 0; }
.bilan-green { background: rgba(16, 185, 129, .09); border-color: rgba(110, 231, 183, .35); color: #a7f3d0; }
.bilan-amber { background: rgba(245, 158, 11, .09); border-color: rgba(252, 211, 77, .35); color: #fde68a; }
.bilan-violet { background: rgba(139, 92, 246, .1); border-color: rgba(196, 181, 253, .35); color: #ddd6fe; }

/* ---------- résultats clés ---------- */
.keyrow {
  display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem;
  border-top: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; font-size: .85rem;
}
.keyrow:first-child { border-top: none; }
.keyrow:hover { background: rgba(224, 163, 60, .06); text-decoration: none; }
.keyrow .kid { width: 4rem; flex-shrink: 0; font-family: var(--mono); font-weight: 700; color: var(--gold-soft); }
.keyrow .ktag { flex-shrink: 0; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.keyrow .arrow { margin-left: auto; color: var(--ink-faint); }

/* ---------- catalogue ---------- */
.filters {
  display: flex; gap: .7rem; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; padding: .9rem;
}
.filters input, .filters select {
  border: 1px solid var(--line); border-radius: 999px; padding: .5rem .9rem;
  font-size: .85rem; background: var(--surface-2); color: var(--ink); outline: none;
  font-family: var(--sans);
}
.filters input { flex: 1; min-width: 14rem; }
.filters input::placeholder { color: var(--ink-faint); }
.filters input:focus, .filters select:focus { border-color: var(--gold); }
.filters select option { background: var(--surface); }
.prog-head { border-left: 3px solid var(--gold); padding-left: .8rem; margin: 2rem 0 .8rem; }
.prog-head h2 { margin: 0; font-size: 1.35rem; font-weight: 600; }
.prog-head p { margin: .15rem 0 0; font-size: .75rem; color: var(--ink-faint); }
.ch-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: .75rem; padding: 1.2rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.ch-card:hover { border-color: rgba(224, 163, 60, .45); box-shadow: 0 4px 16px rgba(0, 0, 0, .4); text-decoration: none; }
.ch-card .head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.ch-card .cid { font-family: var(--mono); font-weight: 700; color: var(--gold-soft); font-size: 1rem; }
.ch-card .score { margin-left: auto; }
.ch-card h3 { margin: 0; font-size: 1.1rem; line-height: 1.25; font-weight: 600; }
.ch-card .summary { font-size: .83rem; color: var(--ink-soft); margin: .5rem 0 0; }
.ch-card .foot {
  display: flex; gap: .8rem; flex-wrap: wrap; align-items: center;
  border-top: 1px solid var(--line-soft); margin-top: .8rem; padding-top: .7rem;
  font-size: .68rem; color: var(--ink-faint);
}
.ch-card .open { margin-left: auto; color: var(--gold-soft); font-weight: 600; }

/* ---------- fiche ---------- */
.back-link { display: inline-flex; gap: .35rem; font-size: .85rem; font-weight: 500; color: var(--ink-faint); margin-bottom: 1rem; }
.back-link:hover { color: var(--gold-soft); text-decoration: none; }
.fiche-head .cid {
  display: inline-block; border-radius: .5rem; background: var(--gold); color: #131a2b;
  font-family: var(--mono); font-weight: 700; font-size: 1.15rem; padding: .3rem .8rem;
}
.fiche-head .tags { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fiche-head h1 { font-size: 1.8rem; margin: .9rem 0 .6rem; line-height: 1.2; font-weight: 600; }
.fiche-head .summary { max-width: 46rem; font-size: .92rem; color: var(--ink-soft); }
.section-title { font-size: 1.3rem; margin: 2.2rem 0 .8rem; font-weight: 600; }
.section-sub { font-size: .75rem; color: var(--ink-faint); margin: -.4rem 0 .8rem; }
.json-card { border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.json-card .json-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); background: rgba(232, 236, 244, .03); padding: .6rem 1rem;
}
.json-card .fname { font-family: var(--mono); font-weight: 700; font-size: .85rem; }
.json-card .fmeta { font-size: .72rem; color: var(--ink-faint); }
.json-card .json-head a { margin-left: auto; }
.json-card .json-body { padding: .7rem; }
/* figures : planches claires épinglées sur fond sombre */
.figure-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .figure-grid { grid-template-columns: 1fr; } }
.figure-grid a {
  display: block; border: 1px solid var(--line); border-radius: .75rem; overflow: hidden;
  background: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}
.figure-grid img { width: 100%; display: block; }
.note-text {
  max-height: 30rem; overflow-y: auto; white-space: pre-wrap;
  background: rgba(232, 236, 244, .04); border-radius: .5rem; padding: 1rem;
  font-size: .78rem; line-height: 1.55; color: var(--ink-soft); margin: 0;
}
.script-link {
  display: inline-flex; align-items: center; gap: .45rem;
  border: 1px solid var(--line); border-radius: .5rem; background: var(--surface-2);
  padding: .5rem .9rem; font-family: var(--mono); font-size: .75rem; font-weight: 600;
  color: var(--ink); margin: 0 .5rem .5rem 0;
}
.script-link:hover { border-color: rgba(224, 163, 60, .5); color: var(--gold-soft); text-decoration: none; }
.xref-grid { display: grid; gap: .5rem; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .xref-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .xref-grid { grid-template-columns: 1fr; } }
.xref {
  display: block; border: 1px solid var(--line); border-radius: .55rem; padding: .7rem;
  color: var(--ink); text-decoration: none; transition: border-color .15s, background .15s;
  background: var(--surface-2);
}
.xref:hover { border-color: rgba(224, 163, 60, .5); background: rgba(224, 163, 60, .06); text-decoration: none; }
.xref .xhead { display: flex; align-items: center; gap: .5rem; }
.xref .xid { font-family: var(--mono); font-weight: 700; color: var(--gold-soft); font-size: .85rem; }
.xref .xtitle { font-size: .72rem; font-weight: 500; color: var(--ink-soft); margin-top: .3rem; line-height: 1.35; }
.gloss-hit { border-radius: .5rem; background: rgba(232, 236, 244, .04); padding: .6rem .9rem; margin-bottom: .5rem; font-size: .85rem; color: var(--ink-soft); }
.gloss-hit strong { color: var(--ink); }

/* ---------- lexique ---------- */
.letter { border-bottom: 1px solid var(--line); padding-bottom: .2rem; color: var(--gold-soft); font-size: 1.2rem; margin: 1.8rem 0 .7rem; }
.gloss-entry { background: var(--surface); border: 1px solid var(--line); border-radius: .7rem; padding: .9rem 1.1rem; margin-bottom: .7rem; }
.gloss-entry h3 { margin: 0 0 .25rem; font-size: 1.05rem; font-weight: 600; }
.gloss-entry p { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.gloss-links { margin-top: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.gloss-links a {
  display: inline-flex; align-items: center; gap: .25rem; border: 1px solid rgba(224, 163, 60, .35);
  background: rgba(224, 163, 60, .08); border-radius: 999px; padding: .1rem .6rem;
  font-family: var(--mono); font-size: .68rem; font-weight: 600; color: var(--gold-soft);
}
.gloss-links a:hover { background: var(--gold); color: #131a2b; text-decoration: none; }

/* ---------- markdown ---------- */
.md-h { font-family: var(--serif); color: var(--ink); margin: 1.2rem 0 .4rem; font-weight: 600; }
.md-p { font-size: .87rem; color: var(--ink-soft); margin: .5rem 0; }
.md-p strong, .md-list strong { color: var(--ink); }
.md-list { font-size: .87rem; color: var(--ink-soft); margin: .5rem 0; padding-left: 1.3rem; }
.md-list li { margin: .2rem 0; }
.md-quote {
  border-left: 3px solid rgba(224, 163, 60, .55); background: rgba(224, 163, 60, .06);
  margin: .8rem 0; padding: .5rem 1rem; font-style: italic; font-size: .87rem; color: var(--ink-soft);
}
.md-hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }
.inline-code { background: rgba(232, 236, 244, .1); border-radius: .3rem; padding: .05rem .3rem; font-family: var(--mono); font-size: .8em; }
.code-block {
  background: #080d18; color: #a7f3d0; border: 1px solid var(--line-soft);
  border-radius: .5rem; padding: .9rem;
  font-family: var(--mono); font-size: .74rem; overflow-x: auto; white-space: pre;
}
.md-link { font-weight: 500; }
.method-op {
  background: #080d18; color: #a7f3d0; border: 1px solid var(--line-soft);
  border-radius: .55rem; padding: .9rem;
  text-align: center; font-family: var(--mono); font-size: .9rem; margin: .6rem 0;
}

/* tableaux issus du markdown (explications) */
.collapse-body .table-scroll, .card .table-scroll { margin: .6rem 0; }
