/* ==========================================================
   Interrogation d'Aikido — feuille de style
   Palette : gofun (blanc craie), sumi (encre), ai (indigo),
             matcha (vert, OK), beni (rose-rouge, à travailler)
   ========================================================== */

:root {
  --bg: #eef0ea;
  --surface: #fbfbf8;
  --ink: #191c24;
  --muted: #5f6572;
  --line: #d6d9d0;

  --ai: #22355e;
  --ai-ink: #ffffff;
  --ok: #3b6f43;
  --ok-ink: #ffffff;
  --ok-soft: #dcebdd;
  --work: #a3304a;
  --work-soft: #f5dfe4;

  --font-body: "Avenir Next", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-name: "Hiragino Mincho ProN", "Yu Mincho", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  --radius: 10px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--ai) 45%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171c26;
    --ink: #e8e9e3;
    --muted: #9ba1ae;
    --line: #2b3242;

    --ai: #9db2e6;
    --ai-ink: #0e1524;
    --ok: #7cc78b;
    --ok-ink: #0c1d10;
    --ok-soft: #17301d;
    --work: #f08ea4;
    --work-soft: #3a1b25;
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

/* ---------- En-tête ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.5rem;
  color: var(--ai);
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-name);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.enso { width: 2.5rem; height: 2.5rem; flex: none; }

/* ---------- Structure ---------- */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 3rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
}

h2 {
  margin: 0 0 1rem;
  font-family: var(--font-name);
  font-size: 1.5rem;
  font-weight: 600;
}

h2:focus { outline: none; }

.muted { color: var(--muted); }

.label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0.6rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:focus-visible,
.link-btn:focus-visible,
.chip input:focus-visible + span,
input[type="number"]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn-primary { background: var(--ai); color: var(--ai-ink); }
.btn-primary:hover { filter: brightness(1.1); }

.btn-ok { background: var(--ok); color: var(--ok-ink); }
.btn-ok:hover { filter: brightness(1.1); }

.btn-work { background: transparent; border-color: var(--work); color: var(--work); }
.btn-work:hover { background: var(--work-soft); }

.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ai); }

.btn-large { min-height: 3.5rem; padding-inline: 1.75rem; font-size: 1.05rem; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.link-btn {
  padding: 0.25rem 0.4rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ai);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.file-btn { cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { box-shadow: var(--focus); }

/* ---------- Écran de préparation ---------- */

fieldset {
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 11rem;
  overflow-y: auto;
  padding: 2px;
}

.chip { position: relative; }

.chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.chip span {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 0.95rem;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover span { border-color: var(--ai); }

.chip input:checked + span {
  background: var(--ai);
  border-color: var(--ai);
  color: var(--ai-ink);
}

.max-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

input[type="number"] {
  width: 6.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.setup-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.match-info { margin: 0; }

.notice {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--ai);
  border-radius: 6px;
  background: var(--bg);
}

.notice p { margin: 0 0 0.75rem; }
.notice p:last-child { margin-bottom: 0; }
.notice-error { border-left-color: var(--work); }

/* ---------- Écran d'interrogation ---------- */

.quiz-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.counter {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Le cercle se referme à mesure que l'interrogation avance */
.ring { width: 4.5rem; height: 4.5rem; transform: rotate(-90deg); flex: none; }

.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: var(--line); }
.ring-fill {
  stroke: var(--ai);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.ring-number {
  position: absolute;
  left: 0;
  top: 0;
  width: 4.5rem;
  height: 4.5rem;
  display: grid;
  place-items: center;
  font-family: var(--font-name);
  font-size: 1.6rem;
  font-weight: 600;
}

.counter-text { display: flex; flex-direction: column; }

.quiz-top-right { display: flex; align-items: center; gap: 0.75rem; }

.badge {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.badge[data-status="ok"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.badge[data-status="travail"] { background: var(--work-soft); border-color: var(--work); color: var(--work); }

.technique {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2rem;
  margin: 1.75rem 0 1.25rem;
  padding: 1.25rem 0;
  border-block: 1px solid var(--line);
}

.tech-block + .tech-block {
  padding-left: 2rem;
  border-left: 1px solid var(--line);
}

.tech-name {
  margin: 0.15rem 0 0;
  font-family: var(--font-name);
  font-size: clamp(1.6rem, 4.2vw, 2.6rem);
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.kyu-tag {
  grid-column: 1 / -1;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #0a0c10;
}

.video-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  background: #0a0c10;
  color: #f0f0ea;
  pointer-events: none;
}

.video-msg p { margin: 0; }
.video-msg p:first-child { font-size: 1.1rem; font-weight: 600; }
.video-msg-file { margin-top: 0.35rem !important; color: #a9aeb9; font-size: 0.9rem; overflow-wrap: anywhere; }

.indication {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-left: 4px solid var(--ai);
  border-radius: 6px;
  background: var(--bg);
}

.indication p { margin: 0.2rem 0 0; }

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ---------- Rapport ---------- */

.report-meta {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
}

.report-meta div { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.report-meta dt { min-width: 5.5rem; color: var(--muted); }
.report-meta dd { margin: 0; font-weight: 600; }

.table-wrap { overflow-x: auto; }

.report-table {
  width: 100%;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.report-table th { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.report-table td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.report-table td:last-child { width: 1%; white-space: nowrap; }

.result-tag {
  display: inline-block;
  min-width: 6.5rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.result-tag[data-result="ok"] { background: var(--ok-soft); color: var(--ok); }
.result-tag[data-result="travail"] { background: var(--work-soft); color: var(--work); }

.report-actions { margin-top: 1.75rem; }

/* ---------- Petits écrans ---------- */

@media (max-width: 640px) {
  .panel { padding: 1.25rem; }

  .technique { grid-template-columns: 1fr; }

  .tech-block + .tech-block {
    margin-top: 1rem;
    padding-top: 1rem;
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .setup-footer .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Impression : uniquement le rapport ---------- */

@media print {
  body { background: #fff; color: #000; }
  .site-header,
  .actions,
  #screen-setup,
  #screen-quiz { display: none !important; }
  .panel { border: 0; padding: 0; background: #fff; }
  .result-tag { border: 1px solid #000; background: none !important; color: #000 !important; }
}
