/* Field-terminal direction: olive-black canvas, bone text, one lime marker for what you act on,
   mono for every label and number, sharp corners, no shadows. Red is reserved for "serious". */
:root {
  --canvas: #13140e;
  --canvas-2: #1b1c15;
  --canvas-3: #24251d;
  --ink: #f4f3e8;
  --ink-soft: #9a998f;
  --rule: #33342c;
  --rule-strong: #4a4b42;
  --lime: #ebfc72;
  --serious: #e0475b;
  --serious-tag: #c8384c; /* darker red behind white numbers: 5:1 instead of 3.9:1 */
  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  /* spacing steps: 4 8 12 16 24 32 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r: 4px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --panel-w: 344px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--canvas); color: var(--ink); font: 15px/22px var(--sans); }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#world:active { cursor: grabbing; }
.skip { position: fixed; left: var(--s4); top: -48px; z-index: 20; background: var(--lime); color: var(--canvas); padding: var(--s2) var(--s3); border-radius: var(--r); font: 13px/16px var(--mono); }
.skip:focus { top: var(--s4); }
.mono, .meta, .fine, h2, .btn, .link, .demos, .tour-step, .ribbon-ends, .legend b, .v-sub { font-family: var(--mono); }

/* ---------- notebook ---------- */
#notebook {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--panel-w);
  overflow-y: auto; padding: var(--s5) var(--s5) var(--s6); background: var(--canvas);
  border-right: 1px solid var(--rule);
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
h1 { font: 400 13px/16px var(--mono); margin: 0 0 var(--s2); color: var(--ink); }
.tagline { margin: 0 0 var(--s5); color: var(--ink-soft); text-wrap: pretty; }
/* sections are separated by space, not rules */
section, .report-box { padding: var(--s6) 0 0; }
h2 { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--ink-soft); margin: 0 0 var(--s3); }
.spec-name { margin: 0; font: 400 32px/34px var(--sans); letter-spacing: -0.03em; overflow-wrap: anywhere; text-wrap: balance; }
.meta { margin: var(--s2) 0 0; color: var(--ink-soft); font-size: 12px; line-height: 16px; }
.fine { font-size: 12px; line-height: 18px; color: var(--ink-soft); margin: var(--s6) 0 0; }
a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--lime); }

.actions { display: grid; gap: var(--s3); justify-items: start; }
.demos { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 18px; }
.link { font-size: inherit; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--lime); }
.btn {
  font-size: 13px; line-height: 16px; color: var(--ink); background: transparent; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: var(--r); padding: var(--s2) var(--s3);
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease), color 200ms var(--ease);
}
.btn:hover { border-color: var(--ink-soft); background: var(--canvas-2); }
.btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.btn.primary { background: var(--lime); color: var(--canvas); border-color: var(--lime); }
.btn.primary:hover { background: #f4ff9e; }
.btn.quiet { border-color: transparent; color: var(--ink-soft); }
.btn[aria-pressed="true"] { color: var(--lime); }
.btn:focus-visible, .link:focus-visible, summary:focus-visible, label:focus-within, a:focus-visible { outline: 1px solid var(--lime); outline-offset: 2px; }

.progress { height: 2px; background: var(--rule); margin-top: var(--s3); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--lime); transition: width 200ms var(--ease); }

/* verdict: one plain sentence, then one tick per hazard like a scale bar */
.verdict { padding-top: var(--s5); }
.v-title { margin: 0 0 var(--s3); font: 400 32px/34px var(--sans); letter-spacing: -0.03em; }
.v-title.hostile { color: var(--serious); }
.v-bar { display: flex; gap: 2px; height: 6px; margin-bottom: var(--s2); }
.v-bar i { flex: 1; }
.v-bar .sv3 { background: var(--serious); }
.v-bar .sv2 { background: var(--ink); }
.v-bar .sv1 { background: var(--rule-strong); }
.v-sub { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 16px; }

/* skeletons while a file is being surveyed */
.skeleton, .skeleton-row { background: var(--canvas-2); border-radius: var(--r); color: transparent; }
.v-title.skeleton { height: 32px; width: 70%; }
.v-bar.skeleton { height: 6px; }
.v-sub.skeleton { height: 16px; width: 40%; }
.skeleton-row { height: 32px; margin-bottom: var(--s2); list-style: none; }

