/* ── The HUD frame ───────────────────────────────────────────────────────── */

#hud {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 440px;
  grid-template-rows: 46px minmax(0, 1fr);
  grid-template-areas: 'top top top' 'left centre right';
  height: 100vh;
}

/* Top rail --------------------------------------------------------------- */

#hud-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--rule);
}
#wordmark {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.42em;
  color: var(--phosphor);
}
#statuses { display: flex; gap: 22px; align-items: center; }
#statuses > span { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }
#statuses > span b { font-weight: 500; color: var(--text-quiet); margin-left: 6px; }
#statuses > span.ok b  { color: var(--ok); }
#statuses > span.bad b { color: var(--alert); }
#status-clock { color: var(--text-quiet) !important; font-variant-numeric: tabular-nums; }

/* Activity trace --------------------------------------------------------- */

#hud-left {
  grid-area: left;
  border-right: 1px solid var(--rule);
  padding: var(--pad);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#activity-head { display: flex; justify-content: space-between; align-items: baseline; }
#activity-list { list-style: none; margin: 14px 0 0; padding: 0; }

.act {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 8px;
  font-size: 10px;
  line-height: 1.55;
  padding: 5px 0 5px 11px;
  border-left: 1px solid var(--rule-strong);
  color: var(--text-quiet);
  word-break: break-word;
  animation: trace-in .3s var(--ease);
}
@keyframes trace-in { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: none; } }
.act .t { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.act.ok   { border-left-color: var(--ok); }
.act.ok   .m { color: var(--text); }
.act.warn { border-left-color: var(--amber); color: var(--amber); }
.act.err  { border-left-color: var(--alert); color: var(--alert); }
.act.idle { border-left-color: var(--rule); color: var(--text-faint); }

/* The pinned foot of the rail: what is happening right now, overwritten in place
   rather than accumulating a line per interim transcript. */
.act.live {
  border-left-color: var(--arc);
  color: var(--text-dim);
  position: sticky;
  bottom: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--arc) 9%, transparent), transparent 70%);
}
.act.live .m::after {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 7px;
  vertical-align: middle;
  background: var(--arc);
  animation: act-pulse 1.6s ease-in-out infinite;
}
@keyframes act-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .act.live .m::after { animation: none; opacity: .7; }
}

/* Repeats collapse into a count instead of filling the rail with duplicates. */
.act .x {
  grid-column: 2;
  justify-self: start;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--text-faint);
  border: 1px solid var(--rule);
  padding: 0 4px;
}

/* Reactor ---------------------------------------------------------------- */

#hud-centre {
  grid-area: centre;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: var(--pad);
  min-width: 0;
}
#orb { width: min(330px, 38vh); height: min(330px, 38vh); display: block; }

#orb-state {
  font-size: 9.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-faint);
  transition: color .3s var(--ease);
}
#orb-state.listening { color: var(--phosphor); }
#orb-state.thinking  { color: var(--amber); }
#orb-state.speaking  { color: var(--ok); }

#orb-hint { margin: -6px 0 0; font-size: 9.5px; letter-spacing: .18em; color: var(--text-faint); }

/* The caption is the only humane typographic moment in the interface. */
#caption {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.65;
  letter-spacing: -0.005em;
  text-align: center;
  max-width: 46ch;
  min-height: 3.3em;
  color: var(--text-faint);
  margin: 0;
}
#caption b { font-weight: 400; color: var(--text); }

/* Panels ----------------------------------------------------------------- */

#hud-right {
  grid-area: right;
  border-left: 1px solid var(--rule);
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
  min-height: 0;
}

@media (max-width: 1180px) {
  #hud {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 46px auto minmax(0, 1fr) 150px;
    grid-template-areas: 'top' 'centre' 'right' 'left';
  }
  #hud-left  { border-right: none; border-top: 1px solid var(--rule); }
  #hud-right { border-left: none; }
  #orb { width: 190px; height: 190px; }
  #statuses { gap: 12px; }
}
