/* ============================================================
   Neurotest — pages du protocole (asrs, réaction, go/no-go,
   stroop, résultats), alignées sur la refonte de l'accueil.
   Blanc chaud · encre forêt · accent corail · serif éditorial
   ============================================================ */

:root {
  --paper: #f9f7f2;
  --paper-deep: #f1ede3;
  --card: #fffefb;
  --ink: #1c2b26;
  --ink-soft: #5d6b64;
  --ink-faint: #7d766a; /* contraste ≥ 4,5:1 sur le fond papier (WCAG AA) */
  --line: #ded8cc;
  --line-soft: #e9e4d9;
  --accent: #e05c3a;
  --accent-deep: #c94a2a;
  --accent-wash: #f7ddd4;
  --sage-deep: #3e7a5e;
  --sage-wash: #e4ecdf;
  --gold: #c9a227;
  --dark: #1c2b26;
  --dark-line: #33453d;
  --dark-soft: #8fa398;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Archivo", -apple-system, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;

  /* alias conservés pour les scripts/pages existants */
  --font-display: var(--serif);
  --font-body: var(--sans);
  --font-mono: var(--mono);

  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 43, 38, 0.04), 0 12px 32px rgba(28, 43, 38, 0.05);
  --maxw: 1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

/* ---------- Transitions entre pages (View Transitions API) ----------
   Fondu croisé par défaut du navigateur : le plus robuste. */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-wash); color: var(--accent-deep); }

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

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

a { color: var(--accent-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 28px; }

.mono-label {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 76px;
}
.logo {
  font-family: var(--serif); font-size: 24px;
  color: var(--ink); text-decoration: none;
}
.logo em { font-style: normal; color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 26px; font-size: 14.5px; font-weight: 500; }
.header-nav > a { color: var(--ink-soft); text-decoration: none; }
.header-nav > a:hover { color: var(--ink); }
.header-badge {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--sans); font-weight: 600; font-size: 15px;
  padding: 13px 28px; border-radius: 100px;
  border: none; cursor: pointer; text-decoration: none;
  transition: background 0.18s, transform 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--accent-deep); transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--ink-soft); background: var(--card); }
