/*
 * VibeGate console — layout.
 *
 * Mobile-first in the literal sense: the base stylesheet IS the 390px layout,
 * and the wider breakpoints only change how many columns the same DOM flows
 * into. Nothing is hidden on small screens and re-shown on large ones, because
 * that is how a "responsive" page ends up with two behaviours to maintain and
 * one of them untested.
 */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Nothing may push the page sideways. */
html, body { max-width: 100%; overflow-x: hidden; }

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--gap) var(--gap) var(--gap-xl);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---- header ---------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: var(--step-1);
  letter-spacing: -0.01em;
  margin-right: auto;
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
}

.brand small {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  font-weight: 400;
}

/* Theme switch and install sit together, as one control cluster. */
.controls { display: flex; align-items: center; gap: var(--gap-xs); }

.btn {
  font: inherit;
  font-size: var(--step--1);
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { color: var(--text); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[hidden] { display: none !important; }

.btn-go     { color: #05140c; background: var(--go);   border-color: var(--go); font-weight: 600; }
.btn-stop   { color: var(--stop); border-color: var(--stop); }

/* ---- live / stale banner --------------------------------------------------- */

.stream {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.stream[data-state="live"]    { color: var(--go); border-color: color-mix(in oklab, var(--go) 40%, var(--border)); }
.stream[data-state="live"] .dot { background: var(--go); animation: pulse 2s ease-in-out infinite; }
.stream[data-state="polling"] { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, var(--border)); }
.stream[data-state="polling"] .dot { background: var(--warn); }
.stream[data-state="down"]    { color: var(--stop); border-color: color-mix(in oklab, var(--stop) 40%, var(--border)); }
.stream[data-state="down"] .dot { background: var(--stop); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none !important; } }

/* ---- panels ---------------------------------------------------------------- */

.grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  min-width: 0;
}

.panel > header {
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
  justify-content: space-between;
}

.panel h2 {
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}

.panel .note { font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); }

/* ---- pipeline: the green bars ---------------------------------------------- */

.stages { display: flex; flex-direction: column; gap: 10px; }

.stage { display: grid; grid-template-columns: 1.6rem 1fr auto; align-items: center; gap: var(--gap-sm); }

.stage .n {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  text-align: right;
}

.stage .label { font-size: var(--step--1); color: var(--text-dim); min-width: 0; }
.stage[data-state="active"] .label { color: var(--text); font-weight: 600; }
.stage[data-state="done"] .label { color: var(--text-dim); }

.stage .pct { font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); font-variant-numeric: tabular-nums; }

.bar {
  grid-column: 2 / -1;
  height: 5px;
  background: var(--go-track);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--go);
  border-radius: inherit;
  /* The "updates over time" motion: the bar slides to its new value. */
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.stage[data-state="pending"] .bar { background: var(--bg-sunken); }
.stage[data-state="active"] .bar > i { background: var(--accent); }

/* ---- spend ------------------------------------------------------------------ */

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

.figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.figure .v {
  font-family: var(--mono);
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.figure .k {
  font-size: var(--step--1);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.figure.free .v { color: var(--free); }
.figure.paid .v { color: var(--paid); }

.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  padding: 1px 5px;
  color: var(--text-faint);
}

.badge[data-meter="exact"]     { color: var(--go); }
.badge[data-meter="estimated"] { color: var(--warn); }

/* ---- connections: pills, path in the tooltip -------------------------------- */

.pills { display: flex; flex-wrap: wrap; gap: var(--gap-xs); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: var(--step--1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  background: var(--bg-sunken);
  color: var(--text-dim);
  /* The path lives in the title attribute, never as its own row. */
  cursor: help;
  max-width: 100%;
  min-width: 0;
}

.pill .dot { width: 6px; height: 6px; }
.pill .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .rem { color: var(--text-faint); font-variant-numeric: tabular-nums; }

.pill[data-state="ok"]      { color: var(--text); border-color: color-mix(in oklab, var(--go) 45%, var(--border)); }
.pill[data-state="ok"] .dot { background: var(--go); }
.pill[data-state="expired"] { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 45%, var(--border)); }
.pill[data-state="expired"] .dot { background: var(--warn); }
.pill[data-state="blocked"], .pill[data-state="missing"] { color: var(--stop); border-color: color-mix(in oklab, var(--stop) 45%, var(--border)); }
.pill[data-state="blocked"] .dot, .pill[data-state="missing"] .dot { background: var(--stop); }
.pill[data-state="unknown"] .dot { background: var(--text-faint); }

/* ---- fleet ------------------------------------------------------------------ */

.fleet { display: flex; flex-direction: column; gap: var(--gap-sm); }

.provider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px var(--gap-sm);
  padding: var(--gap-sm);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  min-width: 0;
}

.provider[data-state="ready"]       { border-left-color: var(--go); }
.provider[data-state="cooling"]     { border-left-color: var(--warn); }
.provider[data-state="spent"]       { border-left-color: var(--stop); }
.provider[data-state="unavailable"] { border-left-color: var(--text-faint); }

.provider .name { font-weight: 600; font-size: var(--step-0); overflow: hidden; text-overflow: ellipsis; }
.provider .state { font-family: var(--mono); font-size: var(--step--1); text-align: right; }
.provider[data-state="ready"]   .state { color: var(--go); }
.provider[data-state="cooling"] .state { color: var(--warn); }
.provider[data-state="spent"]   .state { color: var(--stop); }
.provider .meta { grid-column: 1 / -1; font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); font-variant-numeric: tabular-nums; }

.building {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.building .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }

/* ---- gates ------------------------------------------------------------------ */

