/* Agent Arcade: local cabinet lineup, static and public-safe. */

:root {
  --desk: #dedbd0;
  --cabinet: #f4f1e8;
  --cabinet-2: #ebe7db;
  --well: #d8d3c5;
  --well-dark: #cfc8b8;
  --ink: #191713;
  --muted: #615e55;
  --quiet: #8a8579;
  --line: #cbc5b7;
  --line-strong: #aaa294;
  --accent: #c45b22;
  --ok: #2b7a4b;
  --busy: #9a6a1b;
  --warn: #a33c2f;
  --paper: #fbfaf5;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family: var(--sans);
  background: var(--desk);
  padding: clamp(0.75rem, 2.4vw, 2rem);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.cabinet {
  width: min(1160px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--cabinet);
  box-shadow: 0 18px 42px -34px rgba(25, 23, 19, 0.72);
  padding: clamp(0.9rem, 2vw, 1.4rem);
}

.cabinet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid var(--ink);
}

.cabinet-title {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2rem, 4.8vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: 0;
  font-weight: 850;
}

.subtitle {
  max-width: 35rem;
  margin-top: 0.38rem;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.3vw, 1rem);
  line-height: 1.32;
}

.cabinet-source {
  display: grid;
  gap: 0.16rem;
  min-width: 9rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--paper);
  padding: 0.62rem 0.78rem;
}

.source-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.cabinet-source strong {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readout {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0.85rem 0 1rem;
  border: 1px solid var(--line-strong);
  background: var(--well);
}

.readout-fact {
  min-width: 0;
  padding: 0.62rem 0.75rem;
  border-right: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.2);
}

.readout-fact:last-child {
  border-right: 0;
}

.readout-fact[data-state="busy"] {
  background: color-mix(in oklab, var(--busy) 10%, var(--well));
}

.readout-fact[data-state="warn"] {
  background: color-mix(in oklab, var(--warn) 10%, var(--well));
}

.fact-label,
.fact-detail {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-value {
  display: block;
  margin: 0.18rem 0 0.12rem;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.98rem, 1.8vw, 1.25rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin: 1rem 0 0.55rem;
}

.section-head h2 {
  font-size: clamp(1.08rem, 1.8vw, 1.35rem);
  font-weight: 780;
  line-height: 1.1;
}

.section-head span {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.72rem;
}

.agent-unit {
  display: grid;
  grid-template-rows: auto minmax(5.2rem, 1fr) auto;
  min-width: 0;
  min-height: 12.6rem;
  border: 1px solid var(--line-strong);
  border-top-width: 5px;
  background: color-mix(in oklab, var(--cabinet) 78%, white);
}

.agent-unit[data-state="ok"] {
  border-top-color: var(--ok);
}

.agent-unit[data-state="busy"] {
  border-top-color: var(--busy);
  background: color-mix(in oklab, var(--busy) 6%, var(--cabinet));
}

.agent-unit[data-state="warn"] {
  border-top-color: var(--warn);
  background: color-mix(in oklab, var(--warn) 6%, var(--cabinet));
}

.agent-unit.is-priority {
  grid-column: span 2;
  min-height: 13.8rem;
}

.unit-name-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  min-height: 4.45rem;
  padding: 0.78rem 0.82rem 0.65rem;
}

.row-index {
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.agent-main {
  min-width: 0;
}

.agent-main h3 {
  overflow-wrap: anywhere;
  font-size: clamp(1.02rem, 1.65vw, 1.22rem);
  font-weight: 820;
  line-height: 1.08;
}

.is-priority .agent-main h3 {
  font-size: clamp(1.28rem, 2.4vw, 1.7rem);
}

.agent-main p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 520;
  line-height: 1.25;
}

.signal-well {
  margin: 0 0.72rem;
  border: 1px solid color-mix(in oklab, var(--line-strong) 76%, var(--ink));
  background: var(--well-dark);
  padding: 0.72rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 540;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.signal-well span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.is-priority .signal-well {
  min-height: 5.9rem;
  font-size: 0.96rem;
}

.unit-base {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  min-height: 2.8rem;
  margin-top: 0.72rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.22);
  padding: 0.62rem 0.82rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
}

.unit-base span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-word {
  color: var(--ink);
  font-weight: 760;
}

.routines {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.42fr);
  border: 1px solid var(--line-strong);
  background: var(--paper);
}

.routine-group {
  min-width: 0;
  padding: 0.82rem;
}

.routine-group + .routine-group {
  border-left: 1px solid var(--line-strong);
}

