/* Tableau de bord Writilia — interface V2 (Spec 09). CSS vanilla, aucun framework (Spec 04, D6).
   Jetons repris de la charte Figma « Writilia V2 — couleurs » ; contrastes vérifiés par tests/interface.test.mjs. */

/* ---- Polices auto-hébergées (Geist 1.3.1, SIL OFL : public/fonts/OFL.txt) */
@font-face { font-family: "Geist"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/geist-1.3.1-400.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/geist-1.3.1-500.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/geist-1.3.1-600.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/geist-mono-1.3.1-400.woff2") format("woff2"); }

/* ---- D1 : jetons de couleur (clair) */
:root {
  --fond: #F7F7FB; --surface: #FFFFFF; --surface-2: #F0F0F8;
  --texte: #14123A; --discret: #5B5A7A; --sur-accent: #FFFFFF; --sur-couleur: #14123A;
  --bord: #E3E3EF; --bord-fort: #8A88A3;
  --accent: #4338CA; --accent-doux: #EEF0FF; --lien-logo: #C7CBF5; --valide: #10B981;
  --ok: #047857; --ok-fond: #E7F8F1; --alerte: #B45309; --alerte-fond: #FEF4E6; --erreur: #B91C1C; --erreur-fond: #FDECEC;
  --module-faits: #F59E0B; --module-maillage: #0EA5E9; --module-studio: #EC4899;
  --info: var(--accent); --info-fond: var(--accent-doux);
  --ombre-1: 0 1px 2px rgb(20 18 58 / 6%), 0 1px 3px rgb(20 18 58 / 4%);
  --ombre-2: 0 4px 12px rgb(20 18 58 / 8%), 0 2px 4px rgb(20 18 58 / 4%);
  --ombre-3: 0 12px 32px rgb(20 18 58 / 14%), 0 4px 8px rgb(20 18 58 / 6%);
  --police: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --police-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light dark;
}
/* ---- D1 : jetons de couleur (sombre) */
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0E0D1F; --surface: #17162E; --surface-2: #201F3D;
    --texte: #ECEBFA; --discret: #A3A2C2; --sur-accent: #0E0D1F; --sur-couleur: #0E0D1F;
    --bord: #2E2D52; --bord-fort: #6A6798;
    --accent: #A5B4FC; --accent-doux: #25245A; --lien-logo: #4F4D9C; --valide: #34D399;
    --ok: #6EE7B7; --ok-fond: #10352A; --alerte: #FBBF24; --alerte-fond: #3A2A0E; --erreur: #F87171; --erreur-fond: #3A1515;
    --module-faits: #FBBF24; --module-maillage: #38BDF8; --module-studio: #F472B6;
  }
}
/* Panneau de marque de la connexion : toujours en sombre (mêmes valeurs que le bloc sombre). */
.force-sombre {
  --fond: #0E0D1F; --surface: #17162E; --surface-2: #201F3D;
  --texte: #ECEBFA; --discret: #A3A2C2; --sur-accent: #0E0D1F; --sur-couleur: #0E0D1F;
  --bord: #2E2D52; --bord-fort: #6A6798;
  --accent: #A5B4FC; --accent-doux: #25245A; --lien-logo: #4F4D9C; --valide: #34D399;
  --ok: #6EE7B7; --ok-fond: #10352A; --alerte: #FBBF24; --alerte-fond: #3A2A0E; --erreur: #F87171; --erreur-fond: #3A1515;
  --module-faits: #FBBF24; --module-maillage: #38BDF8; --module-studio: #F472B6;
  background: var(--fond); color: var(--texte);
}

/* ---- Base et D2 : typographie */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 400 16px/26px var(--police); }
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.02em; margin: 4px 0 24px; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 16px 0 8px; }
.display { font-size: 48px; line-height: 56px; letter-spacing: -0.03em; }
code, pre, kbd { font-family: var(--police-mono); font-size: 13px; line-height: 20px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 12px; border-radius: 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 640px) {
  h1 { font-size: 26px; line-height: 34px; }
  .display { font-size: 32px; line-height: 40px; }
}

