/* ===================== NETWORK v3 =====================
   Fleet readout (hero), demo switcher (run), proof ledger,
   AIOS cockpit. Extends run.css; shares variables.css tokens. */

/* ---------- Fleet readout (hero) ---------- */
.fleet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  font-family: var(--font-mono);
}
.fleet-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-right: 0.4rem;
}
.fleet-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.35s, color 0.35s;
}
.fleet-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.35s;
}
.fleet-chip.is-ok .fleet-dot { background: var(--success); }
.fleet-chip.is-busy {
  border-color: var(--accent-dim);
  color: var(--text);
}
.fleet-chip.is-busy .fleet-dot {
  background: var(--accent);
  animation: fleetPulse 1.1s infinite;
}
@keyframes fleetPulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  70% { box-shadow: 0 0 0 5px rgba(212, 160, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 160, 82, 0); }
}

/* ---------- Demo switcher (run intro) ---------- */
.demo-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.9rem;
  font-family: var(--font-mono);
}
.demo-switch-cmd {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-right: 0.2rem;
}
.demo-tab {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.demo-tab:hover {
  color: var(--text);
  border-color: var(--border-hover);
}
.demo-tab.is-active {
  color: var(--accent-bright);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}
.demo-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Content swap entrance */
.swap-fade { animation: swapIn 0.45s var(--ease-out) both; }
@keyframes swapIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Proof ledger (anonymized systems) ---------- */
.sys-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.1rem;
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--border);
}
.sys-row:last-child { border-bottom: none; }
.sys-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  padding-top: 0.2rem;
}
.sys-client { font-weight: 600; font-size: 0.95rem; }
.sys-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 300;
  margin-top: 0.25rem;
}
.sys-metric {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}
.sys-row.is-struck .result-before::after { transform: scaleX(1); }

/* ---------- Proof ledger: rolling viewport ---------- */
.sys-viewport {
  --sys-rows: 3;
  --sys-row-h: 8.1rem;
  position: relative;
  height: calc(var(--sys-row-h) * var(--sys-rows) + 0.8rem);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 95%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 95%, transparent 100%);
}
.sys-track { display: block; will-change: transform; }
/* Rows keep their natural height (min-height only) so wrapped content
   never overlaps the next row. The ticker translates by each row's real
   measured height, so variable heights stay seamless. */
.sys-viewport .sys-row {
  min-height: var(--sys-row-h);
  box-sizing: border-box;
  padding: 0.7rem 0;
  align-content: center;
}
.sys-viewport .sys-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Keep each metric on one line so every row is a uniform height
   (a wrapped metric was the only thing making rows differ). */
