/* ==================================================================
   AnSu × Incubateur — feuille de style « console enseignant »
   Calquée sur le système Mondri · variante Ardoise compacte
   Sobriété · Lisibilité · Hiérarchie par l'ombre · Aucun arrondi
   ================================================================== */

:root {
  /* Ardoise (slate) — variante institutionnelle de Mondri */
  --marine: #1f3357;        /* ardoise profonde — header, titres */
  --blue: #1556d6;          /* bleu primaire — accent dominant */
  --blue-700: #0e3fa8;      /* bleu hover */
  --red: #d7263d;           /* rouge primaire */
  --red-bg: #fdecee;
  --yellow: #f5c518;        /* jaune primaire */
  --yellow-bg: #fff8d6;
  --amber: #a36b00;

  --text: #2a2a32;
  --text-light: #6b6b76;
  --border: #ebe8e2;
  --border-strong: #d4d0c8;
  --bg: #fdfdfb;
  --bg-alt: #f5f3ee;
  --bg-alt-2: #ebe8e0;

  --shadow-1: 0 1px 2px rgba(31, 51, 87, 0.06), 0 1px 1px rgba(31, 51, 87, 0.04);
  --shadow-2: 0 2px 6px rgba(31, 51, 87, 0.08), 0 1px 2px rgba(31, 51, 87, 0.05);
  --shadow-3: 0 6px 18px rgba(31, 51, 87, 0.10), 0 2px 4px rgba(31, 51, 87, 0.06);

  --mono: ui-monospace, SFMono-Regular, Menlo, "Cascadia Mono", monospace;
  --rail-w: 268px;
}

* { box-sizing: border-box; border-radius: 0 !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }

.mono { font-family: var(--mono); }

