/* The audit's tag: a small bronze tag hung in Arachne's web while she works.
   The scene (the spiders, their threads, the findings in the web) is the
   main display; this tag is secondary and stays small, but every word on it
   is readable. The canvas draws the tag itself (data-surface="tablet": a
   +=====+ edge, [ ] sides and two silk ties up into the web, see the top of
   styles.css); this file sets the words on its face. app.js renderStatus()
   fills it.

   On its face: the stage as a title, the elapsed time, one plain sentence
   about what is happening, the cloth on the loom (the percentage done), four
   knots for the four stages, and three big counts. Everything else is folded
   under "Read the threads". */

#status-view.loom {
  --loom-ink: #f6ecd8;      /* 15.9:1 on the tablet face #19150f */
  --loom-mute: #cdbb9b;     /*  9.9:1 */
  --loom-faint: #b3a283;    /*  7.5:1 */
  --loom-gold: #f0c47a;     /* 11.3:1 */
  --loom-thread: #8a6634;   /* bronze lines, never text */
  --loom-warp: rgba(205, 187, 155, 0.42);

  max-width: 440px;
  margin: calc(var(--lh) * 3.5) 0 var(--lh);
  padding: 14px 18px 12px;
  color: var(--loom-ink);
}
/* while the audit runs the tag stays small and the web gets the stage;
   the finished report (another view) may use the full column */
body[data-page="investigation"] #status-view.loom { max-width: 330px; }

.loom p { margin: 0; }

/* ---------- Stage, time, and what's happening now ---------- */

/* the data-mode badge: a simulation, demo data or a replay, never mistaken for a real audit */
.loom-mode {
  display: inline-block;
  margin: 6px 0 0 !important;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: var(--lh-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--loom-gold);
}
.loom-mode::before { content: "[ "; color: var(--loom-thread); }
.loom-mode::after { content: " ]"; color: var(--loom-thread); }
.loom-mode[hidden] { display: none; }

.loom-head { display: flex; align-items: baseline; gap: 1ch; }
.loom h2.loom-title {
  display: block;
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--loom-gold);
}
.loom h2.loom-title::before, .loom h2.loom-title::after { content: none; }
.loom-clock { font-size: var(--fs-sm); color: var(--loom-mute); font-variant-numeric: tabular-nums; }
.loom-head .spin { font-size: var(--fs-sm); color: var(--loom-gold); }

.loom-now {
  margin-top: 4px !important;
  font-family: var(--font-prose);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--loom-ink);
  text-wrap: pretty;
}

