/* Quiz Tanaguru — charte issue du support de formation */
@font-face {
  font-family: "Luciole";
  src: url("assets/fonts/Luciole-Regular.woff2") format("woff2"), url("assets/fonts/Luciole-Regular.ttf") format("truetype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Luciole";
  src: url("assets/fonts/Luciole-Bold.woff2") format("woff2"), url("assets/fonts/Luciole-Bold.ttf") format("truetype");
  font-weight: 700; font-display: swap;
}

:root {
  --navy: #143250;      /* bleu nuit Tanaguru */
  --teal: #055a7f;      /* bleu pétrole */
  --red: #d90b0b;       /* rouge dragon */
  --red-dark: #b50000;
  --green: #0a5a2d;
  --slate: #3c5064;
  --sky: #f5faff;
  --line: #c9d6e3;
  --white: #ffffff;
  --text: #143250;
  --muted: #3c5064;
  --focus: #d90b0b;
  --radius: 14px;
  --font: "Luciole", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--text);
  background: var(--sky); line-height: 1.5; display: flex; flex-direction: column;
}
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--navy); color: #fff; padding: .75rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* En-tête */
.site-header {
  background: var(--navy); color: #fff; padding: .75rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand-logo { background: #fff; border-radius: 10px; padding: 4px 10px; display: flex; }
.brand-logo img { height: 34px; width: auto; }
.brand-title { font-weight: 700; font-size: 1.05rem; }
.header-meta { font-size: .95rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: .2rem .8rem; }

.banner { background: var(--navy); line-height: 0; }
.banner img { width: 100%; height: clamp(60px, 12vw, 150px); object-fit: cover; object-position: center bottom; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.site-footer { text-align: center; font-size: .9rem; color: var(--muted); padding: 1rem; }
.site-footer a { color: var(--teal); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.5rem, 3.5vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); }
p { margin: 0 0 1rem; }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 2rem); box-shadow: 0 2px 10px rgba(20, 50, 80, .06); margin-bottom: 1.25rem;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

/* Formulaires */
label, legend { font-weight: 700; display: block; margin-bottom: .35rem; }
.hint { font-size: .95rem; color: var(--muted); margin: -.15rem 0 .5rem; }
input[type="text"], input[type="password"], select {
  font: inherit; width: 100%; padding: .7rem .85rem; border: 2px solid var(--slate);
  border-radius: 10px; background: #fff; color: var(--text);
}
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; accent-color: var(--teal); }

