/* Vigilarch demo page.
 *
 * Register: a terminal transcript rendered as a web page. Monospace throughout,
 * dense, no gloss. The one thing this stylesheet is really for is making an open
 * window edge look different from a bounded one at a glance — that distinction is
 * the project's whole point, so it is carried by shape and colour, never by text
 * alone. */

/* --- tokens ---------------------------------------------------------------- */
/* The palette and the shared header bar live in base.css, which the landing page
 * links too, so the two pages cannot drift apart. This sheet only consumes them.
 *
 * Nothing below renames a class or an id: app.js queries this DOM by name, and a
 * restyle that renamed a hook would break the one thing on the page that matters. */

/* --- frame ---------------------------------------------------------------- */

* { box-sizing: border-box; }

/* base.css pads .sitenav for a full-bleed page; this page's body is already a
 * padded 1180px measure, so the bar rides that measure instead. */
.sitenav { padding-inline: 0; margin-bottom: .25rem; }

body {
  margin: 0;
  padding: 0 1.25rem 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.55 var(--mono);
  max-width: 1180px;
  margin-inline: auto;
}

/* Headings take the landing page's display face; everything with data in it
 * stays monospace, which is the register the transcript needs. */
h1, h2 {
  font-family: var(--display);
  font-weight: 600;
  font-stretch: 110%;
  letter-spacing: 0;
  color: var(--ink-strong);
}
h2 { font-size: .95rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

code { color: var(--ink); background: var(--panel-2); padding: 0 .25em; border-radius: 2px; }

/* --- explanatory strip ---------------------------------------------------- */

.strip {
  padding: 1.9rem 0 1.35rem;
  border-bottom: 1px solid var(--rule);
}

.strip h1 { margin: 0 0 .8rem; font-size: 1.45rem; font-weight: 700; }
.strip h1 .sub {
  color: var(--ink-faint);
  font-weight: 400;
  font-stretch: 100%;
}

.strip p {
  margin: 0 0 .6rem;
  max-width: 76ch;
  color: var(--ink-dim);
}

.strip b { color: var(--ink); }
.k-sealed      { color: var(--sealed); }
.k-unwitnessed { color: var(--unwitnessed); }

.links { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .9rem; font-size: 12px; }

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

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.field { display: flex; flex-direction: column; gap: .3rem; flex: 1 1 24rem; }
.field span { font-size: 11px; color: var(--ink-faint); text-transform: lowercase; }

input[type="text"], select {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .4rem .55rem;
}
input[type="text"] { width: 100%; }
input[type="text"]:focus-visible, select:focus-visible,
button:focus-visible, li:focus-visible, .log:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.buttons { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.equiv { display: inline-flex; gap: .3rem; align-items: center; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .4rem .7rem;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--ink-faint); }
button:disabled { opacity: .38; cursor: not-allowed; }
button.danger:not(:disabled) { color: var(--disputed); border-color: var(--disputed); }
button.secondary { color: var(--ink-faint); background: transparent; margin-left: auto; }

/* --- chains --------------------------------------------------------------- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.25rem 0;
  align-items: start;
}

.nodes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; min-width: 0; }

.node {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .75rem .85rem 1rem;
  min-width: 0;
}

.node h2 { margin: 0 0 .1rem; font-size: .95rem; }
.pubkey { color: var(--ink-faint); font-weight: 400; font-size: 11px; }

.quarantine-banner {
  margin: .5rem 0 .1rem;
  padding: .35rem .5rem;
  font-size: 11px;
  color: var(--disputed);
  background: var(--disputed-bg);
  border-left: 3px solid var(--disputed);
}

.chain { list-style: none; margin: .75rem 0 0; padding: 0; }

.chain li {
  padding: .4rem .5rem;
  margin-bottom: .3rem;
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-radius: 3px;
  background: var(--panel-2);
  cursor: pointer;
}
/* Hover and selection must not touch the left rule — that edge carries the
 * sealed / unwitnessed / disputed state and may never be repainted by a
 * transient interaction. */
.chain li:hover {
  border-top-color: var(--ink-faint);
  border-right-color: var(--ink-faint);
  border-bottom-color: var(--ink-faint);
}
.chain li[aria-selected="true"] {
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-bottom-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Sealed / unwitnessed carried on the left rule as well as in the badge. */
.chain li.st-sealed      { border-left-color: var(--sealed); }
.chain li.st-unwitnessed { border-left-color: var(--unwitnessed); }
.chain li.st-disputed    { border-left-color: var(--disputed); background: var(--disputed-bg); }

.row-head {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  font-size: 11px;
  color: var(--ink-faint);
}
.row-head .seq { color: var(--ink-dim); }
.row-head .id  { color: var(--ink); }
.row-head .badge { margin-left: auto; }
.row-text { margin-top: .2rem; color: var(--ink); word-break: break-word; }
.row-prev { font-size: 11px; color: var(--ink-faint); margin-top: .15rem; }

.badge {
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .05rem .3rem;
  border-radius: 2px;
  white-space: nowrap;
}
.badge.sealed      { color: var(--sealed);      background: var(--sealed-bg); }
.badge.unwitnessed { color: var(--unwitnessed); background: var(--unwit-bg); }
.badge.disputed    { color: var(--disputed);    background: var(--disputed-bg); }
.badge.fork        { color: var(--disputed);    background: var(--disputed-bg); }

.empty { color: var(--ink-faint); font-size: 12px; margin: .5rem 0 0; }

/* --- detail panel --------------------------------------------------------- */

.detail {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .75rem .85rem 1rem;
  position: sticky;
  top: .75rem;
  min-width: 0;
}
.detail h2 { margin: 0 0 .6rem; font-size: .95rem; }

.verdict {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: .03em;
}
.verdict.sealed      { color: var(--sealed);      background: var(--sealed-bg); }
.verdict.unwitnessed { color: var(--unwitnessed); background: var(--unwit-bg); }
.verdict.disputed    { color: var(--disputed);    background: var(--disputed-bg); }
.verdict .glyph { font-size: 1rem; line-height: 1; }

.kv { margin: .8rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; }
.kv dt { color: var(--ink-faint); font-size: 11px; }
.kv dd { margin: 0; word-break: break-all; }
.kv dd.none { color: var(--ink-faint); }

.detail-note {
  margin: .9rem 0 0;
  padding-top: .7rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-dim);
  font-size: 11.5px;
}

/* --- the unwitnessed window ----------------------------------------------- */
/* An open edge fades out and is dashed; a bounded edge is a solid cap. The two
 * must not be mistaken for one another at a glance. */

.window { margin-top: .9rem; }
.window h3 { margin: 0 0 .45rem; font-size: 11px; color: var(--ink-faint); font-weight: 400; }

.window-bar { display: flex; align-items: stretch; height: 26px; }

.cap {
  width: 10px;
  flex: none;
  border-top: 2px solid;
  border-bottom: 2px solid;
}
.cap.bounded  { border-color: var(--sealed); }
.cap.open     { border-color: var(--unwitnessed); }
.cap.left.bounded  { border-left: 4px solid var(--sealed); }
.cap.right.bounded { border-right: 4px solid var(--sealed); }
.cap.left.open  { border-left: 2px dashed var(--unwitnessed); }
.cap.right.open { border-right: 2px dashed var(--unwitnessed); }

.track {
  flex: 1;
  min-width: 0;
  border-top: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  background: var(--panel-2);
}
/* Fade the fill towards whichever side is open, so "unbounded" reads as
 * unbounded rather than as a tidy interval. */
.window-bar.open-left  .track { background: linear-gradient(90deg, transparent, var(--unwit-bg) 70%); }
.window-bar.open-right .track { background: linear-gradient(270deg, transparent, var(--unwit-bg) 70%); }
.window-bar.open-left.open-right .track {
  background: linear-gradient(90deg, transparent, var(--unwit-bg) 45%, var(--unwit-bg) 55%, transparent);
}

.edges { display: flex; justify-content: space-between; gap: 1rem; margin-top: .3rem; font-size: 11px; }
.edge { max-width: 48%; word-break: break-all; }
.edge.right { text-align: right; }
.edge .kind { display: block; letter-spacing: .03em; text-transform: uppercase; font-size: 10px; }
.edge.bounded .kind { color: var(--sealed); }
.edge.open    .kind { color: var(--unwitnessed); }
.edge .what { color: var(--ink-dim); }

/* --- attestation table ---------------------------------------------------- */

.attestations, .log-wrap {
  border-top: 1px solid var(--rule);
  padding: 1.1rem 0;
}
.attestations h2, .log-wrap h2 { margin: 0 0 .6rem; font-size: .95rem; }
.attestations h2, .log-wrap h2, .detail h2, .window h3 { text-transform: lowercase; }
.count { color: var(--ink-faint); font-weight: 400; font-size: 11px; }

table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
th {
  text-align: left;
  font-weight: 400;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
  padding: .25rem .5rem .25rem 0;
}
td { padding: .25rem .5rem .25rem 0; border-bottom: 1px solid var(--rule); }
td.who { color: var(--ink); }
td.who.quarantined { color: var(--disputed); }

/* --- transcript ----------------------------------------------------------- */

.log {
  margin: 0;
  padding: .7rem .8rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  max-height: 15rem;
  overflow: auto;
  font: inherit;
  color: var(--ink-dim);
  white-space: pre-wrap;
  word-break: break-word;
}
.log .cmd { color: var(--ink); }
.log .ok  { color: var(--sealed); }
.log .warn { color: var(--unwitnessed); }
.log .err { color: var(--disputed); }

footer {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  color: var(--ink-faint);
  font-size: 11.5px;
}
footer p { max-width: 76ch; margin: 0; }

/* --- narrow ---------------------------------------------------------------- */

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .detail { position: static; }
}
@media (max-width: 620px) {
  .nodes { grid-template-columns: 1fr; }
  button.secondary { margin-left: 0; }
}

