/* Interface volontairement neutre (gris, noir, blanc) : aucune couleur d'accent
   ne doit influencer la perception des couleurs testées. */
:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #ececea;
  --ink: #191918;
  --ink-2: #5f5f5b;
  --ink-3: #8c8c87;
  --line: #dcdcd7;
  --btn: #191918;
  --btn-ink: #ffffff;
  --danger: #8a2b22;
  --test-bg: #777776;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 28px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #141413;
    --surface: #1d1d1c;
    --surface-2: #272725;
    --ink: #f0f0ec;
    --ink-2: #a9a9a3;
    --ink-3: #7b7b76;
    --line: #34342f;
    --btn: #f0f0ec;
    --btn-ink: #141413;
    --danger: #e08a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 750; }
h3 { font-size: 1rem; }
code, kbd { font: 0.85em ui-monospace, 'SF Mono', Menlo, monospace; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; background: var(--surface); }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.eyebrow { margin: 0 0 0.4rem; font-size: 0.75rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.lede { font-size: 1.1rem; color: var(--ink-2); max-width: 62ch; margin: 0.75rem 0 0; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a { text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 999px; color: var(--ink-2); font-weight: 550; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { background: var(--surface-2); color: var(--ink); }

/* ---------- Pages ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px) 80px; }
.page.narrow { max-width: 720px; }
.page-head { margin-bottom: 2rem; }
.section-title { margin: 3rem 0 1rem; font-size: 1.4rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }
.link { background: none; border: 0; padding: 0.4rem; font: inherit; color: inherit; cursor: pointer; }
.link:disabled { opacity: 0.35; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--ink-3); font-size: 0.9rem; cursor: pointer; padding: 0.3rem; margin-left: auto; }
.icon-btn:hover { color: var(--danger); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.cta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.6rem 0 1rem; }

/* ---------- Accueil ---------- */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(24px, 5vw, 64px); align-items: center; }
.hero-map { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); display: block; }
.steps { list-style: none; padding: 0; margin: 4rem 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.steps p { margin: 0.4rem 0 0; color: var(--ink-2); font-size: 0.95rem; }
.step-n { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--surface-2); font-weight: 700; margin-bottom: 0.7rem; }

/* ---------- Mise en page carte + panneau ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(20px, 3vw, 40px); align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; display: grid; gap: 1rem; }
.block h3 { margin-bottom: 0.3rem; }
.block p { margin: 0.2rem 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Carte ---------- */
.map-grid {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas: '. . cols' 'ytitle rows body' '. . hues' '. . xtitle';
  column-gap: 0.45rem; row-gap: 0.3rem;
  font-size: 0.75rem; color: var(--ink-3);
}
.map-cols { grid-area: cols; display: grid; grid-template-columns: repeat(13, 1fr); text-align: center; font-weight: 650; }
.map-rows { grid-area: rows; display: grid; grid-template-rows: repeat(10, 1fr); align-items: center; text-align: right; font-weight: 650; }
.map-ytitle { grid-area: ytitle; display: flex; flex-direction: column; justify-content: space-between; }
.map-ytitle span { writing-mode: vertical-rl; transform: rotate(180deg); }
.map-body { grid-area: body; position: relative; aspect-ratio: 13 / 10; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.map-hues { grid-area: hues; display: grid; grid-template-columns: repeat(13, 1fr); text-align: center; font-size: 0.68rem; }
.map-xtitle { grid-area: xtitle; display: flex; justify-content: space-between; font-weight: 600; color: var(--ink-2); }
.map-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: pan-y; }

.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(13, 1fr); grid-template-rows: repeat(10, 1fr); gap: 2px; }
.cell { border: 0; padding: 0; border-radius: 3px; cursor: pointer; transition: transform 0.1s; }
.cell:hover { transform: scale(1.08); z-index: 1; position: relative; }
.cell.selected { box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px #111; z-index: 2; position: relative; }

.refs { position: absolute; inset: 0; pointer-events: none; }
.ref { position: absolute; transform: translate(-50%, -50%); width: 14px; height: 14px; pointer-events: auto; }
.ref i { position: absolute; inset: 0; background: var(--c); border: 2px solid #fff; outline: 1.5px solid rgba(0, 0, 0, 0.7); transform: rotate(45deg); }
.ref b { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 0.7rem; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; }

.readout { min-height: 1.6em; margin: 0.8rem 0 0.4rem; font-size: 0.9rem; color: var(--ink-2); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.map-controls { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.legend { font-size: 0.82rem; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { display: inline-block; flex: none; }
.lg-zone { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, #888 0 50%, #ccc 50%); }
.lg-line { width: 18px; height: 3px; background: var(--ink); }
.lg-dash { width: 18px; height: 2px; background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 7px); }
.lg-yes { width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 1.5px solid #333; }
.lg-no { width: 6px; height: 6px; border-radius: 50%; background: #555; }
.lg-ideal { width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--ink-3); }

/* ---------- Panneaux de détail ---------- */
.sw { display: inline-block; width: 1em; height: 1em; border-radius: 4px; vertical-align: -0.15em; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); flex: none; }
.sw-md { width: 1.6rem; height: 1.6rem; border-radius: 6px; }
.sw.empty, .swatch-lg.empty { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, transparent 6px 12px) !important; box-shadow: inset 0 0 0 1px var(--line); }
.swatch-lg { aspect-ratio: 16 / 9; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.cell-code { font-size: 1.6rem; margin-top: 0.6rem; }
.ideal { display: grid; gap: 0.25rem; }
.ideal .cell-code { margin-top: 0; }
.ideal p { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; }
.toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; cursor: pointer; }
.toggle input { width: 1rem; height: 1rem; accent-color: var(--ink); }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; font-size: 0.85rem; }
.ref-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.5rem; align-items: center; }
.slider { display: grid; gap: 0.3rem; font-size: 0.92rem; }
.slider input { width: 100%; accent-color: var(--ink); }
.method summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.method p { font-size: 0.88rem; color: var(--ink-2); }
.hesitations { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.4rem; }
.hesitations li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: center; font-size: 0.9rem; }
.data-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.data-tools .btn { padding: 0.45rem 0.9rem; font-size: 0.88rem; }

/* ---------- Formulaire du test ---------- */
.setup { display: grid; gap: 1.5rem; }
.field { display: grid; gap: 0.4rem; font-weight: 600; }
.field input { font: inherit; font-weight: 400; padding: 0.7rem 0.9rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.modes { border: 0; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.modes legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }
.mode { display: flex; gap: 0.75rem; align-items: center; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.mode:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode input { accent-color: var(--ink); }
.mode span { display: grid; }
.mode small { color: var(--ink-2); }
.tips { margin: 0; padding-left: 1.2rem; color: var(--ink-2); display: grid; gap: 0.3rem; }
.setup .btn.primary { justify-self: start; padding: 0.8rem 1.8rem; font-size: 1.05rem; }

/* ---------- Test immersif : fond gris neutre, rien d'autre à l'écran ---------- */
body.immersive { background: var(--test-bg); overflow: hidden; color: #fff; }
body.immersive .topbar { display: none; }
.test { height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; padding: 16px; user-select: none; -webkit-user-select: none; }
.test-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 1rem; padding: 0.9rem clamp(16px, 4vw, 40px); }
.test-top .link { color: rgba(255, 255, 255, 0.85); font-size: 0.9rem; }
.progress { flex: 1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.progress-bar { height: 100%; background: rgba(255, 255, 255, 0.9); width: 0; transition: width 0.25s; }
.progress-count { font-size: 0.85rem; color: rgba(255, 255, 255, 0.85); min-width: 4.5em; text-align: right; }
.deck { position: relative; width: min(78vw, 340px, 52dvh); aspect-ratio: 3 / 4; }
.card-slot { position: absolute; inset: 0; border-radius: 26px; border: 2px dashed rgba(255, 255, 255, 0.25); }
.card { position: absolute; inset: 0; border-radius: 26px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28); cursor: grab; touch-action: none; }
.card:active { cursor: grabbing; }
.card.animating { transition: transform 0.24s ease, opacity 0.24s ease; }
.stamp { position: absolute; top: 22px; padding: 0.3rem 0.7rem; border: 3px solid #fff; border-radius: 8px; color: #fff; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.95rem; opacity: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); background: rgba(0, 0, 0, 0.18); }
.stamp-yes { left: 20px; transform: rotate(-12deg); }
.stamp-no { right: 20px; transform: rotate(12deg); }
.question { margin: 0.4rem 0 0; font-size: 1.3rem; font-weight: 700; }
.choices { display: flex; align-items: center; gap: 1.6rem; }
.choices .link { color: rgba(255, 255, 255, 0.85); font-size: 0.9rem; }
.choice { width: 68px; height: 68px; border-radius: 50%; border: 0; background: #fff; color: #222; font-size: 1.7rem; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); transition: transform 0.1s; }
.choice:hover { transform: scale(1.06); }
.choice:active { transform: scale(0.95); }
.hint { margin: 0; font-size: 0.82rem; color: rgba(255, 255, 255, 0.75); }
.hint kbd { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.35); color: #fff; }

/* ---------- Galerie des participants ---------- */
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.person canvas { display: block; width: 100%; height: auto; }
.person-meta { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.8rem; }
.person-meta a { text-decoration: none; }
.person-meta p { margin: 0.1rem 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .map-hues { font-size: 0.56rem; }
  .map-hues span:nth-child(even) { visibility: hidden; }
  .map-hues span:last-child { text-align: right; }
  .map-grid { font-size: 0.65rem; column-gap: 0.25rem; }
  .ref b { display: none; }
  .topbar nav a { padding: 0.3rem 0.5rem; font-size: 0.92rem; }
}