/* hazards: ruled rows, numbered with the same tag as the pins on the map */
.hazards { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.hazards li { border-bottom: 1px solid var(--rule); }
.hazards details { transition: background-color 200ms var(--ease); }
.hazards details[open], .hazards details.hot { background: var(--canvas-2); }
.hazards summary { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s3); align-items: baseline; padding: var(--s2) var(--s1); cursor: pointer; list-style: none; }
.hazards summary::-webkit-details-marker { display: none; }
.hazards summary:hover .hz-title { color: var(--lime); }
.num { min-width: 28px; height: 20px; border-radius: var(--r); display: grid; place-items: center; font: 400 12px/1 var(--mono); }
.num.s3 { background: var(--serious-tag); color: #fff; }
.num.s2 { background: var(--ink); color: var(--canvas); }
.num.s1 { border: 1px solid var(--rule-strong); color: var(--ink-soft); }
.hz-title { transition: color 200ms var(--ease); }
.explain-btn {
  font: 11px/16px var(--mono); color: var(--ink-soft); background: transparent; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: var(--r); padding: 1px 6px; align-self: center;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.explain-btn:hover, .explain-btn[aria-expanded="true"] { color: var(--lime); border-color: var(--lime); }
.explain-btn:focus-visible { outline: 1px solid var(--lime); outline-offset: 2px; }
.explain { margin: var(--s3) 0 0; padding: var(--s3) 0 0; border-top: 1px dashed var(--rule-strong); }
.explain dt { font: 11px/16px var(--mono); color: var(--lime); margin-top: var(--s2); }
.explain dt:first-child { margin-top: 0; }
.explain dd { margin: 2px 0 0; color: var(--ink); }
.hz-body { padding: 0 var(--s2) var(--s3) calc(28px + var(--s1) + var(--s3)); }
.hz-body p { margin: 0 0 var(--s2); color: var(--ink-soft); }
.hz-ev { font: 12px/16px var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.empty { color: var(--ink-soft); padding: var(--s3) 0; }

/* key */
.hyps { display: flex; height: 8px; margin-bottom: var(--s3); }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.legend li { display: grid; grid-template-columns: 8px 1fr auto; gap: var(--s3); align-items: center; }
.legend li i { width: 8px; height: 8px; display: block; }
.legend b { font-weight: 400; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.report-box summary { font: 12px/16px var(--mono); color: var(--ink-soft); cursor: pointer; }
.report-box summary:hover { color: var(--ink); }
.report { margin-top: var(--s3); }
.report p { margin: 0 0 var(--s3); }

/* ---------- map overlays ---------- */
.hint, .controls, .ribbon, .tourcard { position: fixed; z-index: 4; }
.hint {
  top: var(--s4); left: calc(var(--panel-w) + var(--s4)); margin: 0; padding: var(--s2) var(--s3);
  background: var(--canvas); border: 1px solid var(--rule); border-radius: var(--r); color: var(--ink-soft);
  font: 12px/16px var(--mono); transition: opacity 300ms var(--ease);
}
.hint.gone { opacity: 0; pointer-events: none; }
@media (max-width: 1180px) { .hint { top: 64px; } }
.controls { top: var(--s4); right: var(--s4); display: flex; background: var(--canvas); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.controls .btn { border: 0; border-radius: 0; }
.controls .btn + .btn { border-left: 1px solid var(--rule); }

.ribbon {
  left: calc(var(--panel-w) + var(--s4)); right: var(--s4); bottom: var(--s4);
  background: var(--canvas); border: 1px solid var(--rule); border-radius: var(--r); padding: var(--s2) var(--s3) var(--s1);
}
.ribbon-ends { display: flex; justify-content: space-between; gap: var(--s3); font-size: 11px; line-height: 16px; color: var(--ink-soft); margin-bottom: var(--s1); }
#ribbon-read { color: var(--lime); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ribbon-canvas { display: block; width: 100%; height: 44px; cursor: pointer; }

.tourcard {
  left: calc(var(--panel-w) + 50% - var(--panel-w) / 2); transform: translateX(-50%);
  bottom: 104px; width: min(440px, calc(100vw - var(--panel-w) - 64px));
  background: var(--canvas); border: 1px solid var(--rule-strong); border-radius: var(--r); padding: var(--s4) var(--s5);
}
.tour-step { margin: 0; color: var(--lime); font-size: 12px; line-height: 16px; }
.tourcard h2 { margin: var(--s2) 0; font: 400 22px/26px var(--sans); letter-spacing: -0.02em; color: var(--ink); }
.tourcard p#tour-text { margin: 0 0 var(--s4); color: var(--ink-soft); text-wrap: pretty; }
.tour-actions { display: flex; gap: var(--s2); }
.tour-actions .quiet { margin-left: auto; }
.reveal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.reveal-head .btn { padding: 4px var(--s2); }
.reveal kbd { font: 11px/1 var(--mono); color: var(--ink-soft); margin-left: var(--s1); }
.tourcard p#reveal-text { margin: 0; color: var(--ink-soft); text-wrap: pretty; }
.reveal .progress span { transition: none; }

.tip {
  position: fixed; pointer-events: none; z-index: 6; max-width: 320px; padding: var(--s2) var(--s3);
  background: var(--canvas); border: 1px solid var(--rule-strong); border-radius: var(--r); font: 12px/16px var(--mono); color: var(--ink-soft);
}
.tip strong { font: 400 15px/22px var(--sans); color: var(--ink); display: block; }
.tip code { font: 12px/16px var(--mono); color: var(--ink); display: block; margin-top: var(--s1); white-space: pre; }

.drop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(19, 20, 14, 0.8); border: 1px dashed var(--lime); }
.drop p { font: 400 32px/34px var(--sans); letter-spacing: -0.03em; }

@media (max-width: 760px) {
  :root { --panel-w: 0px; }
  #notebook { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 46vh; padding: var(--s4); border-right: 0; border-top: 1px solid var(--rule-strong); }
  .spec-name, .v-title { font-size: 26px; line-height: 28px; }
  section, .report-box { padding-top: var(--s5); }
  .hint { display: none; }
  .controls { left: var(--s4); right: var(--s4); }
  .controls .btn { font-size: 11px; padding: 6px var(--s2); white-space: nowrap; flex: 1 1 auto; }
  .ribbon { left: var(--s4); right: var(--s4); bottom: calc(46vh + var(--s2)); }
  .tourcard { left: 50%; width: calc(100vw - 32px); bottom: calc(46vh + 96px); }
  #tourcard { bottom: var(--s4); max-height: calc(46vh - 32px); overflow-y: auto; z-index: 5; } /* over the notes sheet, not the map */
  .reveal { padding: var(--s3) var(--s4); }
  .reveal h2 { font-size: 18px; line-height: 22px; margin-bottom: 0; }
  .reveal #reveal-text { display: none; } /* the open hazard row below says the same */
  .tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0ms !important; }
}