/* ---- D4 : logo */
.symbole { display: block; flex: none; }
.symbole .trait { fill: none; stroke: var(--lien-logo); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.symbole .noeud { fill: var(--accent); }
.symbole .noeud.valide { fill: var(--valide); }
.marque { display: inline-flex; align-items: center; gap: 10px; color: var(--texte); text-decoration: none;
  font-weight: 600; font-size: 24px; letter-spacing: -0.03em; }

/* ---- D5 : mise en page avec barre latérale */
.appli { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.laterale { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  padding: 24px 16px; background: var(--surface); border-right: 1px solid var(--bord); }
.laterale .marque { padding: 0 8px 20px; }
.navigation ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.navigation a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--discret); text-decoration: none;
  font-size: 14px; line-height: 22px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navigation a:hover { background: var(--surface-2); color: var(--texte); }
.navigation a[aria-current="page"] { background: var(--accent-doux); color: var(--accent); }
.navigation .rubrique { padding: 16px 12px 4px; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .01em;
  text-transform: uppercase; color: var(--discret); }
.laterale .deconnexion { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px 8px 0; border-top: 1px solid var(--bord); color: var(--discret); font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
.principal { min-width: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 40px 48px 64px; }
.sans-barre main { padding-top: 64px; }
.fil { color: var(--discret); font-size: 14px; line-height: 22px; margin-bottom: 8px; }
.fil a { color: var(--discret); }
@media (max-width: 900px) {
  /* Spec 09c : en une colonne, l'espace libre (min-height: 100vh) ne va plus étirer la barre du haut. */
  .appli { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .laterale { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px;
    padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--bord); }
  .laterale .marque { padding: 0; font-size: 20px; }
  .navigation { order: 3; flex-basis: 100%; overflow-x: auto; }
  .navigation ul { flex-direction: row; gap: 4px; }
  .navigation .rubrique { display: none; }
  .laterale .deconnexion { margin: 0 0 0 auto; flex-direction: row; align-items: center; padding: 0; border: 0; }
  .laterale .deconnexion span { display: none; }
  main { padding: 24px 16px 48px; }
}

/* ---- D6 : composants */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 16px; padding: 24px; margin-bottom: 16px;
  overflow-x: auto; box-shadow: var(--ombre-1); }
.carte.flottante { box-shadow: var(--ombre-3); }
.etroite { max-width: 400px; margin: 0 auto; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grille > .carte { margin-bottom: 0; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--discret); }
dd { margin: 0; overflow-wrap: anywhere; }
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 22px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { background: var(--surface-2); color: var(--discret); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .01em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
label { display: block; margin-bottom: 16px; font-size: 14px; line-height: 22px; font-weight: 500; }
input, textarea, select { display: block; width: 100%; margin-top: 6px; padding: 10px 14px; font: 400 16px/24px var(--police);
  color: var(--texte); background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 6px; }
input::placeholder, textarea::placeholder { color: var(--discret); }
input.grand { padding: 14px 16px; font-size: 18px; line-height: 26px; }
button, a.bouton { display: inline-block; font: 500 14px/22px var(--police); padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--sur-accent); cursor: pointer; text-decoration: none; }
button:hover, a.bouton:hover { box-shadow: var(--ombre-2); }
a.bouton.secondaire, button.secondaire { background: var(--surface); color: var(--texte); border-color: var(--bord-fort); }
a.bouton.discret, button.discret { background: transparent; color: var(--accent); border-color: transparent; }
button.ok { background: var(--ok); border-color: var(--ok); color: var(--sur-accent); }
button.alerte { background: var(--erreur-fond); border-color: var(--erreur-fond); color: var(--erreur); }
.deconnexion button { padding: 4px 10px; background: transparent; color: var(--texte); border-color: var(--bord-fort); font-size: 12px; line-height: 16px; }
button:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
form.en-ligne { margin-top: 12px; }
.pastille { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; line-height: 16px; font-weight: 500; background: var(--surface-2); color: var(--discret); }
.pastille::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pastille.ok { background: var(--ok-fond); color: var(--ok); }
.pastille.alerte { background: var(--alerte-fond); color: var(--alerte); }
.pastille.erreur { background: var(--erreur-fond); color: var(--erreur); }
.pastille.info { background: var(--accent-doux); color: var(--accent); }
.degrade { background: var(--alerte-fond); color: var(--alerte); border-radius: 10px; padding: 12px 16px; margin: 8px 0 16px; }
.degrade ul { margin: 4px 0 0; padding-left: 20px; }
/* Spec 06d : points de préparation (chemins, en-têtes CSV) coupés plutôt que de déborder sur mobile. */
.points li { overflow-wrap: anywhere; }
/* Spec 06e : liste des faits de « Mon site » (texte, puis source en note). */
.faits { padding-left: 20px; }
.faits li + li { margin-top: 12px; }
.faits p { margin: 0; overflow-wrap: anywhere; }
.erreur { color: var(--erreur); }
.note { color: var(--discret); font-size: 14px; line-height: 22px; }
.journal { padding-left: 20px; }
.journal li { margin-bottom: 6px; }
details summary { cursor: pointer; color: var(--discret); }

/* Étapes du suivi : un nœud par étape, relié au suivant (Spec 09, D6). */
.etapes { list-style: none; padding-left: 0; margin: 16px 0; }
.etapes li { position: relative; padding: 0 0 18px 34px; color: var(--discret); font-size: 14px; line-height: 22px; }
.etapes li::before { content: ""; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--bord-fort); }
.etapes li::after { content: ""; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--bord); }
.etapes li:last-child::after { display: none; }
.etapes li.fait { color: var(--texte); }
.etapes li.fait::before { background: var(--accent); border-color: var(--accent); }
.etapes li.fait::after { background: var(--lien-logo); }
.etapes li.en_cours { color: var(--texte); font-weight: 600; }
.etapes li.en_cours::before { background: var(--valide); border-color: var(--valide); box-shadow: 0 0 0 4px var(--ok-fond); }

