/* =====================================================================
   Ilyes SchoolDev — plateforme v2 — FONDATION « La régie »
   Fichier partagé par toutes les pages de la plateforme (charte « La régie »).
   Contrat documenté dans le rapport de fondation : ne renommez pas
   une classe existante, ajoutez-en. Vanilla CSS, aucune bibliothèque.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Palette brute */
  --ink: #0d0e0c;
  --ink-2: #17181a;
  --ink-3: #202124;
  --ink-line: #2a2b2c;
  --paper: #f1eee6;
  --paper-2: #e4dfd2;
  --paper-line: #cfc9bb;
  --dim: #a9a79f;
  --signal: #d7ff3a;

  --delphi: #ff3d55;
  --delphi-deep: #b0102c;
  --delphi-bg: #f6f1ea;
  --sql: #4d9bff;
  --sql-soft: #9cc8ff;
  --sql-bg: #07111f;
  --sql-bg-2: #0d1b2f;

  --ok: #b6f09c;
  --ok-deep: #1f6b2a;
  --warn: #ffcf6b;
  --warn-deep: #8a5a00;
  --err: #ff8a7a;
  --err-deep: #b0102c;

  /* Typographies (Google Fonts chargées dans chaque <head>) */
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-serif: "Instrument Serif", Georgia, serif;
  --f-mono: "JetBrains Mono", Consolas, monospace;
  --f-brand: "Space Grotesk", "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif; /* texte du logo d'en-tête uniquement */

  /* Mise en page */
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1320px;
  --maxw-narrow: 760px;
  --header-h: 72px;
  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);

  /* Tokens sémantiques : surface sombre par défaut (encre) */
  --bg: var(--ink);
  --bg-raised: var(--ink-2);
  --fg: var(--paper);
  --fg-soft: #cfccc3;
  --muted: var(--dim);
  --line: var(--ink-line);
  --accent: var(--signal);
  --accent-fg: var(--ink);
  --focus: var(--signal);
  --field-bg: #111210;
  --field-line: #3a3b3c;
}

