/* ciphr — the security layers. One file, no dependency, no external request.
   The colours are tokens, dark and light, because the page appears in the
   reader's environment rather than in ours.

   `site.css` is loaded before this file on that page and carries the shared
   navigation bar. It defines the same token values; where the two overlap, this
   file wins, which is the intended order — the geometry here must not change
   because a shell style changed. */

:root {
  --bg: #0d1014;
  --bg-raised: #14181e;
  --bg-sunk: #090b0e;
  --line: #262d36;
  --line-strong: #3a444f;
  --text: #dfe4ea;
  --text-dim: #97a1ae;
  --text-faint: #67717d;

  --asset: #e0b341;        /* centre: plaintext and key material */
  --gate: #7fb2d9;         /* rings with a gate in the code */
  --gate-soft: #3d5568;
  --switch: #56b98a;       /* switchable */
  --band: #c88be0;         /* reviewed core */
  --cut: #e0655f;          /* cuts */
  --absent: #566070;       /* not built, deferred */

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: ui-monospace, Cascadia Mono, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --bg-raised: #ffffff;
    --bg-sunk: #eceff3;
    --line: #d6dbe2;
    --line-strong: #aeb7c2;
    --text: #1b2028;
    --text-dim: #4d5663;
    --text-faint: #7b8492;
    --asset: #8a6104;
    --gate: #245c85;
    --gate-soft: #9fb8ca;
    --switch: #1c7a51;
    --band: #7b3d95;
    --cut: #b7332c;
    --absent: #9aa3af;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

/* ── Masthead ─────────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}

.masthead h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.status {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 92ch;
}

.status .src { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }

.masthead-links { display: flex; gap: 16px; font-size: 13px; }
.masthead-links a { color: var(--gate); text-decoration: none; border-bottom: 1px solid transparent; }
.masthead-links a:hover { border-bottom-color: var(--gate); }

/* ── Frame ───────────────────────────────────────────────────────────── */

.frame {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 360px;
}

.controls, .panel {
  overflow-y: auto;
  background: var(--bg-raised);
  font-size: 13px;
}

.controls { border-right: 1px solid var(--line); }
.panel { border-left: 1px solid var(--line); }

.stage { position: relative; min-width: 0; background: var(--bg-sunk); }

#canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#canvas.dragging { cursor: grabbing; }

.noscript {
  position: absolute; inset: 24px; margin: 0; padding: 16px;
  border: 1px dashed var(--line-strong); color: var(--text-dim);
}

/* ── Controls ────────────────────────────────────────────────────────── */

.control-block { padding: 16px 18px; border-bottom: 1px solid var(--line); }

.control-block h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 660;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex; align-items: center; gap: 8px;
}

.hint { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }

.build-readout {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  padding: 8px 10px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-left: 2px solid var(--switch);
}

.tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border: 1px solid currentColor;
  text-transform: none;
  white-space: nowrap;
}
.tag-switch { color: var(--switch); }
.tag-build { color: var(--asset); }
.tag-runtime { color: var(--gate); }
.tag-warn { color: var(--cut); }
.tag-plain { color: var(--text-faint); }

.switch-list { list-style: none; margin: 0; padding: 0; }
.switch-list > li { margin: 0 0 12px; }
.switch-list > li:last-child { margin-bottom: 0; }

.switch-list label {
  display: flex; gap: 8px; align-items: baseline;
  cursor: pointer; font-family: var(--mono); font-size: 12px;
}
.switch-list input { margin: 0; accent-color: var(--switch); flex: none; transform: translateY(2px); }
.switch-note { display: block; margin: 2px 0 0 22px; font-size: 11.5px; color: var(--text-faint); }

.legend { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--text-dim); }
.legend li { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }

.key { width: 26px; height: 0; flex: none; }
.key-solid { border-top: 2px solid var(--gate); }
.key-dashed { border-top: 2px dashed var(--line-strong); }
.key-switch { border-top: 2px dashed var(--switch); }
.key-absent { border-top: 2px dotted var(--absent); }
.key-band { border-top: 6px solid var(--band); opacity: 0.55; }
.key-cut { border-top: 2px dashed var(--cut); }

.zoom-row { display: flex; gap: 6px; flex-wrap: wrap; }
.zoom-row button {
  font: inherit; font-size: 12px;
  color: var(--text); background: var(--bg-sunk);
  border: 1px solid var(--line-strong); padding: 4px 10px; cursor: pointer;
}
.zoom-row button:hover { border-color: var(--gate); color: var(--gate); }

/* ── Panel ────────────────────────────────────────────────────────────── */

.panel-empty, .panel-body { padding: 18px 20px; }
.panel-empty h2 { margin: 0 0 8px; font-size: 14px; }
.panel-empty p { color: var(--text-dim); font-size: 12.5px; }

.panel-body h2 { margin: 0 0 2px; font-size: 15.5px; line-height: 1.3; }

