/* site/playground/playground.css — the playground's app shell.
 *
 * Self-contained on purpose: this page is an application surface rather than a
 * document, so it does not load the prose site's stylesheet. Nothing here
 * fetches anything — no @import, no url(), no font host. The page test proves
 * that rather than trusting this comment.
 *
 * ---------------------------------------------------------------------------
 * The one hiding rule
 *
 * A screen is hidden as a WHOLE, and nothing finer than a screen is ever
 * hidden. `.screen[data-visible="no"]` is the only `display: none` in this
 * file, and the test file holds that: no rule may hide a disclosure, a model
 * label, a status line or a figure. The sentence a response attaches to a
 * number is on screen whenever that number is, which is the promise that
 * matters; a stage a reader has not reached yet has no numbers and no
 * sentences to hide.
 *
 * ---------------------------------------------------------------------------
 * The viewport
 *
 * The shell is exactly one viewport tall — header, screen, footer — and the
 * page itself never scrolls. Where a response is longer than its pane (the
 * raw JSON, a long location table) the pane scrolls, not the page, so a
 * screen's control and its result are always both in front of the reader.
 */

:root {
  /* the site's v6 tokens (site/styles.css), restated here because this page
   * may load only its own stylesheet — the page test pins that */
  --night: #0a141d;
  --night-2: #101f2b;
  --snow: #eef4f8;
  --sky: #d5eaf3;
  --sky-hover: #e6f3f9;
  --glow: #7fd4f2;
  --ink: #0e1b26;
  --muted: #3d5261;
  --line: #e2e8ec;
  --panel: #ffffff;
  --page: #f2f4f6;
  --accent: #0f6a93;
  --warn: #8a4b12;
  --bad: #8f1f2a;
  --good: #1c5c34;
  --bar-h: 46px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr) auto;
  overflow: hidden;
}

/* --- the bars ----------------------------------------------------------- */

header.bar {
  display: flex;
  align-items: stretch;
  gap: 16px;
  background: var(--night);
  color: var(--snow);
  padding: 0 14px;
}

a.brand { color: var(--snow); text-decoration: none; }
a.brand:hover span { color: var(--glow); }

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand span { color: #7f96a6; }

.env {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-size: 11px;
  color: #7f96a6;
  white-space: nowrap;
}

.env-name {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #dfe3ea;
}

.env a { color: var(--snow); text-decoration: none; }
.env a:hover { color: var(--glow); }

footer.bar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 5px 14px;
  background: var(--night);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: #7f96a6;
}

footer.bar .clause {
  margin: 0;
  color: var(--snow);
}