.routine-group h3 {
  margin-bottom: 0.55rem;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 780;
  line-height: 1.15;
}

.routine-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(3.8rem, auto) minmax(3.8rem, 0.55fr) minmax(4.8rem, auto);
  gap: 0.55rem;
  align-items: baseline;
  min-height: 2.75rem;
  padding: 0.42rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.routine-row + .routine-row {
  border-top: 1px solid color-mix(in oklab, var(--line) 78%, transparent);
}

.routine-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routine-state {
  min-width: 0;
  overflow: hidden;
  color: var(--ok);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routine-row[data-state="warn"] .routine-state {
  color: var(--warn);
}

.routine-schedule,
.routine-next {
  min-width: 0;
  overflow: hidden;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routine-next {
  color: var(--quiet);
  text-align: right;
}

.routine-empty {
  color: var(--quiet);
  font-size: 0.88rem;
  line-height: 1.35;
}

.story-panel {
  margin-top: 0.4rem;
}

.story {
  display: grid;
  grid-template-columns: minmax(15rem, 0.85fr) repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line-strong);
  background: var(--line-strong);
}

.story-lede,
.cart {
  background: var(--paper);
  padding: clamp(0.85rem, 1.8vw, 1.05rem);
}

.story-lede {
  grid-row: span 2;
}

.story-source {
  color: var(--quiet);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.story-telegram {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.cart {
  min-width: 0;
}

.cart-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.cart-num {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.08rem;
  font-weight: 780;
}

.cart-stamp,
.cart-slot {
  overflow: hidden;
  color: var(--quiet);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-label {
  margin-top: 0.45rem;
  font-size: 1.05rem;
  font-weight: 780;
}

.cart-slot {
  margin-top: 0.1rem;
}

.cart-head {
  margin-top: 0.85rem;
  border-left: 4px solid var(--accent);
  padding-left: 0.65rem;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cart-body {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.cabinet-foot {
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line-strong);
}

.stamp {
  color: var(--quiet);
  font-size: 0.74rem;
  line-height: 1.4;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .readout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .readout-fact:nth-child(3n) {
    border-right: 0;
  }

  .readout-fact:nth-child(n + 4) {
    border-top: 1px solid var(--line-strong);
  }

  .fleet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .routines {
    grid-template-columns: 1fr;
  }

  .routine-group + .routine-group {
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .story {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-lede {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  body {
    padding: 0.55rem;
  }

  .cabinet {
    border-radius: 10px;
    padding: 0.75rem;
  }

  .cabinet-head {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.75rem;
  }

  .cabinet-source {
    width: 100%;
  }

  .readout {
    grid-template-columns: 1fr 1fr;
  }

  .readout-fact,
  .readout-fact:nth-child(3n) {
    border-right: 1px solid var(--line-strong);
  }

  .readout-fact:nth-child(2n) {
    border-right: 0;
  }

  .readout-fact:nth-child(n + 3) {
    border-top: 1px solid var(--line-strong);
  }

  .readout-fact:last-child {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 0.18rem;
  }

  .fleet-grid {
    grid-template-columns: 1fr;
  }

  .agent-unit,
  .agent-unit.is-priority {
    grid-column: auto;
    min-height: 12rem;
  }

  .unit-name-row {
    min-height: 4rem;
  }

  .signal-well {
    min-height: 4.6rem;
  }

  .routine-group {
    padding: 0.72rem;
  }

  .routine-row {
    grid-template-columns: minmax(0, 1fr) minmax(4.5rem, auto);
    gap: 0.25rem 0.65rem;
    min-height: 3.1rem;
    padding: 0.58rem 0;
  }

  .routine-name {
    grid-column: 1;
    white-space: normal;
  }

  .routine-state {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  .routine-schedule {
    grid-column: 1;
  }

  .routine-next {
    grid-column: 2;
    text-align: right;
  }

  .story {
    grid-template-columns: 1fr;
  }

  .story-lede {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .readout {
    margin-bottom: 0.85rem;
  }

  .readout-fact {
    padding: 0.52rem 0.58rem;
  }

  .fact-label,
  .fact-detail {
    font-size: 0.68rem;
  }

  .fact-value {
    font-size: 0.94rem;
  }

  .unit-name-row,
  .unit-base {
    padding-right: 0.7rem;
    padding-left: 0.7rem;
  }

  .signal-well {
    margin-right: 0.62rem;
    margin-left: 0.62rem;
  }
}