.panel-kind {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px;
}
.panel-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.panel-body .lead { margin: 0 0 12px; font-size: 13.5px; }
.panel-body h3 {
  margin: 16px 0 6px; font-size: 10.5px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-faint);
}
.panel-body ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-dim); }
.panel-body li { margin-bottom: 7px; }
.panel-body li strong { color: var(--text); font-weight: 600; }
.panel-body code {
  font-family: var(--mono); font-size: 11.5px; background: var(--bg-sunk);
  padding: 1px 4px; border: 1px solid var(--line);
}
.panel-body blockquote {
  margin: 10px 0; padding: 8px 12px; font-size: 12.5px; color: var(--text-dim);
  border-left: 2px solid var(--line-strong); background: var(--bg-sunk);
}
.panel-sources { list-style: none; padding-left: 0; }
.panel-sources a { color: var(--gate); text-decoration: none; font-family: var(--mono); font-size: 11.5px; }
.panel-sources a:hover { text-decoration: underline; }
.panel-close {
  float: right; font: inherit; font-size: 11px; color: var(--text-faint);
  background: none; border: 1px solid var(--line); padding: 2px 8px; cursor: pointer;
}
.panel-close:hover { color: var(--text); border-color: var(--line-strong); }

/* ── Diagram ───────────────────────────────────────────────────────────── */

.node { cursor: pointer; }
.node:focus { outline: none; }
.node:focus-visible .hit { stroke: var(--text); stroke-width: 2; stroke-dasharray: 3 3; }

.ring-line { fill: none; stroke: var(--gate); stroke-width: 1.6; }
.ring-line.is-deployment { stroke: var(--line-strong); stroke-dasharray: 9 7; }
.ring-line.is-switchable { stroke: var(--switch); stroke-dasharray: 3 7; }
.hit { fill: none; stroke: transparent; stroke-width: 26; }

.node:hover .ring-line, .node.is-active .ring-line { stroke-width: 3.4; }

.ring-label {
  font-family: var(--mono); font-size: 12.5px; fill: var(--text);
  paint-order: stroke; stroke: var(--bg-sunk); stroke-width: 5px; stroke-linejoin: round;
}
.ring-sub {
  font-family: var(--font); font-size: 11px; fill: var(--text-faint);
  paint-order: stroke; stroke: var(--bg-sunk); stroke-width: 4px; stroke-linejoin: round;
}

.asset-disc { fill: var(--asset); fill-opacity: 0.09; stroke: var(--asset); stroke-width: 1.8; }
.node:hover .asset-disc, .node.is-active .asset-disc { fill-opacity: 0.18; }
.asset-label { font-family: var(--mono); font-size: 12.5px; fill: var(--asset); text-anchor: middle; }
.asset-sub { font-family: var(--font); font-size: 10.5px; fill: var(--text-dim); text-anchor: middle; }

.band-area { fill: var(--band); fill-opacity: 0.13; stroke: var(--band); stroke-width: 1.2; stroke-dasharray: 5 4; }
.node:hover .band-area, .node.is-active .band-area { fill-opacity: 0.24; }
.band-label {
  font-family: var(--mono); font-size: 11.5px; fill: var(--band);
  paint-order: stroke; stroke: var(--bg-sunk); stroke-width: 4px; stroke-linejoin: round;
}

.spoke { stroke: var(--gate-soft); stroke-width: 1.2; }
.leader { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; fill: none; opacity: 0.75; }
.client-box { fill: var(--bg-raised); stroke: var(--gate-soft); stroke-width: 1.4; }
.client-label { font-family: var(--mono); font-size: 11.5px; fill: var(--text); }
.client-sub { font-family: var(--font); font-size: 10.5px; fill: var(--text-faint); }

.is-inactive .client-box { stroke-dasharray: 3 4; }
.is-inactive .client-label { fill: var(--text-faint); }
.is-absent .client-box { stroke: var(--absent); stroke-dasharray: 2 4; }
.is-absent .client-label, .is-absent .client-sub { fill: var(--absent); }
.node:hover .client-box, .node.is-active .client-box { stroke: var(--gate); stroke-width: 2.2; }

.lateral-box { fill: var(--bg-raised); stroke: var(--gate); stroke-width: 1.4; }
.lateral-label { font-family: var(--mono); font-size: 11.5px; fill: var(--text); }
.lateral-sub { font-family: var(--font); font-size: 10.5px; fill: var(--text-faint); }
.lateral-arrow { stroke: var(--gate); stroke-width: 1.6; fill: none; }
.node:hover .lateral-box, .node.is-active .lateral-box { stroke-width: 2.6; }

.cut-area { fill: var(--cut); fill-opacity: 0.1; stroke: var(--cut); stroke-width: 1.3; stroke-dasharray: 6 5; }
.node:hover .cut-area, .node.is-active .cut-area { fill-opacity: 0.2; }
.cut-label {
  font-family: var(--mono); font-size: 11.5px; fill: var(--cut);
  paint-order: stroke; stroke: var(--bg-sunk); stroke-width: 4px; stroke-linejoin: round;
}
.substrate { fill: none; stroke: var(--cut); stroke-width: 1.2; stroke-dasharray: 3 8; }

.chip-text { font-family: var(--mono); font-size: 10px; fill: var(--switch); }
.chip-box { fill: var(--bg-sunk); stroke: var(--switch); stroke-width: 1; }

.p4-mark { fill: none; stroke: var(--text); stroke-width: 5; stroke-opacity: 0.14; }

.dimmed { opacity: 0.14; }
.hidden { display: none; }

@media (max-width: 1180px) {
  .frame { grid-template-columns: 240px minmax(0, 1fr); }
  .panel {
    position: fixed; right: 0; top: 0; bottom: 0; width: 340px; z-index: 5;
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35);
  }
}

@media (max-width: 820px) {
  .frame { grid-template-columns: 1fr; grid-template-rows: auto 62vh; }
  .controls { border-right: none; border-bottom: 1px solid var(--line); }
  .panel { width: 100%; }
}
