/* The viewer page: the park on the left, the side panel on the right (below it on narrow screens). */

/* Self-hosted faces from the read-only dashboard build (agents/dashboard/fonts, served under dashboard/fonts/). */
@font-face { font-family: "Chakra Petch"; font-weight: 400; font-display: swap; src: url("dashboard/fonts/ChakraPetch-400.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 500; font-display: swap; src: url("dashboard/fonts/ChakraPetch-500.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-display: swap; src: url("dashboard/fonts/ChakraPetch-600.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("dashboard/fonts/JetBrainsMono-400.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600; font-display: swap; src: url("dashboard/fonts/JetBrainsMono-600.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #15171c;
  --panel: #1b1e24;
  --panel-2: #21252c;
  --raised: rgba(27, 30, 36, 0.94);
  --line: #2c313a;
  --line-2: #3b414c;
  --text: #e6e3dc;
  --muted: #9b998f;
  --faint: #6f7178;
  --accent: #e0b04a;
  --accent-wash: rgba(224, 176, 74, 0.12);
  --bar: #343841;
  --ok: #6cc28a;
  --warn: #e0b04a;
  --danger: #e0715a;
  --pos: #6cc28a;
  --neg: #e0715a;
  --k-say: #7cb7e8;
  --k-gossip: #4fc0c0;
  --k-social: #a99be8;
  --k-goal: #e0b04a;
  --k-ride: #d79a6a;
  --k-money: #6cc28a;
  --k-player: #e58fb5;
  --panel-w: 380px;
  --sans: "Chakra Petch", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font: 500 13px/1.45 var(--sans);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: 100vh;
  height: 100dvh;
}
body.collapsed { grid-template-columns: minmax(0, 1fr) 0; }
body.collapsed #panel { display: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ the park */

#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #000; }
canvas#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; image-rendering: pixelated; }

/* The page's own buttons sit in the side panel's header, off the park: the game opens its windows at the top right. */
#controls { display: flex; gap: 6px; margin-bottom: 8px; }
#controls a, #controls button {
  font-size: 12px; font-weight: 500; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 3px; padding: 2px 9px; text-decoration: none; cursor: pointer; line-height: 18px;
}
#controls #panel-toggle { margin-left: auto; }
#controls a:hover, #controls button:hover { border-color: var(--accent); }
#controls button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
#controls button:disabled { opacity: 0.5; cursor: default; }

/* The panel is hidden: one small tab on the park's right edge, halfway down (no toolbar or status bar there). */
#panel-show {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 16px; height: 44px; padding: 0; font-size: 15px; line-height: 1; color: var(--muted);
  background: var(--raised); border: 1px solid var(--line-2); border-right: 0; border-radius: 4px 0 0 4px; cursor: pointer; opacity: 0.75;
}
#panel-show:hover, #panel-show:focus-visible { opacity: 1; color: var(--accent); border-color: var(--accent); outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#card { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; pointer-events: none; }
#card > div { pointer-events: auto; background: var(--raised); border: 1px solid var(--line-2); border-radius: 4px; padding: 18px 22px; width: min(420px, calc(100% - 32px)); }
#card h1 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
#card p { margin: 6px 0; color: var(--muted); }
#card .error { color: var(--danger); }
#bar { height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; margin: 10px 0 6px; }
#bar > div { height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
#card button { margin-top: 10px; padding: 5px 14px; color: var(--bg); background: var(--accent); border: 0; border-radius: 3px; cursor: pointer; font-weight: 600; }

#note { position: absolute; left: 50%; top: 36px; transform: translateX(-50%); z-index: 2; background: var(--raised); border: 1px solid var(--line-2); border-radius: 3px; padding: 3px 10px; font-size: 12px; color: var(--muted); max-width: calc(100% - 32px); }

/* ------------------------------------------------------------------ the panel */

#panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
#resizer { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 4; }
#resizer:hover, #resizer:focus-visible, body.resizing #resizer { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing canvas { pointer-events: none; }

.p-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.p-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.p-title h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.01em; }
.p-title span { font-size: 12px; }
.p-status { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px 1px 7px; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.ok i { background: var(--ok); }
.pill.wait i { background: var(--warn); }
.pill.bad i { background: var(--danger); }

.p-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.tile { background: var(--panel); padding: 7px 10px 8px; min-width: 0; display: flex; flex-direction: column; }
.tile .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .num { font: 600 17px/1.3 var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 11px; color: var(--muted); }

.p-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.p-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 10px 7px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.p-tabs button:hover { color: var(--text); }
.p-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.p-tabs .count { font: 400 11px var(--mono); color: var(--faint); margin-left: 2px; }

.p-body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.p-body > section { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; }
.p-body > section[hidden] { display: none; }
.p-body ::-webkit-scrollbar { width: 8px; }
.p-body ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.unavailable { position: absolute; inset: 0; z-index: 5; background: var(--panel); padding: 28px 22px; color: var(--muted); }
.unavailable[hidden] { display: none; }
.unavailable strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 6px; }
.unavailable p { margin: 0; }

.empty { color: var(--faint); padding: 14px; font-size: 12.5px; }