footer.bar .pg-note {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- the progress header ------------------------------------------------ */

.rail { display: flex; align-items: center; min-width: 0; }

.rail ol {
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 2px;
}

.rail-button {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #7f96a6;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.rail-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 9px;
}

.rail-state {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.rail-stage[data-state="done"] .rail-button { color: var(--glow); }
.rail-stage[data-state="current"] .rail-button {
  color: var(--night);
  background: var(--sky);
  border-color: var(--sky);
}
.rail-stage[data-state="failed"] .rail-button { color: #f0a6a6; }
.rail-stage[data-state="locked"] .rail-button { color: #5b7181; cursor: not-allowed; }
.rail-stage[data-view="yes"] .rail-button { border-color: #4a6577; }

/* --- the screens -------------------------------------------------------- */

main {
  min-height: 0;
  padding: 10px 14px;
}

.screen { display: none; }

.screen[data-visible="yes"] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  height: 100%;
}

.lead {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 600;
}

.panes {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(300px, 30fr) minmax(0, 44fr);
  gap: 10px;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  min-height: 0;
  overflow: auto;
}

/* A card is as tall as what is in it and no taller — an empty half-card is
 * whitespace with a border on it. When a result is taller than the screen the
 * card scrolls inside itself, so the control beside it stays in view. */
.card.grow { flex: 0 1 auto; }

.card h2 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- fields and figures ------------------------------------------------- */

dl.fields {
  display: grid;
  grid-template-columns: minmax(6rem, auto) minmax(0, 1fr);
  gap: 2px 10px;
  margin: 0 0 6px;
  align-items: baseline;
}

dl.fields dt {
  font-size: 11px;
  color: var(--muted);
}

dl.fields dd {
  margin: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

dl.fields.tight dd { font-size: 12px; }

dl.fields dd b { font-variant-numeric: tabular-nums; }

.pg-value { display: block; }

.pg-empty { color: var(--muted); }

.figure-big {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}

.pg-figure { font-size: 14px; margin: 1px 0; font-variant-numeric: tabular-nums; }

.pg-figure-note { font-size: 11px; color: var(--muted); margin: 1px 0 0; }

.pg-caption { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }

.pg-note { font-size: 11px; color: var(--muted); }

/* --- controls ----------------------------------------------------------- */

.controls, .rowbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 6px;
}

.pg-button {
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  padding: 6px 14px;
  border: 1px solid var(--sky);
  border-radius: 999px;
  background: var(--sky);
  color: var(--night);
  cursor: pointer;
}

.pg-button:hover { background: var(--sky-hover); border-color: var(--sky-hover); }

/* A stage that has not succeeded yet cannot be walked to, and the button that
 * would walk there says so rather than failing quietly when pressed. */
.pg-button[disabled] {
  background: #eceef2;
  border-color: var(--line);
  color: #9aa1ad;
  cursor: not-allowed;
}

.pg-button-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.pg-file {
  font-size: 11px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
}

.pg-file input { font-size: 11px; max-width: 150px; }

.pg-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: #f2f3f6;
  border-left: 2px solid var(--line);
  padding: 4px 7px;
  margin: 4px 0 6px;
  overflow-wrap: anywhere;
}

.screen[data-state="failed"] .pg-status,
.card[data-state="failed"] .pg-status { color: var(--bad); border-left-color: var(--bad); }

/* --- the account key ---------------------------------------------------- */

.pg-secret {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px;
  margin: 4px 0;
  background: #fbfcfe;
}

.pg-secret-label {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2px;
}

.pg-secret-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  margin: 0 0 4px;
}

.pg-secret[data-shown="spent"] .pg-secret-value { color: var(--muted); font-style: italic; }

/* A warning attached to a value that is shown once. It stays beside the key
 * rather than moving into a disclosure: it is the consequence of the figure on
 * screen, not an explanation of the platform. */
.pg-warning {
  font-size: 11px;
  line-height: 1.35;
  margin: 0;
  color: var(--warn);
  border-left: 2px solid var(--warn);
  padding-left: 7px;
}

/* --- the ingest job track ----------------------------------------------- */

.pg-track {
  display: flex;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 2px 0 4px;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.pg-track li { color: #adb4c0; }
.pg-track li[data-reached="yes"] { color: var(--good); font-weight: 600; }
.pg-track li[data-reached="failed"] { color: var(--bad); }

/* --- tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 0 6px; }

table.grid {
  border-collapse: collapse;
  width: auto;
  min-width: 60%;
  font-size: 12px;
}

table.grid th, table.grid td {
  text-align: left;
  padding: 3px 8px 3px 0;
  border-bottom: 1px solid #eceef2;
  white-space: nowrap;
}

table.grid th {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid th.num { text-align: right; }
table.grid th, table.grid td { padding-right: 18px; }
table.grid th:last-child, table.grid td:last-child { padding-right: 0; }

/* --- trigger templates -------------------------------------------------- */

.pg-templates { display: grid; gap: 6px; margin: 2px 0 6px; }

.pg-template {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 7px 9px;
}

.pg-template[data-chosen="yes"] { border-color: var(--glow); background: #f0f9fd; }

.pg-template h3 { margin: 0 0 3px; font-size: 13px; }

.pg-template .pg-copy { margin: 0 0 5px; font-size: 11px; color: var(--muted); }

.pg-plain { font-size: 11px; margin: 4px 0 0; padding-left: 15px; color: var(--muted); }

/* --- the backtest chart ------------------------------------------------- */

.pg-chart svg { width: 100%; height: auto; }

.pg-rule { stroke: #e4e7ec; stroke-width: 1; }
.pg-tick { font-size: 9px; fill: var(--muted); }
.pg-bar.paid { fill: var(--bad); }
.pg-bar.zero { fill: #ccd2dc; }

/* --- the price ---------------------------------------------------------- */

.pg-loadings { display: grid; gap: 6px; }

.pg-loading {
  border-top: 2px solid var(--ink);
  padding-top: 4px;
}

.pg-loading h3 {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pg-rationale { font-size: 11px; color: var(--muted); margin: 2px 0 0; }

/* --- attribution -------------------------------------------------------- */

/* SPEC.md §4 P9: the model and version that produced a result travel with the
 * result. Quieter than the figure it labels, never hidden and never smaller
 * than the notes around it — a label a reader cannot find is not a label. */
.pg-model {
  margin: 5px 0 0;
  font-size: 11px;
  color: #3a3f4a;
}

/* --- disclosures -------------------------------------------------------- */

/* Never hidden, never collapsed, never smaller than the copy around it. The
 * text a response attaches to a number travels with that number. */
.disclosure {
  border-left: 2px solid var(--ink);
  padding: 3px 0 3px 8px;
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
}

/* --- on-demand explanation ---------------------------------------------- */

/* Everything the screen does not need to say to be used. One sentence leads a
 * screen; the paragraph a reader may want next is in here. */
details.why { font-size: 11px; }

details.why summary {
  cursor: pointer;
  color: var(--accent);
  padding: 3px 0;
}

details.why p {
  margin: 2px 0 6px;
  color: var(--muted);
  max-width: 70ch;
}

/* --- raw request and response ------------------------------------------- */

.pg-raw { margin: 6px 0 0; }

.pg-raw summary {
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.pg-json, .pg-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.45;
  background: #f2f3f6;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 8px;
  margin: 4px 0 0;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pg-preview { max-height: 130px; margin: 0; }

/* Short viewports and phones: the shell stops pretending to be one screen and
 * scrolls, rather than clipping a result a reader is entitled to. */
@media (max-height: 620px), (max-width: 900px) {
  body { overflow: auto; grid-template-rows: auto auto auto; }
  .screen[data-visible="yes"] { height: auto; }
  .panes { grid-template-columns: minmax(0, 1fr); }
  .card { overflow: visible; }
}
