/* QED — survey plate. research/feel-spec.md §Craft is the only authority here. */

:root {
  --ground: #0c1e2e;
  --deep: #081622;
  --hair: #e8eef2;
  --ink: #dce6ec;
  --sulphur: #e7d24b;
  --mint: #79d3be;
  --dim: #6c8597;
  --grid: 8px;
  --rule: rgba(232, 238, 242, 0.14);
  --rule-strong: rgba(232, 238, 242, 0.3);
  /* The emoji fallback is for the plate, not for us: the pages we re-typeset
     write headings with pictographs, and without it the reader gets a tofu box
     where the source had a character. */
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, var(--emoji), monospace;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, var(--emoji), sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(
      0deg, transparent 0 calc(var(--grid) - 1px),
      rgba(232, 238, 242, 0.028) calc(var(--grid) - 1px) var(--grid)),
    repeating-linear-gradient(
      90deg, transparent 0 calc(var(--grid) - 1px),
      rgba(232, 238, 242, 0.028) calc(var(--grid) - 1px) var(--grid)),
    radial-gradient(130% 90% at 50% 0%, #10293c 0%, var(--ground) 46%, var(--deep) 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

/* ── plate frame ─────────────────────────────────────────────────────────── */

.sheet {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 56px;
  position: relative;
}

.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  inset: 12px 16px;
  border: 1px solid var(--rule);
  pointer-events: none;
}
.sheet::after { inset: 16px 20px; border-color: rgba(232, 238, 242, 0.06); }

.cross {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
}
.cross::before,
.cross::after {
  content: "";
  position: absolute;
  background: var(--rule-strong);
}
.cross::before { inset: 5px 0 5px 0; height: 1px; }
.cross::after { inset: 0 5px 0 5px; width: 1px; }
.cross.tl { top: 7px; left: 11px; }
.cross.tr { top: 7px; right: 11px; }
.cross.bl { bottom: 7px; left: 11px; }
.cross.br { bottom: 7px; right: 11px; }

/* ── masthead ────────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 4px 14px;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.mark {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-strong);
  color: var(--sulphur);
  font-size: 13px;
  line-height: 1;
}

.wordmark b {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.34em;
  margin-right: -0.34em;
}

.wordmark span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.14em;
}

.readline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-transform: lowercase;
}

.nav {
  display: flex;
  gap: 2px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.nav a {
  padding: 5px 10px;
  text-decoration: none;
  color: var(--dim);
  border: 1px solid transparent;
}
.nav a:hover { color: var(--ink); border-color: var(--rule); }
.nav a[aria-current] { color: var(--ground); background: var(--sulphur); }

/* ── rules and counters ──────────────────────────────────────────────────── */

.rule {
  height: 1px;
  background: var(--rule-strong);
  margin: 0 4px;
  will-change: transform;
}
.rule.thin { background: var(--rule); }

.counters {
  display: grid;
  /* Column-flow rather than a fixed six: a counter that has nothing true to
     report yet is removed from the row, and the rest still fill the width. */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 0 4px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-top: 0;
}

.counter {
  background: linear-gradient(180deg, rgba(232, 238, 242, 0.035), transparent);
  padding: 13px 14px 11px;
}

.counter dt {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 5px;
}

.counter dd {
  margin: 0;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.counter dd small {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.counter.live dd { color: var(--sulphur); }
.counter.settled dd { color: var(--mint); }

/* ── the live tile ───────────────────────────────────────────────────────── */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  margin: 18px 4px 0;
  align-items: start;
}

.tile {
  border: 1px solid var(--rule-strong);
  background: linear-gradient(180deg, rgba(8, 22, 34, 0.72), rgba(8, 22, 34, 0.3));
  position: relative;
  min-width: 0;
}

.tile-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  flex-wrap: wrap;
}
.tile-head .idx { color: var(--sulphur); }
.tile-head .url { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.tile-head .who { color: var(--dim); margin-left: auto; }
.tile-head a.open { color: var(--mint); text-decoration: none; }
.tile-head a.open:hover { text-decoration: underline; }

.frame {
  position: relative;
  height: 560px;
  overflow: hidden;
}

.frame canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.plate-sheet {
  position: absolute;
  inset: 0;
  padding: 22px 30px 30px;
  overflow: hidden;
  z-index: 1;
}

.plate-head {
  display: flex;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 15px;
}
.plate-host { color: var(--mint); }

.plate-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0 0 13px;
  max-width: 44ch;
}

.plate-body {
  columns: 2;
  column-gap: 32px;
  column-rule: 1px solid var(--rule);
  max-height: 390px;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.62;
  color: rgba(220, 230, 236, 0.82);
}

.plate-body > * {
  margin: 0 0 9px;
  break-inside: avoid;
}
.plate-h1, .plate-h2, .plate-h3 {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}
.plate-li { padding-left: 13px; position: relative; }
.plate-li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 1px;
  background: var(--dim);
}
.plate-pre {
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--mint);
  border-left: 1px solid var(--rule);
  padding-left: 9px;
}