/* ===========================================================================
 * PART TWO — the purple systems pass, demo page.
 *
 * The palette moved to a purple-dominant system in base.css, and this page
 * consumes those tokens, so most of the shift arrives here for free. What is
 * added below is the part a token cannot carry: the console framing, the glow
 * on the surfaces that are actually computing something, and the one-shot
 * flashes app.js plays when the ledger changes state.
 *
 * The page's own discipline is unchanged and is not relaxed here:
 *
 *   - The left rule of a chain row carries the ledger verdict. No hover, no
 *     selection and no flash may repaint it.
 *   - --accent is the system's colour and never a status. Everything purple
 *     below is a frame, a glow or an affordance.
 *   - A flash draws attention to a change the ledger made. It never announces
 *     one, and its colour always agrees with the state that is already there.
 * =========================================================================== */

/* --- the explanatory strip ------------------------------------------------- */

.strip { position: relative; isolation: isolate; }
.strip::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -1.5rem -1.5rem 0;
  pointer-events: none;
  background:
    radial-gradient(60% 90% at 12% 0%, var(--accent-wash), transparent 72%),
    radial-gradient(46% 70% at 88% 10%, var(--wash-indigo), transparent 76%);
}
.strip h1 { letter-spacing: -.015em; }
.strip .links a { position: relative; text-decoration: none; }
.strip .links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--t) var(--ease);
}
.strip .links a:hover::after { transform: scaleX(1); }

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