.btn-lg { font-size: 17px; padding: 18px 40px; }
.btn .btn-arrow {
  width: 18px; height: 18px; flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.btn:hover .btn-arrow { transform: translateX(4px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ============================================================
   PAGES DE TEST
   ============================================================ */

.test-page { min-height: 100vh; display: flex; flex-direction: column; }
.test-shell { flex: 1; display: flex; flex-direction: column; padding: 44px 0 64px; }

/* Fil d'étapes */
.stepper {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 34px; flex-wrap: wrap;
}
.stepper .step { display: flex; align-items: center; gap: 10px; }
.stepper .step::after { content: "→"; color: var(--line); margin-left: 10px; }
.stepper .step:last-child::after { content: none; }
.stepper .step.done { color: var(--sage-deep); }
.stepper .step.current { color: var(--accent-deep); }

/* Barre de progression */
.progress-track {
  height: 5px; background: var(--line-soft); border-radius: 100px; overflow: hidden;
  margin-bottom: 36px;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 100px;
  transition: width 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  width: 0%;
}

/* Carte d'instructions */
.instructions-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 48px 50px; max-width: 680px; margin: 0 auto;
}
.instructions-card .kicker {
  font-family: var(--mono); font-size: 11.5px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-deep); display: block; margin-bottom: 16px;
}
.instructions-card h1 { font-size: 2.35rem; margin-bottom: 20px; text-wrap: balance; }
.instructions-card p { color: var(--ink-soft); margin-bottom: 14px; font-size: 15.5px; }
.instructions-card ul { margin: 0 0 18px 20px; color: var(--ink-soft); font-size: 15.5px; }
.instructions-card li { margin-bottom: 8px; }
.instructions-card li b, .instructions-card p b { color: var(--ink); font-weight: 600; }
.instructions-actions { margin-top: 30px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.key-hint {
  font-family: var(--mono); font-size: 12px; color: var(--ink-faint);
}
kbd {
  font-family: var(--mono); font-size: 0.82em;
  background: var(--paper-deep); border: 1px solid var(--line);
  border-bottom-width: 2.5px; border-radius: 6px; padding: 2px 8px;
  color: var(--ink);
}

/* ---------- Questionnaire ASRS ---------- */
.asrs-stage { max-width: 680px; margin: 0 auto; width: 100%; }
.asrs-part-label {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 12px;
}
.asrs-question {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 42px 44px;
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.asrs-qnum {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 16px;
}
.asrs-qtext {
  font-family: var(--serif); font-size: 1.7rem; line-height: 1.25;
  margin-bottom: 32px; text-wrap: balance;
}
.asrs-options { display: grid; gap: 10px; }
.asrs-option {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--paper);
  cursor: pointer; font-size: 15.5px; font-weight: 500; color: var(--ink);
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
  text-align: left; width: 100%; font-family: var(--sans);
}
.asrs-option:hover { border-color: var(--accent); background: var(--card); transform: translateX(3px); }
.asrs-option.selected { border-color: var(--accent); background: var(--accent-wash); }
.asrs-option .opt-key {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; flex-shrink: 0;
}
.asrs-nav { display: flex; justify-content: space-between; margin-top: 22px; align-items: center; }
.asrs-back {
  background: none; border: none; color: var(--ink-faint); cursor: pointer;
  font-family: var(--sans); font-size: 14px; padding: 8px 12px;
}
.asrs-back:hover { color: var(--ink); }

/* ---------- Aire de tâche cognitive ---------- */
.task-arena {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 760px; margin: 0 auto; width: 100%;
  min-height: 440px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.task-hud {
  position: absolute; top: 20px; left: 24px; right: 24px;
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint);
}
.task-center { display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; padding: 30px; }

/* Compte à rebours avant les tâches chronométrées */
.countdown {
  font-family: var(--serif); font-size: 6.5rem; line-height: 1;
  color: var(--accent);
  animation: count-beat 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes count-beat {
  0% { opacity: 0; transform: scale(1.5); }
  30% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.1; transform: scale(0.9); }
}
.fixation {
  font-family: var(--mono); font-size: 2.4rem; color: var(--ink-faint); font-weight: 500;
}
.task-feedback {
  min-height: 1.4em; font-family: var(--mono); font-size: 13px;
}
.task-feedback.ok { color: var(--sage-deep); }
.task-feedback.err { color: var(--accent-deep); }

/* Stimulus temps de réaction */
.rt-target {
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--accent);
  animation: pop 0.12s ease-out;
}
@keyframes pop { from { transform: scale(0.6); } to { transform: scale(1); } }

/* Stimuli Go / No-Go */
.gng-go {
  width: 130px; height: 130px; border-radius: 50%;
  background: var(--sage-deep);
  animation: pop 0.1s ease-out;
}
.gng-nogo {
  width: 130px; height: 130px;
  background: var(--accent);
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  animation: pop 0.1s ease-out;
}

/* Stimulus Stroop */
.stroop-word {
  font-family: var(--sans); font-weight: 700; font-size: 3.6rem;
  letter-spacing: 0.02em; animation: pop 0.1s ease-out;
}
.stroop-buttons {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  width: 100%; max-width: 560px; margin: 0 auto;
}
.stroop-btn {
  padding: 16px 8px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--paper); font-family: var(--sans); font-weight: 600;
  font-size: 15px; color: var(--ink); cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.stroop-btn:hover { border-color: var(--ink-soft); }
.stroop-btn:active { transform: scale(0.96); }
.stroop-btn .opt-key {
  display: block; font-family: var(--mono); font-weight: 400;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); margin-top: 4px;
}

/* Écran de fin d'étape */
.stage-done { text-align: center; padding: 44px 34px; }
.stage-done h2 { font-size: 2.1rem; margin-bottom: 14px; }
.stage-done p { color: var(--ink-soft); margin-bottom: 26px; }
.stage-done .mini-stats {
  display: flex; gap: 34px; justify-content: center; margin-bottom: 30px; flex-wrap: wrap;
}
.mini-stat { text-align: center; }
.mini-stat .v { font-family: var(--serif); font-size: 2rem; color: var(--ink); line-height: 1.1; }
.mini-stat .l {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.12em; margin-top: 4px;
}

/* ============================================================
   RÉSULTATS
   ============================================================ */
.results-header { padding: 56px 0 24px; }
.results-header h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); margin-bottom: 14px; }
.results-header .results-date {
  font-family: var(--mono); font-size: 11.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint);
}

.result-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 40px 44px; margin-bottom: 26px;
  page-break-inside: avoid;
}
/* Liseré d'état : corail = signal, or = à surveiller, vert = dans les repères */
.result-block.state-pos { border-left: 4px solid var(--accent); }
.result-block.state-mid { border-left: 4px solid var(--gold); }
.result-block.state-neg { border-left: 4px solid var(--sage-deep); }

/* Mots-clés colorés dans les textes */
.result-block p b { color: var(--ink); }
.hl-pos { color: var(--accent-deep) !important; }
.hl-mid { color: #8a6d13 !important; }
.hl-neg { color: var(--sage-deep) !important; }

.result-block > .kicker {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-deep); display: block; margin-bottom: 10px;
}
.result-block h2 { font-size: 1.9rem; margin-bottom: 22px; }

