/* =============================================================================
   webapp/public/styles.css — dark, projector-readable, conference-grade theme.

   Goals (CONTRACT.md §5):
     - Big fonts and high contrast so the back row of the room can read the
       counters from a projector.
     - Responsive: collapses cleanly to a single column on an attendee's phone.
     - Designed to sit in a split window beside Grafana (no wasted chrome).
     - Zero external fonts/CSS — system font stack only, fully offline.
   ============================================================================= */

:root {
  /* NVIDIA-adjacent green accent + a cool slate dark base. */
  --bg: #0a0e14;
  --bg-elev: #121823;
  --bg-elev-2: #1a2230;
  --border: #232c3b;
  --fg: #e8edf4;
  --fg-dim: #8a97a8;
  --accent: #76b900;       /* NVIDIA green */
  --accent-2: #00c2ff;
  --good: #2ecc71;
  --warn: #ffb020;
  --bad: #ff4d4f;
  --phase1: #ff8a3d;       /* orange  — stock vLLM, stranded GPUs */
  --phase2: #76b900;       /* green   — Dynamo, all GPUs lit */
  --phase3: #00c2ff;       /* cyan    — tuned */
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #14202e 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

body {
  padding: clamp(12px, 2vw, 28px);
  padding-bottom: 48px;
}

/* ---- Connection status pill -------------------------------------------- */
.conn {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 50;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  user-select: none;
}
.conn--up   { color: var(--good); border-color: rgba(46, 204, 113, 0.4); }
.conn--down { color: var(--bad);  border-color: rgba(255, 77, 79, 0.4); }

/* ---- Top bar: brand + phase badge -------------------------------------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(14px, 2vw, 24px);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand__spark { display: none; }
.brand__title {
  font-size: clamp(20px, 2.6vw, 34px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.brand__sub {
  font-size: clamp(12px, 1.3vw, 16px);
  color: var(--fg-dim);
}

/* The big phase badge — the most important element on the projector. */
.phase {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  min-width: 260px;
  transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}
.phase__num {
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
}
.phase__num span { font-variant-numeric: tabular-nums; }
.phase__label {
  font-size: clamp(12px, 1.4vw, 17px);
  font-weight: 600;
  color: var(--fg-dim);
}
.phase--1 {
  border-color: var(--phase1);
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.16), transparent);
  box-shadow: 0 0 24px rgba(255, 138, 61, 0.25);
}
.phase--1 .phase__num { color: var(--phase1); }
.phase--2 {
  border-color: var(--phase2);
  background: linear-gradient(180deg, rgba(118, 185, 0, 0.16), transparent);
  box-shadow: 0 0 24px rgba(118, 185, 0, 0.28);
}
.phase--2 .phase__num { color: var(--phase2); }
.phase--3 {
  border-color: var(--phase3);
  background: linear-gradient(180deg, rgba(0, 194, 255, 0.16), transparent);
  box-shadow: 0 0 24px rgba(0, 194, 255, 0.28);
}
.phase--3 .phase__num { color: var(--phase3); }
/* Phase 0 = "between phases" swap window (load paused). Amber, distinct. */
.phase--0 {
  border-color: var(--warn);
  background: linear-gradient(180deg, rgba(255, 176, 32, 0.16), transparent);
  box-shadow: 0 0 24px rgba(255, 176, 32, 0.25);
}
.phase--0 .phase__num { color: var(--warn); }

/* ---- Counter grid ------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 18px);
  margin-bottom: clamp(16px, 2vw, 26px);
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(12px, 1.6vw, 22px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.card--hero { background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev)); }
.card__label {
  font-size: clamp(12px, 1.2vw, 15px);
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.card__value {
  font-size: clamp(34px, 5.5vw, 76px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.card__value--sm { font-size: clamp(26px, 3.6vw, 50px); }
.card__value .unit { font-size: 0.5em; color: var(--fg-dim); margin-left: 2px; }
.card__hint {
  font-size: clamp(11px, 1.1vw, 14px);
  color: var(--fg-dim);
}
.card--good .card__value { color: var(--good); }
.card--warn .card__value { color: var(--warn); }
.card .ok   { color: var(--good); }
.card .bad  { color: var(--bad); }
.card .slash { color: var(--fg-dim); margin: 0 4px; }
/* Unavailable state for engine metrics when endpoint is unreachable */
.card__value.unavailable { color: var(--fg-dim); opacity: 0.5; }

/* ---- Panels (attendee + presenter) ------------------------------------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 1.8vw, 22px);
  box-shadow: var(--shadow);
  margin-bottom: clamp(14px, 1.8vw, 20px);
}
.panel__title {
  margin: 0 0 6px;
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 800;
}
.panel__sub {
  margin: 0 0 14px;
  color: var(--fg-dim);
  font-size: clamp(12px, 1.2vw, 15px);
  max-width: 70ch;
}

/* Attendee submit form */
.submit {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.submit__input {
  flex: 1;
  min-width: 0;
  resize: vertical;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: clamp(14px, 1.4vw, 17px);
  font-family: var(--font);
  line-height: 1.4;
}
.submit__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(118, 185, 0, 0.18);
}
.submit__msg {
  margin-top: 10px;
  font-size: 14px;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.submit__msg.is-visible { opacity: 1; }
.submit__msg--ok   { color: var(--good); }
.submit__msg--warn { color: var(--warn); }
.submit__msg--info { color: var(--accent-2); }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(14px, 1.4vw, 16px);
  padding: 12px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--fg-dim); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0e14;
}
.btn--primary:hover { filter: brightness(1.08); }

.btn--toggle { background: var(--bg-elev-2); }
.btn--toggle-on {
  background: var(--bad);
  border-color: var(--bad);
  color: #0a0e14;
}

.btn--phase { min-width: 96px; }
.btn--phase:hover { border-color: var(--accent-2); }

/* ---- Presenter panel internals ----------------------------------------- */
.panel--presenter > summary {
  cursor: pointer;
  list-style: none;
}
.panel--presenter > summary::-webkit-details-marker { display: none; }
.panel--presenter > summary::before {
  content: '▸ ';
  color: var(--fg-dim);
}
.panel--presenter[open] > summary::before { content: '▾ '; }

.presenter__row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  margin-top: 14px;
}
.presenter__group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.presenter__group--grow { flex: 1; min-width: 240px; }
.presenter__label {
  font-size: 14px;
  color: var(--fg-dim);
  font-weight: 600;
  white-space: nowrap;
}
.presenter__label strong {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.presenter__state {
  font-size: 14px;
  color: var(--fg-dim);
  font-weight: 700;
}
.presenter__state.is-on { color: var(--good); }

.slider {
  flex: 1;
  min-width: 160px;
  accent-color: var(--accent);
  height: 6px;
}

.presenter__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-dim);
}
.presenter__meta code {
  font-family: var(--mono);
  color: var(--fg);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ---- Footer ------------------------------------------------------------- */
.footer {
  margin-top: 20px;
  font-size: clamp(11px, 1.1vw, 13px);
  color: var(--fg-dim);
  text-align: center;
  max-width: 90ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ---- Responsive breakpoints -------------------------------------------- */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .phase { min-width: 0; width: 100%; align-items: flex-start; }
  .topbar { gap: 12px; }
  .submit { flex-direction: column; }
  .submit__btn { width: 100%; }
  .card__value { font-size: clamp(28px, 12vw, 56px); }
}

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