button {
  transition: border-color var(--t) ease, color var(--t) ease,
              box-shadow var(--t) ease, background-color var(--t) ease;
}
button:hover:not(:disabled) {
  border-color: var(--accent-edge);
  color: var(--ink-strong);
  box-shadow: 0 0 20px -8px var(--accent-glow);
}
/* The equivocate control keeps its --disputed edge on hover: it is the one
 * button on the page that causes a violation, and dressing it in the system
 * colour would understate that. */
button.danger:hover:not(:disabled) {
  border-color: var(--disputed);
  color: var(--disputed);
  box-shadow: 0 0 20px -8px rgba(255, 91, 78, .5);
}
input[type="text"]:focus-visible, select:focus-visible { border-color: var(--accent-edge); }

/* --- the two node panels --------------------------------------------------- */

.node {
  position: relative;
  transition: border-color var(--t) ease, box-shadow var(--t) ease;
}
.node:hover { border-color: var(--accent-line); }
.node h2 { display: flex; align-items: baseline; gap: .5rem; }

/* A chain row lifts a little towards the reader on hover, and the lift is on
 * the transform only — the left rule, which carries the verdict, is untouched. */
.chain li { transition: transform var(--t) var(--ease), border-color var(--t) ease, box-shadow var(--t) ease; }
.chain li:hover { transform: translateX(2px); box-shadow: 0 0 22px -14px var(--accent-glow); }
.chain li[aria-selected="true"] { box-shadow: 0 0 0 1px var(--accent), 0 0 26px -12px var(--accent-glow); }