.gates { display: flex; flex-direction: column; gap: var(--gap-sm); }

.gate {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-sm);
  background: var(--bg-sunken);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gate[data-state="open"] {
  border-color: var(--accent);
  background: var(--accent-track);
}

.gate .head { display: flex; align-items: baseline; gap: var(--gap-sm); }
.gate .id { font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); }
.gate[data-state="passed"] .id { color: var(--go); }
.gate[data-state="open"] .id { color: var(--accent); }
.gate .title { font-size: var(--step-0); font-weight: 600; }
.gate[data-state="pending"] .title { color: var(--text-dim); font-weight: 400; }
.gate .asks { font-size: var(--step--1); color: var(--text-dim); }

.gate .evidence {
  font-family: var(--mono);
  font-size: var(--step--1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-sm);
  overflow-x: auto;
  white-space: pre;
}

.gate .actions { display: flex; gap: var(--gap-xs); flex-wrap: wrap; }
.gate .actions .btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }

/* ---- halts ------------------------------------------------------------------ */

.halt {
  border: 1px solid var(--stop);
  border-left-width: 3px;
  background: var(--stop-track);
  border-radius: var(--radius);
  padding: var(--gap-sm);
  font-size: var(--step--1);
}

.halt .what { font-weight: 600; color: var(--stop); }

.empty { color: var(--text-faint); font-size: var(--step--1); font-style: italic; }

/* ---- breakpoints: same DOM, more columns ------------------------------------ */

@media (min-width: 700px) {
  .wrap { padding: var(--gap-lg); gap: var(--gap-lg); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-lg); }
  .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}

@media (min-width: 1080px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
  .span-3 { grid-column: span 3; }
}

/* ---- welcome wizard --------------------------------------------------------
 *
 * One step at a time. The list underneath is orientation only — it shows how
 * far along you are without turning the wizard into the wall of forms it
 * exists to avoid.
 */

.wizard { border-color: var(--accent); }

.step { display: flex; flex-direction: column; gap: var(--gap-sm); }

.step-head { display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; }

.step-n {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius);
  padding: 1px 7px;
  font-weight: 600;
}

.step-label { font-size: var(--step-1); font-weight: 600; margin-right: auto; }

.step-why      { margin: 0; color: var(--text); }
.step-without  { margin: 0; color: var(--text-dim); font-size: var(--step--1); }
.step-evidence { margin: 0; font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); }

.step-note {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--warn);
}

.input {
  font: inherit;
  font-family: var(--mono);
  font-size: var(--step-0);
  width: 100%;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 42px;
}

.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input:read-only { color: var(--text-dim); border-style: dashed; }

.step-actions { display: flex; gap: var(--gap-xs); flex-wrap: wrap; }
.step-actions .btn { flex: 1 1 auto; justify-content: center; min-height: 42px; }

.step-list {
  list-style: none;
  margin: 0;
  padding: var(--gap-sm) 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-xs);
}

.step-list li {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.step-list li[data-state="ready"]   { color: var(--go);   border-color: color-mix(in oklab, var(--go) 45%, var(--border)); }
.step-list li[data-state="needed"]  { color: var(--text); border-color: var(--border-strong); }
.step-list li[data-state="skipped"] { opacity: 0.55; }

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

/* ---- inspiration modal ------------------------------------------------------ */

.modal {
  width: min(100%, 880px);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--gap);
}

.modal::backdrop { background: rgb(0 0 0 / 0.68); }

.modal-head { display: flex; align-items: center; gap: var(--gap-sm); }
.modal-head h2 { font-size: var(--step-1); margin-right: auto; }
.modal-sub { margin: 2px 0 var(--gap); color: var(--text-dim); font-size: var(--step--1); }

.panels { display: grid; gap: var(--gap); grid-template-columns: 1fr; }

.source {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-sm);
  background: var(--bg-sunken);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.source header { display: flex; align-items: baseline; gap: var(--gap-sm); }
.source .name { font-weight: 600; }
.source .purpose { font-size: var(--step--1); color: var(--text-dim); margin-left: auto; text-align: right; }

.query { display: flex; align-items: center; gap: 6px; }
.query .input { font-size: var(--step--1); min-height: 34px; padding: 6px 8px; }

.lock {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: var(--radius);
  padding: 1px 5px;
  white-space: nowrap;
  cursor: help;
}

.inherited {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--accent);
}

.source .count { font-family: var(--mono); font-size: var(--step--1); color: var(--text-faint); font-variant-numeric: tabular-nums; }

.drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--gap);
  text-align: center;
  color: var(--text-dim);
  font-size: var(--step--1);
}

.direction { display: flex; flex-direction: column; gap: 4px; margin: var(--gap) 0; }
.direction .k { font-size: var(--step--1); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.direction .k + .input { margin-bottom: var(--gap-sm); }
.hint { margin: 0; font-size: var(--step--1); color: var(--warn); }

.conditions { list-style: none; margin: 0 0 var(--gap); padding: 0; display: flex; flex-direction: column; gap: 4px; }

.conditions li {
  display: flex;
  align-items: baseline;
  gap: var(--gap-sm);
  font-size: var(--step--1);
  font-family: var(--mono);
}

.conditions li::before { content: "✗"; color: var(--stop); }
.conditions li[data-met="true"]::before { content: "✓"; color: var(--go); }
.conditions li[data-met="true"] { color: var(--text-dim); }
.conditions .detail { margin-left: auto; color: var(--text-faint); }

.boundary {
  margin: 0;
  padding-top: var(--gap-sm);
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--text-dim);
  font-style: italic;
}

@media (min-width: 700px) {
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