/* ---------- En-tête institutionnel ---------- */
.app-header {
  background: var(--marine);
  color: #fff;
  position: sticky; top: 0; z-index: 60;
  box-shadow: var(--shadow-2);
}
.app-header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 12px 32px;
  display: flex; align-items: center; gap: 16px;
}
.brand-mark { display: flex; align-items: center; gap: 13px; }
.brand-logo {
  width: 30px; height: 30px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 2px; padding: 2px; flex-shrink: 0;
}
.brand-logo span:nth-child(1) { background: var(--blue); }
.brand-logo span:nth-child(2) { background: var(--yellow); }
.brand-logo span:nth-child(3) { background: var(--text-light); }
.brand-logo span:nth-child(4) { background: var(--red); }
.brand-word { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand-divider { width: 1px; align-self: stretch; background: rgba(255,255,255,0.18); margin: 2px 4px; }
.brand-kicker {
  font-family: var(--mono); font-size: 0.62rem;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: #9db4d8; font-weight: 600;
}
.brand-sub { color: #cbd5e1; font-size: 0.82rem; margin-top: 1px; }
.app-header .spacer { flex: 1; }
.header-pill {
  font-family: var(--mono); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 5px 11px; color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ---------- Bandeau d'état (console) ---------- */
.status-strip {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.status-strip-inner {
  max-width: 1280px; margin: 0 auto; padding: 9px 32px;
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.74rem;
  color: var(--text-light); letter-spacing: 0.02em;
}
.status-item { display: flex; align-items: center; gap: 8px; padding: 2px 18px; border-right: 1px solid var(--border-strong); }
.status-item:first-child { padding-left: 0; }
.status-item:last-child { border-right: 0; }
.status-item b { color: var(--marine); font-weight: 700; }
.status-dot { width: 7px; height: 7px; background: var(--blue); flex-shrink: 0; }
.status-dot.live { background: #1f8a4c; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Coque deux colonnes ---------- */
.shell {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: var(--rail-w) 1fr;
  align-items: start;
}

/* ---------- Sommaire / panneau console ---------- */
.rail {
  position: sticky; top: 113px;
  align-self: start;
  max-height: calc(100vh - 113px);
  overflow-y: auto;
  padding: 24px 18px 32px 32px;
  border-right: 1px solid var(--border);
}
.rail-head {
  font-family: var(--mono); font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-light); font-weight: 600;
  margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 0;
  border-left: 2px solid transparent;
  padding-left: 12px; margin-left: -12px;
  transition: border-color 0.15s, background 0.15s;
}
.rail-link {
  flex: 1; display: flex; align-items: baseline; gap: 9px;
  color: var(--text); font-size: 0.86rem; line-height: 1.3;
  cursor: pointer; text-align: left; min-width: 0;
}
.rail-link:hover { color: var(--blue); }
.rail-num { font-family: var(--mono); font-size: 0.7rem; color: var(--text-light); font-weight: 600; flex-shrink: 0; }
.rail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item.is-active { border-left-color: var(--blue); background: var(--bg-alt); }
.rail-item.is-active .rail-link { color: var(--marine); font-weight: 600; }
.rail-item.is-active .rail-num { color: var(--blue); }
.rail-item.is-hidden .rail-link { color: var(--border-strong); }
.rail-item.is-hidden .rail-num { color: var(--border-strong); }

/* bouton œil (afficher/masquer) — visible en mode édition */
.rail-eye {
  width: 26px; height: 26px; flex-shrink: 0;
  display: none; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-light);
}
.rail-eye:hover { border-color: var(--blue); color: var(--blue); box-shadow: var(--shadow-1); }
.rail-eye svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
body.edit-on .rail-eye { display: flex; }
.rail-item.is-hidden .rail-eye { color: var(--red); border-color: #f0c9cf; }

/* commande mode édition */
.rail-edit-toggle {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border);
}
.edit-switch {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--marine);
  font-size: 0.8rem; font-weight: 600;
  box-shadow: var(--shadow-1);
}
.edit-switch:hover { border-color: var(--blue); color: var(--blue); }
body.edit-on .edit-switch { background: var(--marine); color: #fff; border-color: var(--marine); }
body.edit-on .edit-switch .sw-track { background: rgba(255,255,255,0.3); }
body.edit-on .edit-switch .sw-track::after { left: 14px; background: #fff; }
.sw-track { width: 28px; height: 16px; background: var(--bg-alt-2); position: relative; flex-shrink: 0; margin-left: auto; }
.sw-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--text-light); transition: left 0.18s; }
.reset-btn {
  width: 100%; margin-top: 8px; padding: 7px;
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-light); display: none;
}
.reset-btn:hover { color: var(--blue); }
body.edit-on .reset-btn { display: block; }
.edit-hint {
  display: none; margin-top: 10px;
  font-size: 0.74rem; line-height: 1.5; color: var(--text-light);
}
body.edit-on .edit-hint { display: block; }

/* ---------- Document principal ---------- */
.doc { min-width: 0; padding-bottom: 40px; }

.block {
  position: relative;
  padding: 40px 56px 40px 56px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 124px;
}
.block:nth-child(even) { background: var(--bg-alt); }
.block.is-hidden { display: none; }

/* gros numéro fantôme (marge) */
.block-num {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.14em; color: var(--blue);
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.block-num::before { content: ""; width: 24px; height: 2px; background: var(--blue); }
.block-eyebrow {
  font-family: var(--mono); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-light); font-weight: 600;
  margin-bottom: 14px; line-height: 1.5; max-width: 760px;
}
.block-title {
  font-size: 1.6rem; font-weight: 700; color: var(--marine);
  line-height: 1.25; margin-bottom: 18px;
  padding-left: 14px; border-left: 4px solid var(--blue);
  max-width: 800px; text-wrap: pretty;
}
.block-body { max-width: 760px; }
.block-body p { margin-bottom: 14px; color: var(--text); }
.block-body p:last-child { margin-bottom: 0; }
.block-body strong { color: var(--marine); font-weight: 700; }
.block-body em { font-style: italic; }
.block-body ul { margin: 0 0 14px; padding: 0; list-style: none; }
.block-body li {
  position: relative; padding-left: 22px; margin-bottom: 9px; color: var(--text);
}
.block-body li::before {
  content: ""; position: absolute; left: 0; top: 9px;
  width: 7px; height: 7px; background: var(--blue);
}
.block-body li strong { color: var(--marine); }

/* ---------- Hero ---------- */
.block.is-hero { background: var(--bg); padding-top: 56px; padding-bottom: 56px; }
.block.is-hero .block-eyebrow {
  border-left: 3px solid var(--blue); padding-left: 12px; max-width: 720px;
}
.block.is-hero .block-title {
  font-size: 2.6rem; line-height: 1.15; border-left: 0; padding-left: 0;
  margin-bottom: 20px; max-width: 880px;
}
.block.is-hero .block-body { font-size: 1.12rem; max-width: 720px; }
.block.is-hero .block-body p { color: var(--text); }

/* ---------- Boutons ---------- */
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; font-weight: 600; font-size: 0.92rem;
  border: 1px solid transparent; transition: box-shadow 0.18s, background 0.18s, color 0.18s;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--blue-700); box-shadow: var(--shadow-2); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--bg); color: var(--blue); border-color: var(--blue); }
.btn-secondary:hover { background: var(--bg-alt); box-shadow: var(--shadow-1); text-decoration: none; }

/* ---------- Méta de bloc ---------- */
.block-meta {
  margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.74rem; color: var(--text-light);
  letter-spacing: 0.02em; line-height: 1.6; max-width: 800px;
}
.block.is-hero .block-meta { border-top: 0; padding-top: 0; margin-top: 22px; }