/* chips */
.chips { display: flex; gap: 4px; padding: 8px 12px; position: sticky; top: 0; background: var(--panel); z-index: 1; border-bottom: 1px solid var(--line); }
.chips button { background: none; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 10px; font-size: 12px; line-height: 20px; color: var(--muted); cursor: pointer; }
.chips button:hover { color: var(--text); }
.chips button[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 8px; padding: 7px 12px 7px 10px; border-bottom: 1px solid var(--line); border-left: 2px solid transparent; }
.feed li.fresh { background: var(--accent-wash); }
.feed .t { font: 400 11px/1.9 var(--mono); color: var(--faint); }
.feed .head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.feed .kind { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.feed .to { color: var(--muted); font-size: 12px; }
.feed .text { color: var(--text); overflow-wrap: anywhere; }
.feed .k-say .text, .feed .k-gossip .text, .feed .k-player .text { color: #f1eee6; }
.feed .k-say .text::before, .feed .k-player .text::before { content: "\201C"; color: var(--faint); }
.feed .k-say .text::after, .feed .k-player .text::after { content: "\201D"; color: var(--faint); }
.k-say { border-left-color: var(--k-say) !important; } .k-say .kind { color: var(--k-say); }
.k-gossip { border-left-color: var(--k-gossip) !important; } .k-gossip .kind { color: var(--k-gossip); }
.k-social { border-left-color: var(--k-social) !important; } .k-social .kind { color: var(--k-social); }
.k-goal { border-left-color: var(--k-goal) !important; } .k-goal .kind { color: var(--k-goal); }
.k-ride { border-left-color: var(--k-ride) !important; } .k-ride .kind { color: var(--k-ride); }
.k-money, .k-pay { border-left-color: var(--k-money) !important; } .k-money .kind, .k-pay .kind { color: var(--k-money); }
.k-player { border-left-color: var(--k-player) !important; } .k-player .kind { color: var(--k-player); }

a.agent { color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; border-bottom: 1px dotted var(--faint); }
a.agent:hover, a.agent:focus-visible { color: var(--accent); border-bottom-color: var(--accent); outline: none; }

/* agent list */
#agent-browse { display: flex; flex-direction: column; }
#agent-browse[hidden], #agent-detail[hidden] { display: none; }
#agent-search { margin: 10px 12px 6px; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px; outline: none; }
#agent-search:focus { border-color: var(--accent); }
.agents { list-style: none; margin: 0; padding: 0 0 8px; }
.agents li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.agents li:hover, .agents li:focus-visible { background: var(--panel-2); outline: none; }
.agents .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agents .nm .tag { font-size: 10px; font-weight: 600; color: var(--k-say); margin-left: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.agents .cash { font: 400 12px var(--mono); color: var(--muted); text-align: right; }
.agents .goal { grid-column: 1 / -1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agents .goal b { color: var(--text); font-weight: 500; }
.mini { display: inline-block; width: 44px; height: 4px; background: var(--bar); border-radius: 2px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.mini > i { display: block; height: 100%; background: var(--ok); }

/* agent detail */
#agent-detail { padding: 0 0 16px; }
.d-top { position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 8px 12px 10px; border-bottom: 1px solid var(--line); }
.d-nav { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.d-nav button, .d-nav a { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 9px; font-size: 12px; cursor: pointer; color: var(--text); text-decoration: none; line-height: 20px; }
.d-nav button:hover:not(:disabled), .d-nav a:hover { border-color: var(--accent); }
.d-nav button:disabled { opacity: 0.45; cursor: not-allowed; }
.d-nav .spacer { flex: 1; }
.d-name { margin: 0; font-size: 17px; font-weight: 600; }
.d-sub { color: var(--muted); font-size: 12px; }
.d-sec { padding: 10px 12px 4px; }
.d-sec h3 { margin: 0 0 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.d-sec p { margin: 0 0 6px; }
.d-goal { color: var(--accent); font-weight: 600; }
.d-plan { margin: 4px 0 0; padding-left: 18px; color: var(--text); }
.d-plan li { margin: 1px 0; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr) 34px; gap: 3px 8px; align-items: center; font-size: 12px; }
.kv .v { font: 400 11px var(--mono); color: var(--muted); text-align: right; }
.bar { height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--danger); }
.trust { position: relative; height: 6px; background: var(--bar); border-radius: 3px; }
.trust::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line-2); }
.trust > i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.list li { padding: 2px 0; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.convo { border-left: 2px solid var(--line-2); padding: 2px 0 2px 8px; margin: 0 0 8px; font-size: 12.5px; }
.convo .c-head { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.convo .ln { margin: 2px 0; }
.convo .ln b { font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.timeline li { display: grid; grid-template-columns: 36px 48px minmax(0, 1fr); gap: 6px; padding: 2px 0; border-left: 0 !important; }
.timeline .t { font: 400 11px/1.7 var(--mono); color: var(--faint); }
.timeline .kind { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.9; }

/* economy */
.econ { padding: 10px 12px; }
.econ h3 { margin: 6px 0 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.econ .backend { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.econ .backend b { color: var(--text); font-weight: 600; }
table.tx { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
table.tx th { text-align: left; font-weight: 600; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 4px; border-bottom: 1px solid var(--line-2); }
table.tx td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; overflow: hidden; text-overflow: ellipsis; }
table.tx td.amt, table.tx th.amt { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.tx td.what { color: var(--muted); }
table.tx td.what b { color: var(--text); font-weight: 600; }
.st { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.st.settled { color: var(--ok); }
.st.queued, .st.pending, .st.submitted { color: var(--warn); }
.st.failed, .st.rejected { color: var(--danger); }
svg.spark { display: block; width: 100%; height: 44px; margin: 2px 0 10px; }
svg.spark .ln { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
svg.spark .ar { fill: var(--accent-wash); stroke: none; }
svg.spark .base { stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ------------------------------------------------------------------ narrow screens: the panel goes below the park */

@media (max-width: 820px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56vh minmax(0, 1fr); grid-template-rows: 56dvh minmax(0, 1fr); }
  body.collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 0; }
  #panel { border-left: 0; border-top: 1px solid var(--line); }
  #resizer { display: none; }
  .p-head { padding: 8px 12px 6px; }
  .tile { padding: 5px 8px 6px; }
  .tile .num { font-size: 15px; }
}