/* what comes next, who's at work, and the latest catch (fed by the scene) */
.loom-next, .loom-counts, .loom-caught { margin-top: 4px !important; font-size: var(--fs-sm); line-height: 1.45; }
.loom-next { color: var(--loom-mute); }
.loom-counts { color: var(--loom-ink); font-variant-numeric: tabular-nums; }
.loom-caught { color: var(--loom-ink); text-wrap: pretty; }
.loom-next[hidden], .loom-counts[hidden], .loom-caught[hidden] { display: none; }
.loom-caught .lc-label { color: var(--loom-gold); font-weight: 700; text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.loom-caught .lc-risk { font-weight: 700; color: #f4cc64; }
.loom-caught .lc-risk.critical { color: #ff8a80; }
.loom-caught .lc-risk.high { color: #ffa070; }
.loom-caught .lc-risk.low { color: #86d2a4; }
.loom-caught .lc-risk.info { color: #98bae0; }

/* ---------- The cloth: woven up to the share of checks done ---------- */

.loom-cloth { display: flex; align-items: center; gap: 1ch; margin-top: 10px; }
.cloth {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 12px;
  white-space: pre;
  letter-spacing: 0;
}
.cloth .woven { color: var(--loom-gold); }
.cloth .warp { color: var(--loom-warp); }
.cloth-pct {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--loom-ink);
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  text-align: right;
}

/* ---------- Four knots on one thread, one per stage ---------- */

.loom-stages { display: flex; align-items: center; gap: 1ch; margin-top: 6px; }
.journey {
  flex: 1;
  min-width: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
}
.journey li { min-width: 0; }
.journey .knot { display: flex; white-space: pre; color: var(--loom-faint); line-height: var(--lh); }
/* the thread runs out of each knot to its neighbours: woven (=) behind the
   stage underway, loose (-) ahead of it */
.journey .knot::before, .journey .knot::after {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  content: "- - - - - - - - - - - - - - - - - - - - - -";
  color: var(--loom-thread);
}
.journey .knot::before { direction: rtl; }
.journey li:first-child .knot::before, .journey li:last-child .knot::after { visibility: hidden; }
.journey li.done .knot { color: var(--patina); }
.journey li.done .knot::before, .journey li.done .knot::after,
.journey li.active .knot::before { content: "======================================"; color: var(--loom-gold); }
.journey li.active .knot { color: var(--loom-gold); font-weight: 700; }
.stage-count { font-size: var(--fs-sm); color: var(--loom-mute); white-space: nowrap; }

/* ---------- The tally: three big, plain numbers ---------- */

.tally {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 8px;
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px dashed rgba(138, 102, 52, 0.55);
}
.tally-cell { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.tally dd {
  order: -1; /* the number on top */
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--loom-ink);
  font-variant-numeric: tabular-nums;
}
.tally dt {
  font-size: var(--fs-xs);
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--loom-mute);
}
.tally-cell.gold dd { color: var(--loom-gold); }
.tally dd.bump { animation: loom-bump 1.4s ease-out; }
@keyframes loom-bump {
  0% { color: #fff3d6; text-shadow: 0 0 14px rgba(240, 196, 122, 0.7); }
  100% { text-shadow: 0 0 0 rgba(240, 196, 122, 0); }
}

/* ---------- Arachne's notes: the case file, one line per list ----------
   Each line: the list's name and how many values are on it, then the latest
   few. Confirmed values in gold, possible ones muted, unchecked claims faint
   and slanted. Open on wide screens; on phones only the summary shows. */

.loom-notes { margin: 8px 0 0; padding-top: 6px; border-top: 1px dashed rgba(138, 102, 52, 0.55); }
.loom-notes[hidden] { display: none; }
.loom .loom-notes summary { padding: 2px 0; color: var(--loom-gold); cursor: pointer; }
.loom .loom-notes summary::before { content: "[+] "; letter-spacing: 0; }
.loom .loom-notes[open] summary::before { content: "[-] "; }
.loom .loom-notes summary:hover { color: var(--loom-ink); }
.loom-notes .ln-sum { margin-left: 0.5ch; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--loom-faint); }
.ln-list { margin: 4px 0 0; }
.ln-row {
  display: grid;
  grid-template-columns: 13ch 1fr;
  column-gap: 1ch;
  padding: 1px 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-ui);
}
.ln-row dt { color: var(--loom-mute); white-space: nowrap; }
.ln-row dt .ln-n { color: var(--loom-faint); font-variant-numeric: tabular-nums; }
.ln-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--loom-ink); }
.ln-v.confirmed { color: var(--loom-gold); font-weight: 700; }
.ln-v.seed { color: var(--loom-ink); }
.ln-v.possible { color: var(--loom-mute); }
.ln-v.claimed { color: var(--loom-faint); font-style: italic; }
.ln-v.masked { letter-spacing: 0.04em; }
.ln-sep, .ln-more { color: var(--loom-faint); }

/* ---------- Read the threads: the detail, folded by default ---------- */

.loom .loom-sub {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: var(--lh-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--loom-mute);
  text-shadow: none;
}
.loom .loom-sub::before { content: none; }
.loom h3.loom-sub { margin-top: 12px; }

.loom-log { margin: 8px 0 0; }
.loom .loom-log summary {
  width: auto;
  padding: 2px 0;
  color: var(--loom-gold);
  cursor: pointer;
}
.loom .loom-log summary::before { content: "[+] "; color: var(--loom-gold); letter-spacing: 0; }
.loom .loom-log[open] summary::before { content: "[-] "; }
.loom .loom-log summary:hover { color: var(--loom-ink); }

.threads { max-height: 50vh; overflow-y: auto; padding-right: 4px; }
.spiders, .happenings { list-style: none; margin: 0; padding: 0; }
.spiders li, .happenings li { font-size: var(--fs-sm); line-height: var(--lh-ui); color: var(--loom-ink); }
.spiders li { padding-left: 3ch; text-indent: -3ch; }
.spiders li::before { content: "o- "; color: var(--loom-gold); white-space: pre; }
.spiders li.more, .spiders li.idle { color: var(--loom-mute); }
.spiders li.more::before, .spiders li.idle::before { color: var(--loom-thread); }

.happenings li { display: grid; grid-template-columns: 2ch 1fr; column-gap: 1ch; padding: 2px 0; }
.happenings .mark { color: var(--loom-faint); font-weight: 700; }
.happenings .find .mark { color: var(--loom-gold); }
.happenings .lead .mark { color: var(--silver); }
.happenings .gap .mark { color: var(--err); }
.happenings .gone, .happenings .step .said { color: var(--loom-mute); }
.happenings li.idle { display: block; color: var(--loom-mute); }

.loom-tasks { margin-top: 10px !important; font-size: var(--fs-xs); line-height: var(--lh-ui); color: var(--loom-faint); }
.loom-tasks code { color: var(--loom-faint); }

/* new audit: a quiet way out at the foot of the tag */
/* an alert on the tag, framed in ASCII rules: +--[ ! ]----- ... -----+ */
.loom-alert {
  margin-top: 12px;
  overflow: hidden;
  font-size: var(--fs-sm);
  line-height: var(--lh-ui);
  color: var(--loom-ink);
}
.loom-alert[hidden] { display: none; }
.loom-alert::before, .loom-alert::after {
  display: block;
  white-space: pre;
  overflow: hidden;
  font-family: var(--mono);
  color: var(--err);
}
.loom-alert::before { content: "+--[ ! ]-------------------------------------------------------------------"; font-weight: 700; }
.loom-alert::after { content: "+---------------------------------------------------------------------------"; }
.loom-alert-text { padding: 4px 0 2px 2ch !important; text-wrap: pretty; }
.loom-alert .btn { margin: 2px 0 6px 2ch; color: var(--loom-gold); font-size: var(--fs-xs); }
.loom-alert .btn[hidden] { display: none; }
.loom-alert .btn:hover, .loom-alert .btn:focus-visible { background: var(--loom-gold); color: #19150f; }

.loom #new-audit { margin-top: 6px; color: var(--loom-mute); font-size: var(--fs-xs); }
.loom #new-audit:hover, .loom #new-audit:focus-visible { background: var(--loom-mute); color: #19150f; }

/* ---------- Phones: a compact tag under the web ---------- */

@media (max-width: 600px) {
  #status-view.loom { margin-top: calc(var(--lh) * 2.5); padding: 12px 14px 10px; }
  body[data-page="investigation"] #status-view.loom { max-width: none; }
  .loom-now { font-size: 15px; }
  .tally dd { font-size: 26px; }
  .ln-row { grid-template-columns: 11ch 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .tally dd.bump { animation: none; }
}
@media (forced-colors: active) {
  .cloth .woven, .journey li.active .knot { color: Highlight; }
}