.verdict {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px;
  padding: 10px 20px; border-radius: 100px; margin-bottom: 20px;
}
.verdict.pos { background: var(--accent-wash); color: var(--accent-deep); border: 1.5px solid var(--accent); }
.verdict.neg { background: var(--sage-wash); color: var(--sage-deep); border: 1.5px solid var(--sage-deep); }
.verdict.mid { background: #f5ecd3; color: #8a6d13; border: 1.5px solid var(--gold); }

.result-block > p { font-size: 15.5px; color: var(--ink-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 22px 0; }
.metric {
  border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 16px 18px; background: var(--paper);
}
.metric .m-value { font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.metric .m-value small { font-size: 1rem; color: var(--ink-faint); }
.metric .m-label {
  font-family: var(--mono); font-size: 10px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.1em; margin-top: 6px;
}
.metric .m-ref { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; font-style: italic; }
/* Valeur hors repère : tuile mise en évidence */
.metric.flag { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-soft)); background: var(--accent-wash); }
.metric.flag .m-value { color: var(--accent-deep); }

/* Jauge horizontale */
.gauge { margin: 14px 0 6px; }
.gauge-label { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 6px; }
.gauge-track { height: 8px; border-radius: 100px; background: var(--line-soft); overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 100px; background: var(--accent); transition: width 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
.gauge-fill.sage { background: var(--sage-deep); }
.gauge-fill.gold { background: var(--gold); }

/* Bloc synthèse globale */
.synthese-pct { margin: 18px 0 6px; color: var(--ink-soft); font-size: 15.5px; }
.synthese-pct strong {
  font-family: var(--serif); font-weight: 400;
  font-size: 2.4rem; line-height: 1;
  margin-right: 8px; color: var(--ink);
}
.synthese-list { list-style: none; margin: 20px 0 4px; display: grid; gap: 9px; padding: 0; }
.synthese-list li {
  display: flex; gap: 11px; align-items: baseline;
  font-size: 14.5px; color: var(--ink-soft);
}
.synthese-list .sig-mark { font-family: var(--mono); flex-shrink: 0; font-size: 13px; }
.synthese-list li.on { color: var(--ink); }
.synthese-list li.on .sig-mark { color: var(--accent-deep); }
.synthese-list li:not(.on) .sig-mark { color: var(--sage-deep); }
.synthese-list .sig-name { flex: 1; }
.synthese-list li.on .sig-name { font-weight: 600; }
.synthese-list .sig-val {
  font-family: var(--mono); font-size: 12px; white-space: nowrap;
  color: var(--sage-deep);
}
.synthese-list li.on .sig-val { color: var(--accent-deep); font-weight: 600; }

.result-note {
  font-size: 13.5px; color: var(--ink-faint);
  border-top: 1px solid var(--line-soft); padding-top: 16px; margin-top: 22px;
}

.result-empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 32px; text-align: center; color: var(--ink-faint); margin-bottom: 26px;
}
.result-empty a { font-weight: 600; }

.results-actions { display: flex; gap: 14px; flex-wrap: wrap; margin: 34px 0 24px; }

/* Encadré avertissement */
.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 28px 32px; margin-bottom: 60px;
  display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start;
}
.notice .notice-mark {
  font-family: var(--serif); font-style: italic;
  font-size: 1.8rem; color: var(--accent); line-height: 1;
}
.notice p { color: var(--ink-soft); font-size: 14.5px; }
.notice p b { color: var(--ink); font-weight: 600; }
.notice p + p { margin-top: 8px; }

/* ---------- Footer sombre ---------- */
.site-footer {
  background: var(--dark); color: var(--dark-soft);
  padding: 44px 0 54px; margin-top: 40px;
  font-size: 13px;
}
.site-footer .wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; }
.site-footer h4 { font-family: var(--serif); font-weight: 400; font-size: 18px; color: var(--paper); margin-bottom: 10px; }
.site-footer p + p { margin-top: 8px; }
.site-footer a { color: var(--dark-soft); }
.site-footer a:hover { color: var(--paper); }
.footer-fine { font-size: 12px; color: color-mix(in srgb, var(--dark-soft) 75%, var(--dark)); }

/* ---------- Impression / PDF ---------- */
@media print {
  .site-header, .site-footer, .results-actions, .stepper, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .result-block { box-shadow: none; border: 1px solid #ccc; padding: 20px 24px; margin-bottom: 14px; }
  .results-header { padding: 10px 0; }
  .notice { margin-bottom: 20px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .instructions-card, .asrs-question { padding: 32px 26px; }
  .result-block { padding: 28px 24px; }
  .site-footer .wrap { grid-template-columns: 1fr; }
  .header-nav .hide-mobile { display: none; }
  .stroop-word { font-size: 2.6rem; }
  .stroop-buttons { grid-template-columns: repeat(2, 1fr); }
}
