/* Asymptote — écran de contrôle.
   Le parti pris visuel est celui d'un oscilloscope : fond d'encre, grille faible, tracés
   lumineux. Ce n'est pas décoratif — la lisibilité d'une courbe sur fond sombre est ce qui
   permet de superposer six trajectoires sans que la figure devienne illisible. */

:root {
  color-scheme: dark;
  --ink: #070a12;
  --panel: #0d1220;
  --panel-2: #131a2c;
  --line: #1e2942;
  --grid: #16203a;
  --text: #e8edf7;
  --dim: #8797b5;
  --faint: #566a8e;
  --accent: #4cc9f0;
  --good: #06d6a0;
  --warn: #ffd166;
  --bad: #f72585;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter Tight", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 1fr 330px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "head head" "stage side" "foot foot";
  height: 100%;
  gap: 1px;
  background: var(--line);
}

/* ---------------------------------------------------------------- en-tête */

header {
  grid-area: head;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 650;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.brand .sub { color: var(--dim); font-size: 11.5px; letter-spacing: 0.04em; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.phase-SUBMIT  { border-color: #2b4a78; color: var(--accent); }
.chip.phase-RESOLVE { border-color: #6b4a1f; color: var(--warn); }
.chip.phase-DONE    { border-color: #4a2040; color: var(--bad); }

.timer { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.spacer { flex: 1 1 auto; }

button.ghost {
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 12px; font: inherit; font-size: 12px; cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: #33456d; }
button.ghost[aria-pressed="true"] { color: var(--ink); background: var(--accent); border-color: var(--accent); }
button.ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- scène */

#stage { grid-area: stage; position: relative; background: var(--ink); min-width: 0; }
#board { display: block; width: 100%; height: 100%; }

.stage-note {
  position: absolute; left: 14px; bottom: 12px;
  font-size: 11.5px; color: var(--dim);
  background: rgba(7, 10, 18, 0.82);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; max-width: 60%;
}
.stage-note code { font-family: var(--mono); color: var(--accent); }

/* ---------------------------------------------------------------- panneau */

aside { grid-area: side; background: var(--panel); overflow-y: auto; padding: 12px; min-width: 0; }

h2 {
  margin: 0 0 8px; font-size: 11px; font-weight: 650;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
}
section + section { margin-top: 18px; }

.agent-row {
  display: grid; grid-template-columns: 10px 1fr auto;
  gap: 9px; align-items: center;
  padding: 7px 8px; border-radius: 8px; background: var(--panel-2);
  margin-bottom: 5px;
}
.agent-row .dot { width: 10px; height: 10px; border-radius: 50%; }
.agent-row .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-row .nm small { display: block; color: var(--dim); font-size: 10.5px; }
.agent-row .sc { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.agent-row.resting { opacity: 0.55; }

.shot {
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 7px; background: var(--panel-2);
}
.shot .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.shot .who { font-size: 12px; font-weight: 600; }
.shot .verdict { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.v-HIT { color: var(--good); }
.v-MISS { color: var(--dim); }
.v-BLOCKED { color: var(--warn); }
.v-OUT_OF_BOUNDS { color: var(--warn); }
.v-INVALID, .v-VIOLATION, .v-TIMEOUT { color: var(--bad); }

.shot .eq {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  margin: 5px 0 4px; word-break: break-all; line-height: 1.35;
}
.shot .meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums;
}
.shot .meta b { color: var(--text); font-weight: 600; }
.shot details { margin-top: 6px; }
.shot summary { font-size: 11px; color: var(--dim); cursor: pointer; }
.shot .reason {
  font-size: 11.5px; color: var(--dim); margin-top: 5px;
  white-space: pre-wrap; word-break: break-word;
  border-left: 2px solid var(--line); padding-left: 8px;
}
.empty { color: var(--dim); font-size: 12px; font-style: italic; }

/* ---------------------------------------------------------------- pied */

footer {
  grid-area: foot; background: var(--panel);
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; flex-wrap: wrap;
}
footer .lbl { font-size: 11px; color: var(--dim); letter-spacing: 0.1em; text-transform: uppercase; }
#scrub { flex: 1 1 260px; accent-color: var(--accent); min-width: 160px; }
#rateChart { height: 34px; width: 210px; }
.seqbox { font-family: var(--mono); font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

@media (max-width: 880px) {
  body { overflow: auto; }
  #app { grid-template-columns: 1fr; grid-template-areas: "head" "stage" "side" "foot"; height: auto; }
  #stage { height: 56vh; }
  aside { max-height: none; }
}

/* ------------------------------------------------- bandeau d'équation de tir */

.speed { font-size: 11px; color: var(--dim); letter-spacing: 0.1em; text-transform: uppercase; }
select.ghost { padding: 5px 8px; }

.eqbar {
  position: absolute; left: 14px; right: 14px; top: 12px;
  background: rgba(9, 13, 24, 0.93);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 9px 13px;
  display: grid; gap: 4px;
  backdrop-filter: blur(3px);
}
.eqbar-who { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.eqbar-who .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.eqbar-line { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.eqbar-lbl {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim); flex: 0 0 44px;
}
.eqbar code {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  word-break: break-word; line-height: 1.4;
}
.eqbar code .w { color: #b892ff; font-weight: 500; }
.eqbar-sub {
  font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums;
  justify-content: space-between;
}

.legend {
  position: absolute; right: 14px; bottom: 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(9, 13, 24, 0.86);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 11px; color: var(--dim);
}
.legend span { display: flex; align-items: center; gap: 7px; }
.sw { width: 20px; height: 0; border-top-width: 2px; display: inline-block; }
.sw-plan { border-top-style: dashed; border-top-color: #7e8aa6; }
.sw-real { border-top-style: solid; border-top-color: var(--accent); }

@media (max-width: 880px) {
  .eqbar { position: static; margin: 10px 10px 0; }
  .legend { position: static; margin: 10px; }
}

.shot .eq.eff { color: var(--dim); font-size: 11px; margin-top: -2px; }
.shot .eq.eff .w { color: #b892ff; }
.fieldnote {
  margin-top: 8px; padding: 7px 9px; font-size: 11px; line-height: 1.5;
  color: var(--dim); border-left: 2px solid #b892ff; background: rgba(184, 146, 255, 0.06);
  border-radius: 0 6px 6px 0;
}

h2 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); font-size: 10.5px; }
.agent-row { cursor: pointer; border: 1px solid transparent; }
.agent-row:hover { border-color: #33456d; }
.agent-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.agent-row.focused { border-color: var(--accent); background: #16213a; }

.agent-row .nm small.method {
  color: var(--faint); font-size: 10.5px; line-height: 1.35;
  white-space: normal; margin-bottom: 2px;
}
.agent-row .nm { white-space: normal; }
.eqbar-method { font-size: 11px; color: var(--faint); margin-top: -2px; }

a.ghost.link { text-decoration: none; display: inline-block; }

.v-REFUSAL, .v-TRUNCATED { color: #b892ff; }
.v-NO_EQUATION { color: var(--faint); }