.plate-link {
  color: var(--sulphur);
  text-decoration: none;
  border-bottom: 1px solid rgba(231, 210, 75, 0.35);
}
.plate-link:hover { border-bottom-color: var(--sulphur); }

.plate-foot {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--dim);
  border-top: 1px solid var(--rule);
  padding-top: 9px;
}
.plate-stamp { color: var(--sulphur); font-size: 14px; line-height: 1; }
.plate-sha { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tile-foot {
  display: flex;
  gap: 18px;
  padding: 9px 13px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  flex-wrap: wrap;
}
.tile-foot .status { color: var(--mint); margin-left: auto; max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── side column ─────────────────────────────────────────────────────────── */

.aside { display: grid; gap: 18px; min-width: 0; }

.panel { border: 1px solid var(--rule-strong); min-width: 0; }

.panel > h2 {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--rule);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 10px;
  max-height: 310px;
  overflow: hidden;
}

.log-line {
  display: grid;
  grid-template-columns: 54px 30px minmax(0, 1fr) 26px 56px 42px;
  gap: 5px;
  padding: 3.5px 10px;
  border-bottom: 1px solid rgba(232, 238, 242, 0.05);
  color: rgba(220, 230, 236, 0.78);
  will-change: transform, opacity;
}
.log-at { color: var(--dim); }
.log-id { color: var(--sulphur); }
.log-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-status { color: var(--mint); }
.log-tokens, .log-ms { color: var(--dim); text-align: right; }
.log-off .log-status { color: #c9705c; }

.strip { display: grid; }

.strip-cell {
  display: grid;
  grid-template-columns: 112px 70px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 11px;
  border-bottom: 1px solid rgba(232, 238, 242, 0.05);
  font-family: var(--mono);
  font-size: 10px;
  text-decoration: none;
  color: rgba(220, 230, 236, 0.78);
}
.strip-cell:hover { background: rgba(232, 238, 242, 0.04); }
.strip-id { color: var(--ink); }
.strip-pages { color: var(--mint); text-align: right; }
.strip-status { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── explainer and foot ──────────────────────────────────────────────────── */

.loop {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule-strong);
  margin: 18px 4px 0;
}

.loop section {
  background: var(--ground);
  padding: 15px 16px 17px;
}
.loop h3 {
  margin: 0 0 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--sulphur);
  font-weight: 500;
}
.loop p { margin: 0; font-size: 12.5px; line-height: 1.58; color: rgba(220, 230, 236, 0.78); }
.loop p + p { margin-top: 7px; }
.loop b { color: var(--ink); font-weight: 500; }

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 4px 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim);
  flex-wrap: wrap;
}
.colophon a { color: var(--dim); text-decoration: none; }
.colophon a:hover { color: var(--mint); }

@media (max-width: 1080px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .counters { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .loop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plate-body { columns: 1; max-height: 340px; }
  .frame { height: 480px; }
}

@media (max-width: 640px) {
  .sheet { padding: 16px 14px 40px; }
  .counters { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loop { grid-template-columns: minmax(0, 1fr); }
  .frame { height: 420px; }
  .log-line { grid-template-columns: 48px minmax(0, 1fr) 26px 44px; }
  .log-tokens, .log-ms { display: none; }
  .tile-head .url { max-width: 28ch; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
