/* Feuille de style du site. Les couleurs sont regroupées ici : changer une valeur la change partout. */
@font-face { font-family: "Source Sans 3"; src: url(sans.woff2) format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(serif.woff2) format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(serif-italique.woff2) format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f6;
  --text: #1e2330; --muted: #5b6475; --border: #dde1e8;
  --accent: #2b5cab; --accent-soft: #e7eefa;
  --ok: #2b7a4b; --ok-soft: #e4f2e9;
  --bad: #b03d36; --bad-soft: #f8e6e4;
  --warn: #8a5a12; --warn-soft: #fbf0dc;
  --trait: #1e2330;
  --shadow: 0 1px 2px rgba(30, 35, 48, .06);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d222b; --surface: #252b36; --surface-2: #2b3240;
  --text: #e4e7ec; --muted: #a3abb9; --border: #384152;
  --accent: #8fb3f0; --accent-soft: #2c3a52;
  --ok: #82cfa0; --ok-soft: #233a2e;
  --bad: #f0a097; --bad-soft: #43292a;
  --warn: #e9c07a; --warn-soft: #3d3222;
  --trait: #c9ced8;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--serif); font-size: 1.0625rem; line-height: 1.65; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }

/* ---------- barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; height: 3.5rem; padding: 0 1rem 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border); font-family: var(--sans); }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: .45rem; font: 500 .95rem var(--sans); color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .75rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 1.1rem; height: 1.1rem; }
.menu-btn { display: none; }
:root[data-theme="dark"] #iconMoon, :root:not([data-theme="dark"]) #iconSun { display: none; }
html:not(.js) #themeBtn { display: none; }
.avis { margin: 0; padding: .45rem 1.25rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border); font: .92rem/1.4 var(--sans); }

/* ---------- mise en page ---------- */
.layout { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); }
.side { position: sticky; top: 3.5rem; height: calc(100vh - 3.5rem); overflow-y: auto; padding: 1.25rem .9rem 2rem;
  border-right: 1px solid var(--border); background: var(--surface); font-family: var(--sans); }
.nav-chap { margin: 1.4rem .6rem .35rem; font-size: .82rem; font-weight: 700; color: var(--muted); line-height: 1.35; }
.nav-link { display: block; padding: .38rem .65rem; border-radius: 7px; color: var(--text); text-decoration: none; font-size: .97rem; line-height: 1.35; }
.nav-link.sub { padding-left: 1.1rem; }
.nav-link small { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { padding: 2.25rem 2rem 3rem; min-width: 0; }
.page { max-width: 47rem; margin: 0 auto; }
.page-head { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.crumb { margin: 0 0 .25rem; font: 500 .95rem var(--sans); color: var(--muted); }
h1, h2, h3, h4 { font-family: var(--sans); line-height: 1.3; }
.page-head h1 { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: -.01em; }
.lead { font-size: 1.15rem; color: var(--muted); }
.hint { color: var(--muted); font: .95rem var(--sans); }
.outils { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; margin: 0 0 1.5rem; }
.callout { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; padding: .6rem 1.1rem; margin: 1.25rem 0; }
.callout p { margin: .3rem 0; }
.callout.attente { font-family: var(--sans); font-size: .98rem; }
.pied { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); font: .88rem var(--sans); color: var(--muted); text-align: center; }

/* ---------- accueil ---------- */
.chap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.chap-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem .7rem; box-shadow: var(--shadow); }
.chap-num { margin: 0 0 .6rem; font: 600 .9rem var(--sans); color: var(--accent); }
.chap-links { list-style: none; padding: 0; margin: 0; font-family: var(--sans); }
.chap-links li { border-top: 1px solid var(--border); }
.chap-links a { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; text-decoration: none; color: var(--text); line-height: 1.35; }
.chap-links a:hover { color: var(--accent); text-decoration: underline; }
.count { color: var(--muted); font-size: .88rem; white-space: nowrap; align-self: center; }

