/* BB Tech Tools - "In the Wild" Field Report callout + Declassify case-file dialog.
   Pair with /js/bb-in-the-wild.js. Fonts come from the site (font-standard.css); nothing is loaded here.
   Colors follow theme tokens (theme-tokens.css) with hard Cyber fallbacks.
   Exhibits (pre output) are "scenes": they keep Cyber colors in every theme (owner rule 2026-10-25). */

.bb-itw, .bb-itw-dialog {
  --itw-surface: var(--theme-surface, #0f161b);
  --itw-inset: var(--theme-inset, #05080a);
  --itw-ink: var(--theme-ink, #ECEFF1);
  --itw-muted: var(--theme-muted, #90A4AE);
  --itw-border: var(--theme-border, #546E7A);
  --itw-focus: var(--theme-focus, #FFD600);
  --itw-red: var(--theme-error, var(--bb-red, #FF5252));
  --itw-green: var(--theme-success, var(--bb-kelly, #00c853));
  --itw-amber: var(--theme-warning, #FFD600);
  --itw-teal: var(--bb-teal, #1DE9B6);
  --itw-heading: var(--theme-font-heading, 'Ultra', Georgia, serif);
  --itw-body: var(--theme-font-body, 'Geist', sans-serif);
  --itw-code: var(--theme-font-code, 'JetBrains Mono', monospace);
  --itw-accent: var(--itw-green);
}
/* Light (patriotic) theme: darker accents that keep contrast on pale surfaces. */
[data-bb-theme="patriotic"] .bb-itw, [data-bb-theme="patriotic"] .bb-itw-dialog { --itw-teal: #1f5f66; }

.bb-itw--red { --itw-accent: var(--itw-red); }
.bb-itw--green { --itw-accent: var(--itw-green); }
.bb-itw--amber { --itw-accent: var(--itw-amber); }
.bb-itw--teal { --itw-accent: var(--itw-teal); }

/* ---------- On-page card ---------- */
.bb-itw {
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  margin: 24px 0;
  padding: 18px 20px 18px 22px;
  background: var(--itw-surface);
  color: var(--itw-ink);
  border: 1px solid var(--itw-border);
  border-left: 5px solid var(--itw-accent);
  border-radius: 8px;
  font-family: var(--itw-body);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.bb-itw *, .bb-itw-dialog * { box-sizing: border-box; }
.bb-itw-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bb-itw .bb-itw-badge {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--itw-accent);
}
.bb-itw-badge-kicker { color: var(--itw-ink); }
.bb-itw .bb-itw-badge-type { color: var(--itw-accent); }
.bb-itw-badge-sep { color: var(--itw-muted); }
.bb-itw .bb-itw-title {
  margin: 0 0 8px;
  font-family: var(--itw-heading);
  font-size: clamp(19px, 2.2vw, 23px);
  line-height: 1.25;
  color: var(--itw-ink);
}
.bb-itw p { margin: 0 0 10px; line-height: 1.6; color: var(--itw-ink); }
.bb-itw .bb-itw-concept strong, .bb-itw-dialog .bb-itw-concept strong { color: var(--itw-accent); }
.bb-itw-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-top: 12px; }
.bb-itw .bb-itw-cost, .bb-itw-dialog .bb-itw-cost {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--itw-amber);
  border-radius: 999px;
  color: var(--itw-amber);
  background: transparent;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}
.bb-itw-open, .bb-itw-reveal, .bb-itw-close {
  min-height: 44px;
  padding: 10px 18px;
  border: 2px solid var(--itw-accent);
  border-radius: 6px;
  background: transparent;
  color: var(--itw-ink);
  font-family: var(--itw-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.bb-itw-open { margin-left: auto; text-transform: uppercase; }
.bb-itw-open-arrow { color: var(--itw-accent); }
.bb-itw-open:hover, .bb-itw-reveal:hover, .bb-itw-close:hover { background: color-mix(in srgb, var(--itw-accent) 18%, transparent); }
.bb-itw-open:focus-visible, .bb-itw-reveal:focus-visible, .bb-itw-close:focus-visible,
.bb-itw-dialog a:focus-visible, .bb-itw-file-title:focus-visible {
  outline: 3px solid var(--itw-focus);
  outline-offset: 3px;
}

/* Inside the Mission Brief / Debrief pop-up (bb-page-header.js). The pop-up styles bare headings (uppercase, accent
   color, left rule), paragraphs and strong. These rules are more specific than the pop-up's, so the card keeps its
   own look. The few !important flags only answer !important rules upstream (lab-audit.css sets p/li color and size,
   theme-learning.css sets strong color); everything else wins on specificity alone. */
.bb-mission-body aside.bb-itw .bb-itw-title {
  margin: 0 0 8px;
  padding-left: 0;
  border-left: 0;
  font-family: var(--itw-heading);
  font-size: clamp(19px, 2.2vw, 23px);
  line-height: 1.25;
  letter-spacing: normal;
  text-transform: none;
  color: var(--itw-ink);
}
html body .bb-mission-body aside.bb-itw :is(p, li) { color: var(--itw-ink) !important; font-size: 16px !important; line-height: 1.6 !important; }
html body .bb-mission-body aside.bb-itw p.bb-itw-badge { color: var(--itw-accent) !important; font-size: 13px !important; line-height: 1.4 !important; }
html body .bb-mission-body aside.bb-itw p.bb-itw-cost { color: var(--itw-amber) !important; font-size: 15px !important; line-height: 1.3 !important; }
html body .bb-mission-body aside.bb-itw .bb-itw-concept strong { color: var(--itw-accent) !important; }

/* Exhibits ("what it looks like" output) keep Cyber colors in every theme. */
.bb-itw .bb-itw-sample, .bb-itw-dialog .bb-itw-sample {
  margin: 10px 0 0;
  padding: 14px 16px;
  max-width: 100%;
  overflow-x: auto;
  background: #05080a;
  color: #ECEFF1;
  border: 1px solid #546E7A;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre;
  tab-size: 4;
}

/* ---------- Dialog (declassified case file) ---------- */
html.bb-itw-locked, html.bb-itw-locked body { overflow: hidden; }
.bb-itw-dialog {
  width: min(780px, calc(100vw - 32px));
  max-width: none;
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--itw-border);
  border-radius: 10px;
  background: var(--itw-surface);
  color: var(--itw-ink);
  font-family: var(--itw-body);
  font-weight: 500;
  overflow: hidden;
  overflow: clip; /* never let the dialog itself scroll; only .bb-itw-file-body scrolls */
}
.bb-itw-dialog[open] { display: flex; flex-direction: column; }
.bb-itw-dialog::backdrop { background: rgba(2, 5, 7, .78); }
.bb-itw-sheet {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  flex: 1 1 auto;
  border-top: 5px solid var(--itw-accent);
  animation: bbItwIn .18s ease-out;
}
@keyframes bbItwIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bb-itw-sheet { animation: none; } }

.bb-itw-file-head {
  position: relative;
  flex: 0 0 auto;
  padding: 18px 24px 16px;
  padding-right: 128px;
  border-bottom: 1px dashed var(--itw-border);
  background: var(--itw-inset);
}
.bb-itw-dialog .bb-itw-case {
  margin: 0 0 8px;
  font-family: var(--itw-code);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--itw-muted);
  overflow-wrap: anywhere;
}
.bb-itw-dialog .bb-itw-file-title {
  margin: 0 0 10px;
  font-family: var(--itw-heading);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.2;
  color: var(--itw-ink);
}
.bb-itw-stamp {
  position: absolute;
  top: 74px;
  right: 22px;
  padding: 4px 10px;
  border: 3px double var(--itw-red);
  border-radius: 4px;
  color: var(--itw-red);
  font-family: var(--itw-code);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .78;
  transform: rotate(-8deg);
  pointer-events: none;
  user-select: none;
}
.bb-itw-close { position: absolute; top: 12px; right: 14px; min-width: 44px; padding: 8px 12px; border-color: var(--itw-border); }

.bb-itw-file-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 24px 26px; }
.bb-itw-file-body:focus { outline: none; }
.bb-itw-brief { padding-top: 14px; }
.bb-itw-dialog p { margin: 0 0 10px; line-height: 1.65; color: var(--itw-ink); }
.bb-itw-sec { padding-top: 18px; margin-top: 16px; border-top: 1px solid color-mix(in srgb, var(--itw-border) 55%, transparent); }
.bb-itw-brief + .bb-itw-sec { border-top-color: var(--itw-border); }
.bb-itw-dialog .bb-itw-sec-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--itw-heading);
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: .02em;
  color: var(--itw-ink);
}
.bb-itw-dialog .bb-itw-sec-title::before {
  content: "";
  flex: 0 0 auto;
  width: 14px;
  height: 3px;
  background: var(--itw-accent);
}

/* Timeline: vertical, dated */
.bb-itw-timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 2px solid var(--itw-border); }
.bb-itw-timeline li { position: relative; margin: 0 0 14px; }
.bb-itw-timeline li:last-child { margin-bottom: 0; }
.bb-itw-timeline li::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--itw-surface);
  border: 3px solid var(--itw-accent);
}
.bb-itw-when { display: block; margin-bottom: 2px; font-family: var(--itw-code); font-size: 14px; font-weight: 700; color: var(--itw-accent); letter-spacing: .04em; }
.bb-itw-timeline p { margin: 0; }

/* Countermeasures + objective chips */
.bb-itw-counter { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bb-itw-counter li { padding: 10px 12px; border: 1px solid var(--itw-border); border-radius: 6px; background: var(--itw-inset); line-height: 1.55; }
.bb-itw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bb-itw-chip {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--itw-green);
  border-radius: 999px;
  color: var(--itw-green);
  font-family: var(--itw-code);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

/* Damage assessment table */
.bb-itw-table-wrap { max-width: 100%; overflow-x: auto; }
.bb-itw-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.bb-itw-table th, .bb-itw-table td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--itw-border); color: var(--itw-ink); }
.bb-itw-table thead th { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--itw-muted); font-weight: 800; }
.bb-itw-table .bb-itw-amount { color: var(--itw-amber); font-weight: 800; white-space: nowrap; }
.bb-itw-dialog .bb-itw-note { margin-top: 10px; font-size: 15px; color: var(--itw-muted); }

/* Your Call */
.bb-itw-dialog .bb-itw-question { font-weight: 700; }
.bb-itw-reveal { margin-top: 4px; }
.bb-itw-answer { margin-top: 12px; padding: 12px 14px; border-left: 4px solid var(--itw-green); background: var(--itw-inset); border-radius: 0 6px 6px 0; }
.bb-itw-answer[hidden] { display: none; }
.bb-itw-dialog .bb-itw-answer-label { margin-bottom: 4px; font-family: var(--itw-code); font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--itw-green); }
.bb-itw-answer:focus { outline: none; }

/* Links */
.bb-itw-links { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.5; }
.bb-itw-dialog a { color: var(--itw-ink); text-decoration-color: var(--itw-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.bb-itw-dialog a:hover { color: var(--itw-accent); }
.bb-itw-links--internal a { text-decoration-color: var(--itw-green); }
.bb-itw-publisher { color: var(--itw-muted); }
.bb-itw-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Small screens: card tightens, dialog becomes a full-height sheet ---------- */
@media (max-width: 600px) {
  .bb-itw { padding: 16px 14px 16px 16px; }
  .bb-itw-open { margin-left: 0; width: 100%; }
  .bb-itw-foot { flex-direction: column; align-items: stretch; }
  .bb-itw .bb-itw-cost { align-self: flex-start; }
  .bb-itw-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  /* On a phone the whole sheet scrolls (the case header scrolls away); Close stays pinned top-right. */
  .bb-itw-sheet { max-height: none; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  .bb-itw-file-head { padding: 14px 16px 14px; padding-right: 16px; }
  .bb-itw-stamp { position: static; display: inline-block; margin: 2px 0 10px 4px; font-size: 13px; transform: rotate(-4deg); }
  .bb-itw-close { position: fixed; top: 10px; right: 10px; z-index: 2; background: var(--itw-inset); }
  .bb-itw-file-body { flex: 0 0 auto; overflow: visible; padding: 4px 16px 32px; }
  .bb-itw-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .bb-itw-table, .bb-itw-table tbody, .bb-itw-table tr, .bb-itw-table th, .bb-itw-table td { display: block; width: 100%; }
  .bb-itw-table tr { padding: 8px 0; border-bottom: 1px solid var(--itw-border); }
  .bb-itw-table th, .bb-itw-table td { border: 0; padding: 3px 0; }
  .bb-itw-table tbody [data-label]::before { content: attr(data-label) ": "; color: var(--itw-muted); font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
  .bb-itw-table .bb-itw-amount { white-space: normal; }
}
