/* Figures for /projects/protege-wx/. Loaded after article.css and uses the same
   colours, type and motion tokens. Interactive parts start hidden and are switched
   on by protege-wx.js; without it, every figure reads as plain HTML. */

/* Shared table */
.pw-table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.45; }
.pw-table caption {
  text-align: left; padding: 14px 16px 4px; font-family: var(--mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
.pw-table th, .pw-table td { text-align: left; padding: 10px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.pw-table thead th { font-weight: 500; font-size: 13px; color: var(--muted); border-top: 0; }
.pw-table code { font-size: 0.86em; overflow-wrap: normal; white-space: nowrap; }
.parse-table td:nth-child(n+2) { color: var(--muted); }
.parse-table td:first-child code { white-space: normal; }
@media (max-width: 680px) {
  .parse-table thead { display: none; }
  .parse-table, .parse-table tbody, .parse-table tr, .parse-table td { display: block; }
  .parse-table tr { padding: 12px 16px; border-top: 1px solid var(--line); }
  .parse-table td { padding: 0; border: 0; font-size: 14px; }
  .parse-table td:empty { display: none; }
  .parse-table td:first-child { margin-bottom: 4px; }
  .parse-table td:nth-child(2)::before { content: "Kind: "; color: var(--faint); }
  .parse-table td:nth-child(3)::before { content: "Subject: "; color: var(--faint); }
  .parse-table td:nth-child(4)::before { content: "Type: "; color: var(--faint); }
  .parse-table td:nth-child(5)::before { content: "Who: "; color: var(--faint); }
}

/* Panels share the reference figures' look */
.wire, .states, .leak {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px;
}
.wire figcaption, .states figcaption, .leak figcaption { margin-top: 16px; }

/* 1. Request builder */
.wire-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.wire-cmd, .leak-mode, .st-act {
  font: 600 14px/1 var(--font); min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  transition: background-color var(--dur-quick), color var(--dur-quick), border-color var(--dur-quick), transform var(--dur-quick) var(--spring);
}
.wire-cmd:hover, .leak-mode:hover, .st-act:hover { border-color: var(--faint); }
.wire-cmd[aria-pressed="true"], .leak-mode[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.wire-cmd:active, .leak-mode:active, .st-act:active { transform: scale(.96); }
.wire-stages { list-style: none; padding: 0 !important; margin: 0 !important; display: grid; gap: 0; }
.wire-stage { margin: 0 !important; padding: 0 0 18px 22px !important; position: relative; border-left: 1px solid var(--line); margin-left: 11px !important; }
.wire-stage:last-child { border-left-color: transparent; padding-bottom: 0 !important; }
.wire-head { margin: 0 0 8px !important; font-size: 15px; font-weight: 650; line-height: 1.4; display: flex; align-items: center; gap: 10px; }
.wire-n {
  position: absolute; left: -12px; top: 0; width: 23px; height: 23px; border-radius: 50%;
  display: grid; place-items: center; font: 500 12px/1 var(--mono); color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  transition: background-color var(--dur-quick), color var(--dur-quick), border-color var(--dur-quick), transform var(--dur-move) var(--spring);
}
.wire-stage.active .wire-n { background: var(--text); color: var(--bg); border-color: var(--text); transform: scale(1.12); }
.wire-box {
  margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  font: 13px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto;
  transition: border-color var(--dur-quick);
}
.wire-stage.active .wire-box { border-color: var(--text); }
.wire-hex { white-space: pre; overflow-wrap: normal; }
.wire-http { white-space: pre-wrap; }
.wire-note { margin: 8px 0 0 !important; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.w-k { color: var(--muted); }
.w-v, .w-verb { font-weight: 650; }
.w-amp { color: var(--faint); }
.w-lbl { display: inline-block; width: 3.2ch; color: var(--faint); }
.w-pad { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; color: var(--muted); }
.w-blk { display: inline-block; border-radius: 4px; transition: background-color var(--dur-move) var(--spring); }
.w-blk.w-changed { background: color-mix(in srgb, var(--text) 14%, transparent); transition-duration: 0s; }
.w-m { font-weight: 700; }
.w-c { color: var(--faint); }
.w-body { display: block; word-break: break-all; }
.w-arrow { color: var(--faint); }
.w-out { font-weight: 700; }
@media (max-width: 560px) {
  .wire, .states, .leak { margin-left: -12px; margin-right: -12px; padding: 16px 14px; border-radius: 18px; }
  .wire-box { font-size: 11.5px; padding: 10px 10px; }
  .wire-stage { padding-left: 18px !important; }
}

/* 2. Area state machine */
.states-stage { background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 14px 10px; }
.states-svg { display: block; width: 100%; max-width: 620px; height: auto; aspect-ratio: 556 / 340; margin: 0 auto; overflow: visible; }
.states-svg text { font-family: var(--font); }
.st-links path { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.st-links .st-dashed { stroke-dasharray: 4 5; }
.st-head { fill: var(--faint); }
.st-note { fill: var(--faint); font-family: var(--mono) !important; font-size: 10.5px; letter-spacing: 0.06em; }
.st-node rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; transition: fill var(--dur-quick), stroke var(--dur-quick); }
.st-unknown rect { stroke-dasharray: 5 5; }
.st-name { fill: var(--text); font-size: 15px; font-weight: 650; letter-spacing: -0.01em; transition: fill var(--dur-quick); }
.st-code { fill: var(--muted); font-family: var(--mono) !important; font-size: 10.5px; transition: fill var(--dur-quick); }
.st-node.lit rect { fill: var(--text); stroke: var(--text); }
.st-node.lit .st-name, .st-node.lit .st-code { fill: var(--bg); }
.st-token { fill: var(--text); stroke: var(--bg); stroke-width: 3; paint-order: stroke; opacity: 0; }
.states.enhanced .st-token { opacity: 1; }
.states-panel { margin-top: 16px; }
.states-readout {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0;
  background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.states-readout div { background: var(--bg); padding: 12px 14px; min-width: 0; }
.states-readout dt { color: var(--muted); font-size: 12.5px; }
.states-readout dd { margin: 2px 0 0; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; transition: opacity var(--dur-quick); }
.states-readout dd code { font-size: 13px; background: none; border: 0; padding: 0; }
.states-readout dd strong { font-size: 17px; }
.states-readout.swap dd { opacity: 0.25; transition-duration: 0s; }
.states-note { margin: 14px 0 0 !important; min-height: 4.8em; font-size: 15.5px; line-height: 1.55; color: var(--muted); }
.states-note strong { color: var(--text); }
.states-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.st-act.quiet { color: var(--muted); border-style: dashed; }
.states.enhanced .states-table { display: none; }
.states-table { margin-top: 16px; background: var(--bg); }
@media (max-width: 680px) {
  .states-readout { grid-template-columns: 1fr; }
  .states-note { min-height: 7.5em; }
}
@media (max-width: 560px) {
  .states-stage { padding: 8px 4px; }
  .st-name { font-size: 21px; transform: translateY(7px); }
  .st-code, .st-note { display: none; }
  .pw-table th, .pw-table td { padding: 9px 10px; font-size: 13.5px; }
}

/* 3. Session leak */
.leak-modes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.leak-readout { display: flex; flex-wrap: wrap; gap: 8px 40px; margin-bottom: 14px; }
.leak-readout p { margin: 0 !important; display: flex; flex-direction: column; }
.leak-label { color: var(--muted); font-size: 13.5px; }
.leak-count strong { font-size: clamp(40px, 7vw, 56px); line-height: 1.05; letter-spacing: -0.04em; font-weight: 750; font-variant-numeric: tabular-nums; }
.leak-health strong { font-size: 20px; line-height: 1.3; margin-top: auto; padding-bottom: 6px; transition: opacity var(--dur-quick); }
.leak.down .leak-health strong { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.leak-dots {
  display: grid; grid-template-columns: repeat(25, minmax(0, 1fr)); gap: 5px; padding: 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
}
.leak-dots i {
  display: block; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line);
  transform: scale(.55); transition: transform var(--dur-move) var(--spring), background-color var(--dur-quick), border-color var(--dur-quick);
}
.leak-dots i.on { background: var(--text); border-color: var(--text); transform: scale(1); }
.leak-dots i.on.old { background: color-mix(in srgb, var(--text) 45%, var(--bg)); border-color: transparent; }
.leak.down .leak-dots { border-style: dashed; }
.leak-scrub { margin-top: 16px; }
.leak-scrub label { display: block; margin-bottom: 4px; }
.leak-scrub #leak-clock { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.leak-scrub input { width: 100%; accent-color: var(--text); min-height: 32px; }
.leak-ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.leak-controls { display: flex; gap: 18px; align-items: flex-start; margin-top: 14px; }
.leak-controls .button { flex: none; min-width: 140px; }
.leak-log { margin: 0 !important; flex: 1; min-height: 4.8em; font-size: 15.5px; line-height: 1.55; color: var(--muted); }
.leak-log strong { color: var(--text); }
.leak.enhanced .leak-fallback { display: none; }
@media (max-width: 560px) {
  .leak-dots { grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; padding: 10px; }
  .leak-controls { flex-direction: column; gap: 12px; }
  .leak-log { min-height: 6.4em; }
}

@media (prefers-reduced-motion: reduce) {
  .wire-stage.active .wire-n { transform: none; }
  .leak-dots i { transform: none; }
}
