/* ── BioForge Fault Isolation Manual — sheet runner styles ──────────────
   The Boeing FIM sheet is the PRIMARY interface (owner directive, J.1).
   Paper sheet: light stock, ink lines, mono annotations. Progressive
   illumination: answered path + next block light up in --accent.
   Panel (right on desktop, bottom on mobile) carries the full plain-
   language prompt and the answer controls.
   Tokens come from /styles.css; every var() carries a literal fallback
   so this file also stands alone. */

/* ---- stage layout ---- */

#fim-root { margin: 0 auto; max-width: var(--max-w, 1440px); }

.fim-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  align-items: stretch;
}

/* ---- the sheet ---- */

.fim-sheet-wrap {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  height: clamp(560px, 72vh, 860px);
  background: #EFEBE2;
  background-image:
    linear-gradient(rgba(10, 10, 11, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 10, 11, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid rgba(10, 10, 11, 0.35);
  border-radius: 2px;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.fim-sheet-wrap:active { cursor: grabbing; }

.fim-svg { display: block; width: 100%; height: 100%; }
#fim-world { will-change: transform; }

/* ---- zoom toolbar ---- */

.fim-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  gap: 4px;
}
.fim-zoom button {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  background: var(--bg-light, #F5F2EC);
  color: var(--bg-dark, #0A0A0B);
  border: 1px solid rgba(10, 10, 11, 0.45);
  border-radius: 2px;
  cursor: pointer;
}
.fim-zoom button:hover { border-color: var(--accent, #D97C20); color: var(--accent, #D97C20); }

/* ---- blocks ---- */

/* Every block is inspectable: click centers + zooms for reading.
   Clicking NEVER answers or rewinds (owner product decision) —
   answers live in the panel only. */
.fim-block { cursor: pointer; }

.fim-box {
  fill: #F7F4EC;
  stroke: rgba(10, 10, 11, 0.75);
  stroke-width: 1.5;
  transition: stroke 300ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
              fill 300ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
.fim-box-outer {                            /* terminal double border */
  fill: none;
  stroke: rgba(10, 10, 11, 0.75);
  stroke-width: 1.5;
  transition: stroke 300ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.fim-num {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 15px;
  font-weight: 700;
  fill: rgba(10, 10, 11, 0.85);
}
.fim-kind {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 10px;
  letter-spacing: 0.08em;
  fill: rgba(10, 10, 11, 0.55);
}
.fim-flag { fill: var(--accent, #D97C20); }  /* triangle note flag */

.fim-block-text {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 12.5px;
  line-height: 1.35;
  color: rgba(10, 10, 11, 0.88);
  padding: 30px 12px 22px;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.fim-block-text-in {
  /* Auto height + clamp: the box collapses to exactly 5 lines, so no 6th
     line can paint over the .fim-kind label (bug: ALK-001 block 3, 2026-09-04). */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* progressive illumination */
.fim-block.lit .fim-box { stroke: var(--accent, #D97C20); stroke-width: 2; }
.fim-block.lit .fim-box-outer { stroke: var(--accent, #D97C20); }
.fim-block.lit .fim-num { fill: var(--accent, #D97C20); }
.fim-block.active .fim-box,
.fim-block.terminal-active .fim-box {
  stroke: var(--accent, #D97C20);
  stroke-width: 3;
  fill: #FDF6EC;
}
.fim-block.active .fim-box-outer,
.fim-block.terminal-active .fim-box-outer { stroke: var(--accent, #D97C20); stroke-width: 2.5; }

/* Inspection is a temporary reading focus, not guided state. Keep it
   visually distinct from the orange walked/active path so clicking an
   arbitrary block cannot look like an answer or progress change. */
.fim-block.inspect .fim-box {
  stroke: #236B73;
  stroke-width: 3;
  fill: #E7F1EF;
  filter: drop-shadow(0 3px 5px rgba(10, 10, 11, 0.22));
}
.fim-block.inspect .fim-box-outer { stroke: #236B73; stroke-width: 2.5; }
.fim-block.inspect .fim-num { fill: #236B73; }
.fim-block.inspect .fim-kind { fill: #236B73; }
.fim-block.inspect.active .fim-box,
.fim-block.inspect.terminal-active .fim-box {
  stroke: var(--accent, #D97C20);
  fill: #FDF6EC;
}
.fim-block.inspect.active .fim-num,
.fim-block.inspect.terminal-active .fim-num { fill: var(--accent, #D97C20); }

/* ---- edges ---- */

.fim-edge {
  fill: none;
  stroke: rgba(10, 10, 11, 0.6);
  stroke-width: 1.5;
  transition: stroke 300ms var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}
.fim-edge-fallback { stroke-dasharray: 6 5; stroke: rgba(10, 10, 11, 0.4); }
.fim-edge.lit { stroke: var(--accent, #D97C20); stroke-width: 2.5; }

.fim-edge-label {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  fill: rgba(10, 10, 11, 0.8);
  paint-order: stroke;
  stroke: #EFEBE2;
  stroke-width: 4;
}
.fim-edge-label-fb { font-weight: 400; fill: rgba(10, 10, 11, 0.55); }

/* ---- title block (drawing corner stamp) ---- */

.fim-titleblock line,
.fim-titleblock rect { stroke: rgba(10, 10, 11, 0.75); stroke-width: 1.5; fill: none; }
.fim-titleblock text {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 10px;
  letter-spacing: 0.05em;
  fill: rgba(10, 10, 11, 0.7);
}
.fim-titleblock .fim-tb-big { font-size: 13px; font-weight: 700; fill: rgba(10, 10, 11, 0.9); }

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

.fim-panel {
  background: var(--bg-dark, #0A0A0B);
  color: rgba(245, 242, 236, 0.92);
  border: 1px solid rgba(245, 242, 236, 0.14);
  border-radius: 2px;
  padding: 22px 22px 26px;
  overflow-y: auto;
  max-height: clamp(560px, 72vh, 860px);
}
.fim-panel p { margin: 0 0 14px; font-size: 15.5px; line-height: 1.55; }

.fim-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(245, 242, 236, 0.14);
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.fim-panel-num { color: var(--accent, #D97C20); font-weight: 700; }
.fim-panel-code { color: rgba(245, 242, 236, 0.5); }

.fim-terminal-head {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent, #D97C20);
  border: 1.5px solid var(--accent, #D97C20);
  padding: 10px 12px;
  margin-bottom: 16px;
}

/* answers */
.fim-answers { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }
.fim-btn {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 18px;
  min-height: 44px;
  background: transparent;
  color: rgba(245, 242, 236, 0.92);
  border: 1.5px solid rgba(245, 242, 236, 0.45);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.fim-btn:hover { border-color: var(--accent, #D97C20); color: var(--accent, #D97C20); }
.fim-btn-yes { border-color: var(--accent, #D97C20); }
.fim-hint { font-size: 13px; color: rgba(245, 242, 236, 0.55); }

/* technical note */
.fim-note {
  margin: 0 0 14px;
  border-left: 2px solid var(--accent, #D97C20);
  padding: 2px 0 2px 12px;
}
.fim-note summary {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent, #D97C20);
  cursor: pointer;
  list-style: none;
}
.fim-note summary::-webkit-details-marker { display: none; }
.fim-note p { font-size: 13.5px; color: rgba(245, 242, 236, 0.7); margin: 8px 0 4px; }

/* verify block */
.fim-verify {
  border: 1px solid rgba(245, 242, 236, 0.2);
  padding: 10px 12px;
  margin: 0 0 14px;
}
.fim-verify-head {
  display: block;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(245, 242, 236, 0.6);
  margin-bottom: 6px;
}
.fim-verify p { font-size: 13.5px; margin: 0; color: rgba(245, 242, 236, 0.8); }

/* terminal reason — owner ruling 2026-09-01 (C4): detailed explanation
   under its own heading, distinct from the concise terminal text */
.fim-reason {
  border-left: 2px solid rgba(245, 242, 236, 0.3);
  padding: 2px 0 2px 12px;
  margin: 0 0 14px;
}
.fim-reason-head {
  display: block;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(245, 242, 236, 0.6);
  margin-bottom: 6px;
}
.fim-reason p { font-size: 13.5px; margin: 0; color: rgba(245, 242, 236, 0.8); }

/* refs */
.fim-refs { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.fim-ref {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12.5px;
  color: var(--accent, #D97C20);
  text-decoration: none;
}
.fim-ref:hover { text-decoration: underline; }

/* measure input */
.fim-measure { margin: 0 0 4px; }
.fim-measure label { display: block; font-size: 13px; color: rgba(245, 242, 236, 0.65); margin-bottom: 6px; }
.fim-measure-row { display: flex; gap: 8px; }
.fim-measure-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 14px;
  padding: 10px 12px;
  background: rgba(245, 242, 236, 0.06);
  color: rgba(245, 242, 236, 0.92);
  border: 1px solid rgba(245, 242, 236, 0.3);
  border-radius: 2px;
}
.fim-measure-row input.fim-bad { border-color: #C0392B; }

/* terminal feedback */
.fim-feedback { border-top: 1px solid rgba(245, 242, 236, 0.14); margin-top: 18px; padding-top: 14px; }
.fim-feedback-q { font-size: 14px; margin-bottom: 10px; }
.fim-feedback-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fim-btn-sm {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  background: transparent;
  color: rgba(245, 242, 236, 0.8);
  border: 1px solid rgba(245, 242, 236, 0.35);
  border-radius: 2px;
  cursor: pointer;
}
.fim-btn-sm:hover { border-color: var(--accent, #D97C20); color: var(--accent, #D97C20); }
.fim-feedback-mail { font-size: 12px; color: rgba(245, 242, 236, 0.55); }
.fim-feedback-mail:hover { color: var(--accent, #D97C20); }

/* back / restart */
.fim-back {
  display: block;
  margin-top: 18px;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.04em;
  background: none;
  border: none;
  padding: 4px 0;
  color: rgba(245, 242, 236, 0.55);
  cursor: pointer;
}
.fim-back:hover { color: var(--accent, #D97C20); }

/* ---- notices & fatal ---- */

.fim-notices { margin-top: 12px; }
.fim-notice {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12px;
  color: rgba(245, 242, 236, 0.7);
  border: 1px dashed rgba(245, 242, 236, 0.3);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.fim-fatal {
  border: 1.5px solid var(--accent, #D97C20);
  padding: 24px;
  max-width: 640px;
}
.fim-fatal p { font-size: 15px; line-height: 1.55; margin: 0 0 10px; }
.fim-fatal-code {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent, #D97C20);
  margin-bottom: 12px;
}

/* ---- mobile: option (a) — same sheet, auto-pan/zoom, panel below ---- */

@media (max-width: 900px) {
  .fim-stage { grid-template-columns: 1fr; }
  .fim-sheet-wrap { height: 48vh; min-height: 340px; }
  .fim-panel { max-height: none; }
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .fim-box, .fim-box-outer, .fim-edge, .fim-btn { transition: none; }
}

/* ---- print: the sheet is the document ---- */

@media print {
  .fim-panel, .fim-zoom, .fim-notices { display: none; }
  .fim-stage { display: block; }
  .fim-sheet-wrap { height: auto; overflow: visible; border: none; background: none; }
}