/* ---------- contenu du cours ---------- */
.cours h2 { font-size: 1.35rem; margin: 2.25rem 0 .75rem; font-weight: 700; }
.cours > h2:first-child { margin-top: 0; }
.cours h3 { font-size: 1.12rem; margin: 1.6rem 0 .5rem; }
.cours h4 { font-size: .95rem; margin: 1.3rem 0 .3rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.cours p { margin: .7rem 0; }
.cours ul, .cours ol { padding-left: 1.4rem; margin: .6rem 0; }
.cours li { margin: .35rem 0; }
.cours b, .cours strong { font-weight: 600; }
.cours .centre { text-align: center; }
.cours .petit { font-size: .92rem; color: var(--muted); }
.cours hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.cours .encadre { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0;
  padding: .55rem 1.2rem; margin: 1.25rem 0; box-shadow: var(--shadow); }
.cours .savoir { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem 1.3rem 1rem; margin: 1rem 0; box-shadow: var(--shadow); }
.cours .cols { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: .8rem 0; }
.cours .col { flex: 1 1 13rem; min-width: 0; }
.cours img { background: #fff; border-radius: 8px; vertical-align: middle; }
:root[data-theme="dark"] .cours img { padding: 4px; }
.cours img.petite { max-height: 6.5rem; }
.cours img.moyenne { max-height: 12rem; }
.cours img.grande { width: 100%; }

.defile { overflow-x: auto; margin: 1rem 0; }
.cours table { border-collapse: collapse; background: var(--surface); font-size: .98rem; }
.cours td, .cours th { border: 1px solid var(--border); padding: .5rem .8rem; vertical-align: top; text-align: left; }
.cours th { font-family: var(--sans); font-weight: 600; background: var(--surface-2); }
.cours td.centre, .cours th.centre { text-align: center; }
.cours td.gris { background: var(--surface-2); }
.cours table.sans-bord { background: none; }
.cours table.sans-bord td, .cours table.sans-bord th { border: 0; background: none; padding: .3rem .9rem; font-size: 1.08rem; }
.cours table.etroit td, .cours table.etroit th { padding: .3rem .5rem; font-size: .92rem; text-align: center; min-width: 2.1rem; }

/* écriture mathématique */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .92em; line-height: 1.25; margin: 0 .15em; }
.frac > .num { padding: 0 .3em .06em; border-bottom: 1px solid var(--trait); }
.frac > .den { padding: .06em .3em 0; }
.rac { border-top: 1px solid var(--trait); padding: 0 .12em; }
.angle { position: relative; display: inline-block; }
.angle::before { content: ""; position: absolute; left: 0; right: 0; top: -.05em; height: .3em; background: currentColor;
  clip-path: polygon(0 100%, 50% 0, 100% 100%, 94% 100%, 50% 24%, 6% 100%); }

/* trous */
.trou { display: inline-block; min-width: 3em; min-height: 1.5em; padding: 0 .3em; border-bottom: 2px dotted var(--muted); text-align: center; vertical-align: bottom; line-height: 1.45; }
.trou.t1 { min-width: 2.6em; } .trou.t2 { min-width: 5em; } .trou.t3 { min-width: 9em; } .trou.t4 { min-width: 14em; } .trou.t5 { min-width: 19em; }
.frac .trou { min-width: 2em; }
.trou.rep { color: var(--accent); font-weight: 600; border-radius: 5px 5px 0 0; }
.js .trou.rep { cursor: pointer; background: var(--accent-soft); border-bottom-color: var(--accent); }
.js .trou.rep:hover { background: var(--surface-2); }
.js .trou.rep:not(.vu) .r { visibility: hidden; }
.js .trou.rep.vu { background: none; }
.trou-bloc.vide { margin: .6rem 0 1rem; }
.trou-bloc.vide i { display: block; height: 1.8em; border-bottom: 2px dotted var(--muted); }
details.correction { margin: .9rem 0 1.2rem; }
details.correction > summary { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; list-style: none; font: 600 .95rem var(--sans);
  color: var(--accent); background: var(--accent-soft); border-radius: 7px; padding: .35rem .8rem; }
details.correction > summary::-webkit-details-marker { display: none; }
details.correction > summary::before { content: "+"; font-weight: 700; width: .8rem; text-align: center; }
details.correction[open] > summary::before { content: "−"; }
details.correction[open] > summary { margin-bottom: .5rem; }
details.correction[open] { border-left: 3px solid var(--accent-soft); padding-left: 1rem; }

/* bas de page */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--border); font-family: var(--sans); }
.pager-link { display: flex; flex-direction: column; padding: .7rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); line-height: 1.35; }
.pager-link:hover { border-color: var(--accent); }
.pager-link.next { text-align: right; grid-column: 2; }
.pager-dir { font-size: .85rem; color: var(--muted); }

/* ---------- mobile ---------- */
.overlay { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 3.5rem; left: 0; z-index: 25; width: min(19rem, 85vw); height: calc(100vh - 3.5rem); transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; }
  body.nav-open .overlay { display: block; position: fixed; inset: 3.5rem 0 0 0; z-index: 20; background: rgba(0, 0, 0, .3); }
  html:not(.js) .side { position: static; transform: none; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  main { padding: 1.5rem 1rem 3rem; }
  .page-head h1 { font-size: 1.6rem; }
  .btn-label { display: none; }
  .trou.t4, .trou.t5 { min-width: 9em; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
@media print {
  .topbar, .side, .outils, .pager, .avis, .overlay { display: none !important; }
  .layout { display: block; } body { background: #fff; }
}