/* --- the detail panel, raised ----------------------------------------------
 * This is the one surface on the page showing a computed answer rather than a
 * held object, so it is the one allowed a halo. */

.detail {
  box-shadow:
    0 0 0 1px var(--accent-line),
    0 18px 44px -30px rgba(0, 0, 0, .9),
    0 0 60px -30px var(--accent-glow);
}
.verdict { position: relative; overflow: hidden; }

/* --- attestation table ------------------------------------------------------ */

#att-table { transition: box-shadow .4s ease; }
tbody tr { transition: background-color var(--t) ease; }
tbody tr:hover { background: var(--accent-bg); }

/* --- transcript -------------------------------------------------------------
 * A console, so it gets a console's frame: a labelled top edge and a prompt
 * colour that matches the system rather than the states. */

.log {
  box-shadow: inset 0 0 40px -22px var(--accent-glow);
  scroll-behavior: smooth;
}
.log .cmd { color: var(--accent); }

/* Each line arrives once, and only the newest one moves. Without JavaScript
 * there are no lines at all, so nothing here can hide content. */
.log > span {
  display: block;
  animation: logline .26s var(--ease) both;
}
@keyframes logline {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

/* --- the one-shot flashes ---------------------------------------------------
 * Played by app.js after a re-render, on elements the render has already put
 * into the state the flash refers to. Each colour agrees with the state that is
 * already on the element:
 *
 *   fx-append   an object was written or exchanged      --accent
 *   fx-sealed   a record the ledger now reports sealed  --sealed
 *   fx-fork     a proven equivocation                   --disputed
 */

@keyframes fx-append {
  0%   { box-shadow: 0 0 0 1px var(--accent), 0 0 26px -4px var(--accent-glow); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
@keyframes fx-sealed {
  0%   { box-shadow: 0 0 0 1px var(--sealed), 0 0 26px -4px rgba(53, 209, 107, .55); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
/* Three beats rather than a fade: a violation is the one event on this page
 * that should not slide past unnoticed. */
@keyframes fx-fork {
  0%, 30%, 60%  { box-shadow: 0 0 0 1px var(--disputed), 0 0 24px -4px rgba(255, 91, 78, .6); }
  15%, 45%, 100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}

.fx-append { animation: fx-append .85s ease-out; }
.fx-sealed { animation: fx-sealed 1.1s ease-out; }
.fx-fork   { animation: fx-fork 1.25s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .log > span { animation: none; }
  .fx-append, .fx-sealed, .fx-fork { animation: none; }
  .chain li:hover { transform: none; }
}

/* --- footer ------------------------------------------------------------------ */

footer { border-top-color: var(--accent-line); }