/* Boutons */
.btn {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .7rem 1.4rem; border-radius: 999px; border: 2px solid transparent;
  background: var(--red); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn-secondary:hover { background: #e8f0f8; }
.btn-teal { background: var(--teal); }
.btn-teal:hover { background: #04465f; }
.btn-lg { font-size: 1.2rem; min-height: 56px; padding: .8rem 2rem; }
.btn[disabled], .btn[aria-disabled="true"] { background: #6b7c8c; cursor: not-allowed; border-color: transparent; color: #fff; }

/* Messages */
.alert { border-radius: 10px; padding: .85rem 1rem; border-left: 6px solid; background: #fff; margin: 1rem 0; }
.alert-error { border-color: var(--red-dark); color: var(--red-dark); }
.alert-info { border-color: var(--teal); }

/* Question */
.q-meta { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-weight: 700; margin-bottom: .5rem; }
.q-title { font-size: clamp(1.3rem, 3vw, 2.1rem); }
.q-title:focus { outline: none; }
.q-title:focus-visible { outline: 3px solid var(--focus); }
.q-instruction { font-weight: 700; color: var(--teal); }

.choices { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .85rem; }
.choice {
  --c: var(--navy);
  width: 100%; height: 100%; min-height: 72px; text-align: left; font: inherit; font-size: 1.1rem;
  display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem;
  border-radius: var(--radius); border: 3px solid var(--c); background: #fff; color: var(--text); cursor: pointer;
}
.choice .key {
  flex: none; width: 2.6rem; height: 2.6rem; border-radius: 10px; background: var(--c); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem;
}
.choice .key svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.choice .label { flex: 1; min-width: 0; }
.choice .state { display: flex; align-items: center; gap: .3rem; margin-top: .4rem; font-weight: 700; font-size: .95rem; }
.choice .state svg { width: 1.2rem; height: 1.2rem; fill: currentColor; flex: none; }
.choice .dist { display: block; margin-top: .4rem; font-weight: 700; font-size: .95rem; }
li:nth-child(1) > .choice { --c: var(--navy); }
li:nth-child(2) > .choice { --c: var(--teal); }
li:nth-child(3) > .choice { --c: var(--red-dark); }
li:nth-child(4) > .choice { --c: var(--green); }
li:nth-child(5) > .choice { --c: var(--slate); }
.choice:hover:not([disabled]):not([aria-pressed="true"]) { background: #eef4fa; }
.choice[aria-pressed="true"]:hover { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { background: var(--c); color: #fff; }
.choice[aria-pressed="true"] .key, .choice[aria-checked="true"] .key { background: #fff; color: var(--c); }
/* La sélection ne repose pas que sur la couleur : coche visible */
.choice[aria-pressed="true"]::after { content: "✓" / ""; flex: none; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.choice[disabled] { cursor: default; }
.choice.is-correct { border-width: 4px; border-style: solid; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--green); }
.choice.is-wrong { border-style: dashed; opacity: .85; }
.choice .bar { display: block; height: 8px; border-radius: 4px; background: currentColor; opacity: .5; margin-top: .35rem; }

/* Écran formateur : affichage projeté */
.host-screen .choice { pointer-events: none; font-size: clamp(1.1rem, 2vw, 1.5rem); }
.host-screen .q-title { font-size: clamp(1.6rem, 3.4vw, 2.8rem); }

.timer { display: flex; align-items: center; gap: .75rem; font-weight: 700; }
.timer-track { flex: 1; height: 12px; background: #dde7f0; border-radius: 6px; overflow: hidden; }
.timer-fill { height: 100%; background: var(--teal); width: 100%; transition: width .25s linear; }
.timer-value { min-width: 4.5ch; text-align: right; font-variant-numeric: tabular-nums; font-size: 1.3rem; }

.explain { background: #eef4fa; border-left: 6px solid var(--teal); border-radius: 10px; padding: 1rem 1.25rem; margin-top: 1.25rem; font-size: 1.1rem; }
.feedback { font-size: 1.6rem; font-weight: 700; display: flex; align-items: center; gap: .75rem; justify-content: center; }
.feedback.ok { color: var(--green); }
.feedback.ko { color: var(--red-dark); }
.feedback svg { width: 2.2rem; height: 2.2rem; fill: currentColor; }

/* Lobby */
.join-box { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; }
.join-url { font-size: clamp(1.4rem, 3.5vw, 2.6rem); font-weight: 700; word-break: break-all; color: var(--teal); }
.access-code { font-size: clamp(1.2rem, 2.6vw, 1.8rem); margin: 0; }
.access-code strong { display: inline-block; letter-spacing: .25em; padding: .1rem .6rem; border: 3px solid var(--red); border-radius: 10px; color: var(--navy); font-family: Consolas, "Courier New", monospace; }
.qr { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); width: 240px; }
.qr img, .qr canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.players li { background: var(--navy); color: #fff; border-radius: 999px; padding: .35rem .5rem .35rem 1rem; display: flex; align-items: center; gap: .4rem; font-weight: 700; }
.players li.off { background: var(--slate); }
.players button { font: inherit; background: transparent; border: 0; color: #fff; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; }
.players button:hover { background: rgba(255,255,255,.2); }
.big-number { font-size: 3rem; font-weight: 700; color: var(--red); line-height: 1; }

/* Classement */
.ranking { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.ranking li { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; border-radius: 12px; background: #fff; border: 1px solid var(--line); margin-bottom: .5rem; font-size: 1.2rem; }
.ranking .pos { width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 700; flex: none; }
.ranking li:nth-child(1) .pos { background: var(--red); }
.ranking .name { flex: 1; font-weight: 700; }
.ranking .pts { font-variant-numeric: tabular-nums; font-weight: 700; }
.ranking .delta { color: var(--green); font-size: .95rem; margin-left: .5rem; }

/* Résumé « qui a bien répondu » à la révélation */
.who-box { margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.who { display: flex; align-items: flex-start; gap: .45rem; margin: 0; padding: .55rem .85rem; border-radius: 10px; font-size: clamp(1rem, 1.6vw, 1.25rem); background: #fff; border: 2px solid; }
.who svg { width: 1.4rem; height: 1.4rem; fill: currentColor; flex: none; margin-top: .1rem; }
.who.ok { color: var(--green); border-color: var(--green); background: #eef7f1; }
.who.ko { color: var(--red-dark); border-color: var(--red-dark); background: #fdf0f0; }
.who.none { color: var(--slate); border-color: var(--line); }

/* Tableaux de résultats */
.table-scroll { overflow-x: auto; }
.report { width: 100%; border-collapse: collapse; font-size: 1rem; }
.report th, .report td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.report thead th { background: var(--navy); color: #fff; white-space: nowrap; }
.report tbody th { font-weight: 700; white-space: nowrap; }
.report tfoot th, .report tfoot td { font-weight: 700; background: #eef4fa; }
.report .cell { text-align: center; }
.report .ok, .report .ko, .report .none { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; }
.report .ok { color: var(--green); }
.report .ko { color: var(--red-dark); }
.report .none { color: var(--slate); }
.report svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.q-list li { margin-bottom: .75rem; }
.bilan-list { list-style: none; padding: 0; margin: 0; }
.bilan-list li { border: 1px solid var(--line); border-left-width: 6px; border-radius: 10px; padding: .85rem 1rem; margin-bottom: .75rem; background: #fff; }
.bilan-list li.ok { border-left-color: var(--green); }
.bilan-list li.ko { border-left-color: var(--red-dark); }
.bilan-list .verdict { display: flex; align-items: center; gap: .35rem; font-weight: 700; }
.bilan-list li.ok .verdict { color: var(--green); }
.bilan-list li.ko .verdict { color: var(--red-dark); }
.bilan-list svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }

@media print {
  .site-header, .banner, .toolbar, #toolbar, .skip, .site-footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .report thead th { background: #fff; color: #000; border-bottom: 2px solid #000; }
}

.toolbar { position: sticky; bottom: 0; background: var(--white); border-top: 1px solid var(--line); padding: .75rem 1rem; display: flex; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; z-index: 5; }

.quiz-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.quiz-item { display: block; width: 100%; height: 100%; text-align: left; font: inherit; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 1.1rem; color: var(--text); cursor: pointer; }
.quiz-item:hover { border-color: var(--teal); }
.quiz-item[aria-pressed="true"] { border-color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.quiz-item strong { display: block; font-size: 1.1rem; margin-bottom: .25rem; }
.quiz-item span { color: var(--muted); font-size: .95rem; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .join-box { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .choices { grid-template-columns: 1fr; }
  .toolbar .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Utilitaires : anciens attributs style="" sortis des pages (CSP style-src 'self') */
.u1 { justify-content:space-between !important; }
.u2 { margin:0 !important; }
.u3 { margin-top:1rem !important; }
.u4 { min-width:240px !important; }
.u5 { min-width:200px !important; }
.u6 { max-width:420px !important; }
.u7 { width:auto !important; }
.u8 { margin:.5rem 0 0 !important; }
.u9 { max-width:520px !important;margin:0 auto !important; }
.u10 { font-weight:400 !important; }
.u11 { font-size:1.3rem !important; }
.u12 { margin-top:1rem !important;font-size:1.3rem !important; }
.u13 { font-size:1rem !important; }
.u14 { max-width:560px !important;margin:0 auto !important; }
.u15 { margin-top:1.25rem !important; }
.u16 { text-align:left !important; }
.u17 { justify-content:center !important; }
