/*
 * Basic CMS — thème par défaut
 * Contrastes vérifiés pour le niveau AA (texte ≥ 4,5:1) en clair comme en sombre.
 * Pour personnaliser : modifier les variables ci-dessous.
 */

:root {
  --bg: #fbfaf7;
  --surface: #f1efe9;
  --text: #1c1c1a;
  --muted: #55554f;       /* 7,2:1 sur --bg */
  --accent: #0a5aa8;      /* 6,6:1 sur --bg */
  --accent-hover: #073f77;
  --border: #d9d6cc;
  --focus: #b3410e;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --measure: 40rem;
  --wide: 64rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #22221f;
    --text: #ecebe5;
    --muted: #b0afa7;     /* 8,2:1 sur --bg */
    --accent: #8ec4ff;    /* 9,9:1 sur --bg */
    --accent-hover: #c2deff;
    --border: #3a3a35;
    --focus: #ffb37a;
  }
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ---------- Focus visible et lien d'évitement ---------- */

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

main:focus { outline: none; }

/* Texte réservé aux lecteurs d'écran */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 10;
  padding: .6rem 1rem;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
}
.skip-link:focus { top: 1rem; }

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

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

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 2rem;
  padding-block: 1.1rem;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

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

.site-nav a {
  display: inline-block;
  padding-block: .35rem;      /* zone cliquable d'au moins 24 px */
  color: var(--text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--border); }
.site-nav a[aria-current] {
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- Contenu ---------- */

main {
  flex: 1;
  padding-block: 2.5rem 4rem;
}

.page-header,
.prose,
.entries,
.listing > .meta {
  max-width: var(--measure);
}

.page-header { margin-bottom: 2rem; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  margin: 2.2rem 0 .8rem;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); margin-top: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4, h5, h6 { font-size: 1.05rem; }

.meta {
  color: var(--muted);
  font-size: .95rem;
  margin: .4rem 0 0;
}

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

.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre { margin: 0 0 1.2rem; }
.prose li + li { margin-top: .3rem; }
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul { margin: .3rem 0 0; }

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.prose blockquote {
  margin-inline: 0;
  padding: .2rem 0 .2rem 1.2rem;
  border-left: 4px solid var(--border);
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

code, pre { font-family: var(--font-mono); font-size: .9em; }

:not(pre) > code {
  background: var(--surface);
  padding: .1em .35em;
  border-radius: 4px;
}

/* Les longues lignes de code passent à la ligne : jamais de défilement horizontal (RGAA 10.11) */
pre {
  background: var(--surface);
  padding: 1rem 1.1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* ---------- Tableaux ---------- */

/* Un tableau trop large défile dans son cadre, jamais la page (RGAA 10.11, exception des tableaux de données) */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 1.5rem;
}
.prose .table-wrap { max-width: none; }

table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: .97rem;
}
caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  padding: 0 0 .5rem;
}
th, td {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
thead th { background: var(--surface); }
tbody th { font-weight: 600; }
.align-center { text-align: center; }
.align-right { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Images légendées ---------- */

figure { margin: 0 0 1.5rem; }
figure img { margin-bottom: .5rem; }
figcaption {
  color: var(--muted);
  font-size: .95rem;
}

/* ---------- Liste des pages d'une rubrique ---------- */

.entries {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
}

.entry {
  padding-block: 1.25rem;
  border-top: 1px solid var(--border);
}

.entry-title {
  font-size: 1.3rem;
  margin: 0;
}
.entry-title a { text-decoration: none; }
.entry-title a:hover { text-decoration: underline; }

.entry-summary { margin: .5rem 0 0; }

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

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .95rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem 2rem;
  padding-block: 1.5rem;
}
.site-footer p { margin: 0; }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }
.footer-links a[aria-current] { color: var(--text); font-weight: 600; }

/* ---------- Plan du site ---------- */

.sitemap ul { list-style: disc; }
.sitemap ul ul { list-style: circle; }

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

@media print {
  .skip-link, .site-nav, .site-footer { display: none; }
  pre { white-space: pre-wrap; }
  body { background: #fff; color: #000; }
  .prose a::after { content: " (" attr(href) ")"; font-size: .85em; }
}