/* ---------- Encadrés sémantiques ---------- */
.callout {
  padding: 15px 18px 15px 15px; margin: 4px 0 16px;
  background: var(--bg-alt); box-shadow: var(--shadow-1);
  border-left: 4px solid var(--border-strong); max-width: 760px;
}
.block:nth-child(even) .callout { background: var(--bg); }
.callout strong { display: block; margin-bottom: 4px; color: var(--marine); }
.callout p { margin: 0; color: var(--text); }
.callout.definition { border-left-color: var(--blue); }
.callout.alert { border-left-color: var(--red); background: var(--red-bg); }
.block:nth-child(even) .callout.alert { background: var(--red-bg); }
.callout.levier { border-left-color: var(--yellow); background: var(--yellow-bg); }
.block:nth-child(even) .callout.levier { background: var(--yellow-bg); }

/* ---------- Diagramme ASCII ---------- */
.diagram-box {
  background: var(--bg); border: 1px solid var(--border);
  padding: 18px 20px; margin-bottom: 16px;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.5;
  color: var(--text-light); overflow-x: auto;
  white-space: pre; max-width: 760px;
}
.block:nth-child(even) .diagram-box { background: var(--bg-alt); }

/* ---------- Tableau fichiers ---------- */
.files-box {
  margin-top: 20px; padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--bg-alt); max-width: 760px;
}
.block:nth-child(even) .files-box { background: var(--bg); }
.files-box h4 {
  font-family: var(--mono); font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-light); font-weight: 600;
  margin-bottom: 10px;
}
.files-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; font-family: var(--mono); }
.files-table td {
  padding: 5px 0; border-bottom: 1px solid var(--border);
  vertical-align: top; font-size: 0.74rem;
}
.files-table td:first-child { white-space: nowrap; padding-right: 14px; color: var(--marine); }
.files-table tr:last-child td { border-bottom: none; }

/* ---------- Exercice (copy button, contenu exo) ---------- */
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--blue); color: var(--blue);
  background: var(--bg); transition: box-shadow 0.18s, background 0.18s, color 0.18s;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.copy-btn:hover { background: var(--blue); color: #fff; box-shadow: var(--shadow-1); }
.exo-content {
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.8;
  color: var(--text-secondary, #495057); white-space: pre-wrap;
  overflow-x: auto; max-width: 760px;
}
.exo-content .hl { color: var(--marine); font-weight: 700; }
.exo-content .hl-q { color: var(--text); font-weight: 600; }

/* ---------- Pied de page ---------- */
.app-footer {
  background: var(--marine); color: #cbd5e1;
  padding: 24px 0; font-size: 0.82rem;
}
.app-footer-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 32px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
}
.app-footer a { color: #cbd5e1; }
.app-footer .foot-links { display: flex; gap: 18px; }
.app-footer .mono { color: #9db4d8; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Bouton sommaire mobile ---------- */
.rail-fab { display: none; }

/* ---------- Chargement / erreur ---------- */
.doc-status {
  padding: 60px 56px; color: var(--text-light);
  font-family: var(--mono); font-size: 0.85rem;
}
.doc-status.error { color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
    width: 280px; max-height: 100vh; background: var(--bg);
    box-shadow: var(--shadow-3); transform: translateX(-100%);
    transition: transform 0.22s ease; padding-top: 20px;
  }
  body.rail-open .rail { transform: translateX(0); }
  .rail-backdrop {
    display: none; position: fixed; inset: 0; z-index: 80;
    background: rgba(31,51,87,0.4);
  }
  body.rail-open .rail-backdrop { display: block; }
  .rail-fab {
    display: inline-flex; align-items: center; gap: 8px;
    position: fixed; left: 16px; bottom: 16px; z-index: 70;
    padding: 11px 16px; background: var(--marine); color: #fff;
    font-size: 0.82rem; font-weight: 600; box-shadow: var(--shadow-3);
  }
  .rail-fab svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
  .block { padding: 32px 24px; scroll-margin-top: 20px; }
  .block.is-hero .block-title { font-size: 1.9rem; }
}

@media (max-width: 560px) {
  .status-item { border-right: 0; padding: 2px 0; }
  .status-strip-inner { gap: 6px 16px; }
  .app-header-inner { padding: 10px 18px; }
}

/* ---------- Impression : seuls les blocs visibles ---------- */
@media print {
  .app-header, .status-strip, .rail, .rail-fab, .rail-backdrop, .app-footer { display: none !important; }
  .shell { display: block; max-width: none; }
  .block { break-inside: avoid; border-bottom: 1px solid var(--border); page-break-inside: avoid; }
  .block:nth-child(even) { background: #fff; }
}