/* Symbole d'avancement : nœuds allumés selon les étapes (Spec 09, D7). */
.avancement { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; }
.avancement .noeud.a_venir { fill: var(--bord); }
.avancement .noeud.en_cours { fill: var(--valide); animation: pulsation 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulsation { 50% { opacity: .45; transform: scale(.82); } }

/* ---- Accueil et sites */
.accroche { margin-bottom: 24px; }
.accroche .note { margin: 0 0 4px; }
.tenants { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tenants li { margin: 0; }
.tenants a { display: flex; flex-direction: column; gap: 4px; padding: 20px 24px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 16px; box-shadow: var(--ombre-1); text-decoration: none; color: var(--texte); font-weight: 600; font-size: 18px; line-height: 26px; }
.tenants a:hover { box-shadow: var(--ombre-2); border-color: var(--bord-fort); }
.tenants code { color: var(--discret); font-weight: 400; }

/* ---- Relecture : article en page, barre d'action collée en bas (Spec 09, D7) */
.rendu { max-width: 72ch; font-size: 18px; line-height: 30px; }
.rendu h1 { font-size: 32px; line-height: 40px; }
.rendu h2 { font-size: 24px; line-height: 32px; margin-top: 32px; }
.rendu table { margin: 16px 0; }
.rendu .fait { font-family: var(--police-mono); font-size: 12px; line-height: 16px; color: var(--alerte);
  border-bottom: 1.5px solid var(--alerte); margin: 0 2px; vertical-align: super; white-space: nowrap; }
.papier { padding: 48px 56px; }
.barre-action { position: sticky; bottom: 16px; z-index: 1; box-shadow: var(--ombre-3); overflow: visible; }
.barre-action textarea { min-height: 0; }
.barre-action .actions { justify-content: flex-end; }
@media (max-width: 900px) { .papier { padding: 24px 20px; } }

/* ---- Connexion (Spec 09, D5) */
.connexion { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); min-height: 100vh; }
.connexion-marque { display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 64px; }
.connexion-marque .slogan { font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.02em; max-width: 18ch; margin: 0; }
.connexion-marque ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; color: var(--discret); }
.connexion-marque li { display: flex; gap: 12px; align-items: center; }
.connexion-marque li::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--valide); }
.connexion-formulaire { display: flex; align-items: center; justify-content: center; max-width: none; margin: 0; padding: 48px 24px; background: var(--surface); }
.connexion-formulaire .etroite { width: 100%; }
.connexion-formulaire .marque { margin-bottom: 24px; }
.connexion-formulaire button { width: 100%; }
@media (max-width: 900px) {
  .connexion { grid-template-columns: minmax(0, 1fr); }
  .connexion-marque { display: none; }
}

/* ---- Correction versionnée (Spec 05b) */
textarea.editeur, pre.texte-source { font-family: var(--police-mono); font-size: 13px; line-height: 20px; }
pre.texte-source { max-height: 36rem; overflow: auto; }

/* ---- Accessibilité */
.visuellement-cache { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Spec 06b : sujets suggérés du plan de mots-clés. */
.suggestions { margin-top: 24px; }
.suggestions ul { padding-left: 20px; }
.suggestions li + li { margin-top: 8px; }
.suggestions li.traite > a { color: var(--discret); }