.sys-viewport .sys-metric {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- AIOS cockpit ---------- */
.cockpit-section {
  padding: var(--section-padding);
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: clamp(2.5rem, 5vw, 4.5rem);
  align-items: center;
}
.cockpit-copy .section-desc { margin-bottom: 1.75rem; }

.cockpit {
  background: linear-gradient(180deg, #1c1c1f 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  position: relative;
  font-family: var(--font-mono);
}
.cockpit::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 35%, var(--accent-bright) 50%, var(--accent) 65%, transparent);
  opacity: 0.7;
  z-index: 1;
}
.cockpit-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.65rem;
}
.cockpit-bar-title { color: var(--text-dim); }
.cockpit-bar-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--success);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.cockpit-bar-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: consolePulse 2.4s infinite;
}
.cockpit-body {
  display: grid;
  grid-template-columns: 168px 1fr;
  min-height: 300px;
}
.cockpit-rail {
  border-right: 1px solid var(--border);
  padding: 0.9rem 0;
}
.cockpit-rail-head {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 1rem 0.5rem;
}
.cockpit-agent {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: color 0.35s, background 0.35s;
}
.cockpit-agent .fleet-dot { flex: none; }
.cockpit-agent.is-ok .fleet-dot { background: var(--success); }
.cockpit-agent.is-busy {
  color: var(--text);
  background: var(--accent-soft);
}
.cockpit-agent.is-busy .fleet-dot {
  background: var(--accent);
  animation: fleetPulse 1.1s infinite;
}
.cockpit-main {
  display: flex;
  flex-direction: column;
}
.cockpit-feed {
  flex: 1;
  padding: 1rem 1.2rem;
  font-size: 0.7rem;
  line-height: 2.05;
  overflow: hidden;
}
.feed-line { display: block; }
.feed-line .f-time { color: var(--text-dim); margin-right: 0.6rem; }
.feed-line .f-agent { color: var(--info); margin-right: 0.5rem; }
.feed-line .f-msg { color: var(--text-muted); }
.feed-line.is-escalation .f-agent { color: var(--accent); }
.feed-line.is-escalation .f-msg { color: var(--text); }
.feed-line.is-new { animation: swapIn 0.4s var(--ease-out) both; }
.cockpit-stats {
  display: flex;
  border-top: 1px solid var(--border);
}
.cockpit-stat {
  flex: 1;
  padding: 0.8rem 1.2rem;
  border-right: 1px solid var(--border);
}
.cockpit-stat:last-child { border-right: none; }
.cockpit-stat-value {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}
.cockpit-stat-value.is-live { color: var(--success); }
.cockpit-stat-label {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* ---------- The Meter (embedded waste calculator) ---------- */
.meter-section {
  padding: var(--section-padding);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: clamp(2.5rem, 5vw, 4.5rem);
  align-items: center;
}
.meter-section .section-title em { font-style: italic; color: var(--accent); }
.meter-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.meter-note b { color: var(--success); font-weight: 500; }
.meter {
  background: linear-gradient(180deg, rgba(212, 160, 82, 0.05), transparent 30%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  position: relative;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4);
}
.meter::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent-bright) 50%, var(--accent) 70%, transparent);
}
.meter-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.6rem;
}
.meter-head .live { color: var(--success); }
.meter-readout { border-bottom: 1px solid var(--border); padding-bottom: 1.4rem; }
.meter-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 300; }
.meter-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: clamp(2.6rem, 5vw, 4rem);
  line-height: 1.05;
  color: var(--accent);
  letter-spacing: -0.03em;
  margin-top: 0.35rem;
}
.meter-value small { font-size: 0.34em; color: var(--text-dim); font-weight: 400; letter-spacing: 0; margin-left: 0.4rem; }
.meter-second { margin-top: 0.8rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.meter-second b { color: var(--success); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-second span { color: var(--text-dim); }
.meter-faders { margin-top: 1.6rem; display: grid; gap: 1.25rem; }
.meter-fader label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}
.meter-fader output {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}
.meter input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
.meter input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--border) var(--fill, 50%));
}
.meter input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 26px;
  margin-top: -12px;
  background: var(--text);
  border: none;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--bg), 0 4px 14px rgba(0, 0, 0, 0.55);
}
.meter input[type="range"]::-moz-range-track { height: 2px; background: var(--border); }
.meter input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
.meter input[type="range"]::-moz-range-thumb {
  width: 14px; height: 26px;
  background: var(--text);
  border: none; border-radius: 2px;
}
.meter-cta { margin-top: 1.9rem; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.meter-fine { font-size: 0.76rem; color: var(--text-dim); max-width: 26ch; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cockpit-section { grid-template-columns: 1fr; gap: 2.25rem; }
  .meter-section { grid-template-columns: 1fr; gap: 2rem; }
}
@media (max-width: 600px) {
  .fleet { gap: 0.4rem; }
  .fleet-chip { padding: 0.26rem 0.6rem; font-size: 0.64rem; }
  .demo-switch-cmd { flex-basis: 100%; }
  .sys-row { grid-template-columns: 1fr; gap: 0.35rem; }
  .sys-id { padding-top: 0; }
  .sys-viewport { --sys-row-h: 9rem; }
  /* On phones let the metric wrap (min-height keeps rows from overlapping)
     rather than risk clipping "digits" off the end on narrow screens. */
  .sys-viewport .sys-metric { white-space: normal; }
  .cockpit-body { grid-template-columns: 1fr; min-height: 0; }
  .cockpit-rail {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.4rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.75rem;
  }
  .cockpit-rail-head { flex-basis: 100%; padding: 0 0.25rem 0.35rem; }
  .cockpit-agent { padding: 0.3rem 0.5rem; font-size: 0.66rem; }
  .cockpit-feed { font-size: 0.63rem; }
  .cockpit-stats { flex-wrap: wrap; }
  .cockpit-stat { flex-basis: 50%; }
  .cockpit-stat:nth-child(2) { border-right: none; }
  .cockpit-stat:nth-child(n+3) { border-top: 1px solid var(--border); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .fleet-chip.is-busy .fleet-dot,
  .cockpit-agent.is-busy .fleet-dot,
  .cockpit-bar-live::before { animation: none; }
  .swap-fade, .feed-line.is-new { animation: none; }
}