/* Surface claire (papier) : à poser sur une section, une carte ou <body> */
.surface-paper {
  --bg: var(--paper);
  --bg-raised: #fbfaf6;
  --fg: var(--ink);
  --fg-soft: #3f3c35;
  --muted: #6b675d;
  --line: var(--paper-line);
  --accent: var(--ink);
  --accent-fg: var(--signal);
  --focus: var(--ink);
  --field-bg: #ffffff;
  --field-line: #a9a39a;
  background: var(--bg);
  color: var(--fg);
}
/* Univers de formation (sections ou pages) */
.theme-delphi { --accent: var(--delphi-deep); --accent-fg: #fff; --universe: var(--delphi); }
.theme-sql { --accent: var(--sql); --accent-fg: var(--ink); --universe: var(--sql); }
.surface-sql {
  --bg: var(--sql-bg); --bg-raised: var(--sql-bg-2); --fg: #e6eefb; --fg-soft: #cfe2ff;
  --muted: #7d93b5; --line: #1d3354; --accent: var(--sql); --accent-fg: var(--ink);
  --focus: var(--sql-soft); --field-bg: #030912; --field-line: #2a4670;
  background: var(--bg); color: var(--fg);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-display);
  font-size: clamp(1rem, .95rem + .25vw, 1.125rem);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@supports (overflow: clip) { body { overflow-x: clip; } }
img, svg, video, canvas { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.05; letter-spacing: -0.035em; }
h1 { font-size: clamp(2.4rem, 1.2rem + 5vw, 5.6rem); letter-spacing: -0.05em; line-height: .98; }
h2 { font-size: clamp(1.8rem, 1.1rem + 3vw, 3.6rem); }
h3 { font-size: clamp(1.2rem, 1rem + .8vw, 1.6rem); letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0 0 1em; }
em { font-family: var(--f-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
sup { font-size: .6em; line-height: 0; vertical-align: .55em; }
code, kbd, pre { font-family: var(--f-mono); }
::selection { background: var(--signal); color: var(--ink); }

/* Compatibilité avec les scripts d'origine (public.js, dashboard.js…) */
.hidden { display: none !important; }

/* ---------- 3. Accessibilité ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 200;
  background: var(--signal); color: var(--ink); padding: 10px 16px; border-radius: var(--radius-s);
  font-weight: 700; text-decoration: none; transition: top .2s;
}
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

/* ---------- 4. Mise en page ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { width: 100%; max-width: calc(var(--maxw-narrow) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
/* Contenu principal d'une page intérieure : laisse la place à l'en-tête fixe. Pas de 100dvh. */
.page { min-height: auto; padding-top: calc(var(--header-h) + clamp(32px, 7vh, 80px)); padding-bottom: clamp(56px, 10vh, 120px); }
.page-head { margin-bottom: clamp(28px, 5vh, 56px); }
.page-head h1 em { color: var(--accent); }
.surface-paper .page-head h1 em, .page-head.on-paper h1 em { color: var(--delphi-deep); }
.section { padding-block: clamp(64px, 11vh, 140px); }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, 16px); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, 12px); }
.grid-2, .grid-3 { display: grid; gap: clamp(16px, 2.5vw, 28px); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.divider { height: 1px; background: var(--line); border: 0; margin: 28px 0; }

/* ---------- 5. Texte ---------- */
.kicker {
  font-family: var(--f-mono); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 1.2rem;
}
.lead { font-size: clamp(1.05rem, .95rem + .4vw, 1.3rem); color: var(--fg-soft); max-width: 56ch; }
.muted { color: var(--muted); }
.mono { font-family: var(--f-mono); }
.t-signal { color: var(--signal); }
.t-delphi { color: var(--delphi); }
.t-sql { color: var(--sql-soft); }
.surface-paper .t-delphi { color: var(--delphi-deep); }
.surface-paper .t-sql { color: #0b57c9; }
/* Texte long (charte, mentions) */
.prose { max-width: 68ch; }
.prose h2 { font-size: clamp(1.3rem, 1rem + 1.2vw, 1.9rem); margin: 2em 0 .6em; letter-spacing: -0.025em; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--fg-soft); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose a { text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- 6. Icônes (masques SVG, couleur = currentColor) ---------- */
.ico, .password-toggle i, .modal-close i {
  display: inline-block; width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em;
  background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}
.ico-eye, .fa-eye { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.ico-eye-off, .fa-eye-slash { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.2 4.2M6.6 6.6C3.8 8.4 2 12 2 12s3.5 7 10 7a9.6 9.6 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E"); }
.ico-close, .fa-times, .fa-xmark { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.ico-check { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E"); }
.ico-arrow-left { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E"); }
.ico-arrow-right { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E"); }
.ico-chevron-left { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E"); }
.ico-chevron-right { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E"); }
.ico-logout { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v8M6.3 6.3a8 8 0 1 0 11.4 0'/%3E%3C/svg%3E"); }
.ico-mail { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 7l9 6 9-6'/%3E%3C/svg%3E"); }
.ico-send { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3L10 14M21 3l-7 18-4-7-7-4z'/%3E%3C/svg%3E"); }
.ico-lock { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='10' width='16' height='11' rx='2'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E"); }
.ico-play { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 4.5v15l13-7.5z' fill='%23000'/%3E%3C/svg%3E"); }
.ico-download { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E"); }
.ico-doc { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E"); }
.ico-zoom { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5M11 8v6M8 11h6'/%3E%3C/svg%3E"); }

/* ---------- 7. Barre de progression de lecture ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 120; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--signal); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
@supports (animation-timeline: scroll()) {
  .progress span { animation: progress-grow linear both; animation-timeline: scroll(root); }
  @keyframes progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* ---------- 8. En-tête et navigation ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 100; min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--gutter);
  color: var(--paper);
  transition: transform .5s var(--ease-out), background-color .3s, border-color .3s;
  border-bottom: 1px solid transparent;
}
.topbar.is-solid, .topbar.topbar-solid { background: rgba(13,14,12,.95); border-bottom-color: var(--ink-line); }
.topbar.is-hidden { transform: translateY(-100%); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; white-space: nowrap; color: var(--paper); }
.brand b { font-weight: 700; color: var(--signal); }
.brand-name { font-family: var(--f-brand); }
/* Icône de marque : fenêtre de terminal en SVG en ligne (36 px), curseur clignotant (opacity seule, sans reflow) */
.brand-icon { width: 36px; height: 36px; flex: none; display: block; }
.logo-cursor { animation: logo-blink 1.2s steps(1) infinite; }
@keyframes logo-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .logo-cursor { animation: none; } }
/* En pause, le curseur reste visible et fixe (la règle générique le figerait parfois éteint) */
html.motion-paused .logo-cursor { animation: none; }

.nav ul { display: flex; gap: clamp(14px, 2vw, 30px); list-style: none; margin: 0; padding: 0; }
.nav a { text-decoration: none; font-size: .95rem; color: var(--dim); position: relative; padding: 6px 0; transition: color .25s; }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--signal); transform: scaleX(0); transform-origin: right; transition: transform .4s var(--ease-out); }
.nav a:hover, .nav a:focus-visible, .nav a[aria-current="page"] { color: var(--paper); }
.nav a:hover::after, .nav a:focus-visible::after, .nav a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar :focus-visible { outline-color: var(--signal); }

.motion-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: transparent; color: var(--dim); border: 1px solid var(--ink-line);
  border-radius: 999px; padding: 7px 12px; font: 500 .8rem var(--f-mono); min-height: 40px;
}
.motion-toggle:hover { color: var(--paper); border-color: var(--dim); }
.motion-toggle[hidden] { display: none; }
.motion-icon { width: 10px; height: 10px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.motion-toggle[aria-pressed="true"] .motion-icon { border: 0; width: 0; height: 0; border-left: 9px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }

.menu-btn { display: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--ink-line); background: transparent; color: var(--paper); cursor: pointer; }
.menu-lines, .menu-lines::before, .menu-lines::after { display: block; width: 18px; height: 2px; background: currentColor; margin: auto; transition: transform .35s var(--ease-out); }
.menu-lines { position: relative; }
.menu-lines::before, .menu-lines::after { content: ""; position: absolute; left: 0; }
.menu-lines::before { top: -6px; }
.menu-lines::after { top: 6px; }
.menu-btn[aria-expanded="true"] .menu-lines { background: transparent; }
.menu-btn[aria-expanded="true"] .menu-lines::before { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-lines::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 960px) {
  .menu-btn { display: inline-block; }
  .motion-label { display: none; }
  .motion-toggle { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .nav {
    position: fixed; inset: 0 0 auto 0; z-index: -1;
    background: var(--ink); border-bottom: 1px solid var(--ink-line);
    padding: 88px var(--gutter) 28px;
    transform: translateY(-105%); visibility: hidden;
    transition: transform .55s var(--ease-out), visibility 0s .55s;
  }
  .nav.is-open { transform: translateY(0); visibility: visible; transition: transform .55s var(--ease-out), visibility 0s; }
  .nav ul { flex-direction: column; gap: 4px; }
  .nav a { display: block; font-size: 1.6rem; font-weight: 700; color: var(--paper); padding: 8px 0; }
}
.topbar-actions > * { flex: none; }
/* Bouton de langue fr ↔ ar (index, delphi et leurs versions ar/). Sous 400 px, il passe dans le menu
   (.lang-switch-nav) pour ne pas faire déborder l'en-tête. Les catalogues le masquent déjà sous 960 px (.cat-desk). */
.lang-switch { padding-inline: .9em; }
.lang-switch[lang="ar"], .lang-switch-nav [lang="ar"] { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; letter-spacing: normal; }
.nav .lang-switch-nav { display: none; }
@media (max-width: 400px) {
  .topbar:has(.lang-switch-nav) .lang-switch { display: none; }
  .nav .lang-switch-nav { display: list-item; }
}
/* En-tête de bureau étroit (pages qui ont le bouton de langue) : liens du menu sur une ligne dès 1024 px ;
   bouton de langue en rond de 44 px ; bouton pause réduit à son icône (rond de 44 px, comme sous 960 px,
   aria-label inchangé) pour lui faire la place. Accueil : rond de 961 à 1199 px, pause en icône de 961 à
   1023 px. Catalogues : les deux de 961 à 1399 px. rtl.css garde « Français » en texte sur ar/delphi.html. */
@media (min-width: 1024px) { .topbar:has(.lang-switch) .nav a { white-space: nowrap; } }
@media (min-width: 961px) and (max-width: 1199px) {
  .home .topbar .lang-switch { width: 44px; height: 44px; padding: 0; font-size: .82rem; }
}
@media (min-width: 961px) and (max-width: 1023px) {
  .home .topbar:has(.lang-switch) .motion-label { display: none; }
  .home .topbar:has(.lang-switch) .motion-toggle { width: 44px; height: 44px; justify-content: center; padding: 0; }
}
@media (min-width: 961px) and (max-width: 1399px) {
  .catalog .topbar .lang-switch { width: 44px; height: 44px; padding: 0; font-size: .82rem; }
  .catalog .topbar:has(.lang-switch) .motion-label { display: none; }
  .catalog .topbar:has(.lang-switch) .motion-toggle { width: 44px; height: 44px; justify-content: center; padding: 0; }
}
/* Espace participant : sous 600 px, l'en-tête est plein ; le bouton de langue passe sous le titre (.lang-switch-page) */
.lang-switch-page { display: none; }
@media (max-width: 600px) {
  .dash .topbar .lang-switch { display: none; }
  .lang-switch-page { display: inline-flex; margin-top: 14px; }
  .lang-switch-page[lang="ar"] { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; letter-spacing: normal; }
}
/* Pages sans menu (programme détaillé, charte, mot de passe, avis, dashboards) : sous 520 px, bouton de langue rond de 44 px */
@media (max-width: 520px) { .topbar:not(:has(.nav)) .lang-switch { width: 44px; height: 44px; padding: 0; font-size: .8rem; } }
@media (max-width: 520px) {
  .topbar .topbar-cta { display: none; }
  .brand { font-size: 1rem; }
  .topbar-actions { gap: 8px; }
}
/* Libellé facultatif d'un bouton d'en-tête : masqué sur petit écran (le bouton garde son aria-label) */
@media (max-width: 420px) {
  .topbar .nav-text, .topbar .btn-label-optional { display: none; }
}

/* ---------- 9. Boutons et liens ---------- */
.btn {
  --b-bg: var(--accent); --b-fg: var(--accent-fg); --b-hover-bg: var(--fg); --b-hover-fg: var(--bg);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .6em;
  min-height: 44px; padding: .9em 1.5em; border-radius: 999px; border: 2px solid transparent;
  background: var(--b-bg); color: var(--b-fg);
  font: 700 1rem/1.1 var(--f-display); text-decoration: none; letter-spacing: -0.01em; text-align: center;
  cursor: pointer; overflow: hidden; isolation: isolate;
  transition: transform .5s var(--ease-out), color .3s, opacity .2s;
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: var(--b-hover-bg); transform: translateY(101%); transition: transform .45s var(--ease-out);
}
.btn:hover::before, .btn:focus-visible::before { transform: translateY(0); }
.btn:hover, .btn:focus-visible { color: var(--b-hover-fg); }
.btn-arrow { display: inline-block; transition: transform .45s var(--ease-out); }
.btn:hover .btn-arrow { transform: translateX(4px); }
.btn-signal { --b-bg: var(--signal); --b-fg: var(--ink); --b-hover-bg: var(--paper); --b-hover-fg: var(--ink); }
.btn-ink { --b-bg: var(--ink); --b-fg: var(--signal); --b-hover-bg: var(--signal); --b-hover-fg: var(--ink); }
.btn-paper { --b-bg: var(--paper); --b-fg: var(--ink); --b-hover-bg: var(--signal); --b-hover-fg: var(--ink); }
.btn-ghost { --b-bg: transparent; --b-fg: var(--fg); --b-hover-bg: var(--fg); --b-hover-fg: var(--bg); border-color: color-mix(in srgb, var(--fg) 35%, transparent); }
@supports not (color: color-mix(in srgb, red, blue)) { .btn-ghost { border-color: var(--line); } }
.btn-delphi { --b-bg: var(--delphi-deep); --b-fg: #fff; --b-hover-bg: var(--ink); --b-hover-fg: #fff; }
.btn-sql { --b-bg: var(--sql); --b-fg: var(--ink); --b-hover-bg: var(--paper); --b-hover-fg: var(--ink); }
.btn-danger { --b-bg: var(--err-deep); --b-fg: #fff; --b-hover-bg: var(--ink); --b-hover-fg: #fff; }
.btn-sm { min-height: 40px; padding: .6em 1.1em; font-size: .9rem; }
.btn-lg { padding: 1.05em 1.9em; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn:disabled::before { transform: translateY(101%); }
.btn:disabled:hover { color: var(--b-fg); }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 1.1em; height: 1.1em; margin: -.55em 0 0 -.55em;
  border-radius: 50%; border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .8s linear infinite;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer;
  transition: background-color .25s, color .25s, border-color .25s;
}
.icon-btn:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.link-under, .link-button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0 0 2px; cursor: pointer; text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor); background-repeat: no-repeat;
  background-position: 0 100%; background-size: 100% 2px; overflow-wrap: anywhere;
  transition: background-size .4s var(--ease-out);
}
.link-under:hover, .link-button:hover { background-size: 0 2px; background-position: 100% 100%; }
.link-button { font-size: .95rem; color: var(--fg-soft); }

/* ---------- 10. Formulaires ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label { font-weight: 600; font-size: .95rem; }
.form-hint { font-size: .85rem; color: var(--muted); margin: 0; }
.form-control {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--field-bg); color: var(--fg);
  border: 1.5px solid var(--field-line); border-radius: var(--radius-s);
  font-size: 1rem; line-height: 1.3;
  transition: border-color .2s, box-shadow .2s;
}
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-control:hover { border-color: var(--muted); }
.form-control:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 25%, transparent); }
.form-control[aria-invalid="true"] { border-color: var(--err); }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
/* Rustine autoremplissage Chrome : garde le fond de la surface */
.form-control:-webkit-autofill { -webkit-text-fill-color: var(--fg); -webkit-box-shadow: 0 0 0 40px var(--field-bg) inset; caret-color: var(--fg); }
.form-control:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 40px var(--field-bg) inset, 0 0 0 4px color-mix(in srgb, var(--focus) 25%, transparent); }
.form-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .95rem; }
.form-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.password-field { position: relative; }
.password-field .form-control { padding-right: 52px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: var(--radius-s); color: var(--muted); cursor: pointer;
}
.password-toggle:hover { color: var(--fg); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; margin-top: 6px; }
.form-actions-end { justify-content: flex-end; }
.login-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- 11. Messages ---------- */
.success-message, .warning-message, .error-message, .info-message {
  --m: var(--ok);
  position: relative; display: block; padding: 12px 14px 12px 18px; border-radius: var(--radius-s);
  border: 1px solid color-mix(in srgb, var(--m) 55%, transparent);
  background: color-mix(in srgb, var(--m) 12%, transparent);
  color: var(--fg); font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere;
  animation: msg-in .45s var(--ease-out);
}
.success-message::before, .warning-message::before, .error-message::before, .info-message::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--m);
}
.success-message { --m: var(--ok); }
.warning-message { --m: var(--warn); }
.error-message { --m: var(--err); }
.info-message { --m: var(--sql); }
.surface-paper .success-message { --m: var(--ok-deep); }
.surface-paper .warning-message { --m: var(--warn-deep); }
.surface-paper .error-message { --m: var(--err-deep); }
.surface-paper .info-message { --m: #0b57c9; }
@keyframes msg-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 12. Cartes, badges ---------- */
.card { background: var(--bg-raised); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius-l); padding: clamp(20px, 4vw, 40px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-hover { transition: transform .5s var(--ease-out), border-color .3s; }
.card-hover:hover { transform: translateY(-4px); border-color: var(--fg); }
/* Carte papier posée sur fond encre (formulaires, documents) */
.sheet { position: relative; border-radius: var(--radius-l); padding: clamp(22px, 5vw, 48px); box-shadow: 14px 18px 0 -4px var(--sheet-shadow, var(--signal)); }
.sheet.theme-delphi { --sheet-shadow: var(--delphi-deep); }
.sheet.theme-sql { --sheet-shadow: var(--sql); }
/* Compatibilité : panneau d'authentification (reset_password) */
.auth-card { width: 100%; max-width: 560px; margin-inline: auto; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font: 600 .72rem/1.3 var(--f-mono); letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--fg-soft); white-space: nowrap;
}
.badge-signal { background: var(--signal); color: var(--ink); border-color: var(--signal); }
.badge-delphi { background: var(--delphi-deep); color: #fff; border-color: var(--delphi-deep); }
.badge-sql { background: var(--sql); color: var(--ink); border-color: var(--sql); }
.badge-ok { color: var(--fg); border-color: var(--ok); }
.badge-muted { color: var(--muted); }
.badge-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--delphi); animation: blink 1.2s steps(2, jump-none) infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chips li { padding: 7px 13px; border-radius: 999px; font-size: .88rem; border: 1px solid var(--line); overflow-wrap: anywhere; }

/* ---------- 13. Chargement ---------- */
.spinner { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.loading-block { display: flex; align-items: center; gap: 14px; padding: 24px 0; color: var(--muted); font-family: var(--f-mono); font-size: .9rem; }
.skeleton { position: relative; overflow: hidden; background: var(--bg-raised); border-radius: var(--radius-s); min-height: 1em; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fg) 8%, transparent), transparent); animation: shimmer 1.4s infinite; }
[aria-busy="true"] { cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- 14. Fenêtres modales (compatibles public.js : .modal-overlay.active) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(16px, 6vh, 72px) 16px; overflow-y: auto;
  background: rgba(13,14,12,.82);
  opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; transition: opacity .3s, visibility 0s; }
.modal-box {
  --bg: var(--paper); --bg-raised: #fbfaf6; --fg: var(--ink); --fg-soft: #3f3c35; --muted: #6b675d; --line: var(--paper-line);
  --accent: var(--ink); --accent-fg: var(--signal); --focus: var(--ink); --field-bg: #fff; --field-line: #a9a39a;
  width: 100%; max-width: 520px; margin: auto 0; background: var(--bg); color: var(--fg);
  border-radius: var(--radius-l); box-shadow: 14px 18px 0 -4px var(--signal);
  transform: translateY(24px) scale(.98); transition: transform .45s var(--ease-out);
}
.modal-overlay.active .modal-box { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: clamp(20px, 4vw, 32px) clamp(20px, 4vw, 32px) 0; }
.modal-header h1, .modal-header h2 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); letter-spacing: -0.03em; }
.modal-body { padding: clamp(18px, 4vw, 28px) clamp(20px, 4vw, 32px) clamp(22px, 4vw, 32px); }
.modal-close { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer; }
.modal-close:hover { background: var(--fg); color: var(--bg); }
.modal-inner-card { margin-top: 10px; padding: 16px; border-radius: var(--radius); border: 1px dashed var(--line); background: var(--bg-raised); }
/* Variante <dialog> native */
dialog.modal { padding: 0; border: 0; background: transparent; max-width: min(560px, calc(100vw - 32px)); width: 100%; color: inherit; }
dialog.modal::backdrop { background: rgba(13,14,12,.82); }
dialog.modal[open] .modal-box { transform: none; animation: modal-in .45s var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }

/* Visionneuse d'image partagée (UI.lightbox) */
.lightbox { border: 0; padding: 0; background: transparent; max-width: min(940px, 92vw); width: 100%; color: var(--paper); }
.lightbox::backdrop { background: rgba(13,14,12,.88); }
.lightbox img { width: 100%; height: auto; max-height: 82vh; object-fit: contain; border-radius: 12px; background: #fff; }
.lightbox[open] img { animation: modal-in .45s var(--ease-out); }
.lightbox-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lightbox-close { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; background: var(--signal); color: var(--ink); border: 0; border-radius: 999px; padding: 8px 16px; font: 700 .9rem var(--f-display); cursor: pointer; }
.lightbox-close:focus-visible { outline-color: var(--paper); }

/* ---------- 15. Pied de page ---------- */
.footer { padding-block: 56px 28px; border-top: 1px solid var(--ink-line); background: var(--ink); color: var(--paper); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.footer-brand { font-family: var(--f-brand); font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 8px; }
.footer-brand b { color: var(--signal); font-weight: 700; }
.footer-note { color: var(--dim); margin: 0; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; align-content: start; }
.footer-links a { text-decoration: none; color: #cfccc3; overflow-wrap: anywhere; }
.footer-links a:hover { color: var(--signal); }
.footer-copy { margin-top: 40px; font-family: var(--f-mono); font-size: .8rem; color: var(--dim); }
.footer :focus-visible { outline-color: var(--signal); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- 16. Apparitions (pilotées par base.js, uniquement si html.js) ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(var(--reveal-y, 28px)); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); transition-delay: var(--d, 0s); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
.js [data-reveal-group] > * { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }
.js [data-reveal-group].is-in > * { opacity: 1; transform: none; }
/* Variante sobre pour les pages de travail (formulaires) */
.calm [data-reveal] { --reveal-y: 12px; transition-duration: .5s; }
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.w > span { display: inline-block; transform: translateY(110%); transition: transform 1s var(--ease-out); transition-delay: calc(var(--i, 0) * 50ms); }
[data-split].is-in .w > span { transform: none; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Pause manuelle (bouton de l'en-tête) et blocs hors écran */
.motion-paused *, .motion-paused *::before, .motion-paused *::after,
.is-off, .is-off *, .is-off *::before, .is-off *::after { animation-play-state: paused !important; }
/* Le spinner doit rester lisible même en pause : il signale un chargement */
.motion-paused .spinner, .motion-paused .btn.is-loading::after { animation-play-state: running !important; }

/* ---------- 17. Rustines viewport (règle AGENTS.md) ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --header-h: 60px; }
  .page { padding-top: calc(var(--header-h) + 24px); }
  .nav { max-height: 100vh; overflow-y: auto; padding-top: 72px; }
  .nav a { font-size: 1.2rem; padding: 4px 0; }
  .modal-overlay { padding-block: 12px; }
}

/* ---------- 18. Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
    transition-duration: .001ms !important; transition-delay: 0s !important;
  }
  .js [data-reveal], .js [data-reveal-group] > *, .w > span { opacity: 1; transform: none; }
  /* Les indicateurs de chargement restent animés lentement : ils portent une information */
  .spinner, .btn.is-loading::after { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
