/* =============================================================================
 * FROM FIRE TO ORBIT — Reboot Phase 1
 * css/blueprint.css  ·  the unified 2-D blueprint builder shell
 * ===========================================================================*/

:root {
  --bp-bg:        #0a1830;
  --bp-panel:     #0f2445;
  --bp-panel-2:   #12294f;
  --bp-line:      rgba(120,180,255,0.16);
  --bp-ink:       #e9f1ff;
  --bp-ink-dim:   #9db4d8;
  --bp-accent:    #5bd6ff;
  --bp-go:        #5fe0a8;
  --bp-no:        #ff8a7a;
  --bp-struct:    #c79a6a;
  --bp-prop:      #e0765a;
  --bp-aero:      #63b6e0;
  --bp-payload:   #7fc27e;
  --bp-radius:    10px;
  --bp-font:      "Sarabun", system-ui, -apple-system, sans-serif;
  --bp-mono:      "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body.bp-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, #14315e 0%, transparent 60%),
    var(--bp-bg);
  color: var(--bp-ink);
  font-family: var(--bp-font);
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---------------------------------------------------------------*/
.bp-top {
  display: flex; align-items: baseline; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--bp-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
.bp-top h1 {
  margin: 0; font-size: 18px; letter-spacing: 0.14em; font-weight: 700;
  text-transform: uppercase;
}
.bp-top .bp-era {
  font-family: var(--bp-mono); font-size: 11px; color: var(--bp-accent);
  border: 1px solid rgba(91,214,255,0.4); border-radius: 999px;
  padding: 2px 10px; letter-spacing: 0.08em;
}
.bp-top .bp-tagline { color: var(--bp-ink-dim); font-size: 12px; margin-left: auto; }

.bp-eras { display: flex; gap: 6px; }
.bp-era-btn {
  font-family: var(--bp-font); font-size: 11.5px;
  color: var(--bp-ink-dim);
  background: var(--bp-panel-2);
  border: 1px solid var(--bp-line);
  border-radius: 999px; padding: 3px 12px; cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.bp-era-btn:hover { color: var(--bp-ink); border-color: rgba(91,214,255,0.4); }
.bp-era-btn.is-on {
  color: var(--bp-bg); background: var(--bp-accent);
  border-color: var(--bp-accent); font-weight: 700;
}

/* ---- layout --------------------------------------------------------------- */
.bp-stage {
  display: grid;
  grid-template-columns: 232px 1fr 268px;
  gap: 14px;
  padding: 14px 20px;
  align-items: stretch;
  min-height: calc(100vh - 210px);
}
@media (max-width: 1040px) {
  .bp-stage { grid-template-columns: 1fr; }
  .bp-canvas-wrap { min-height: 52vh; }
}

.bp-col {
  background: var(--bp-panel);
  border: 1px solid var(--bp-line);
  border-radius: var(--bp-radius);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
}
.bp-col h2 {
  margin: 0; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--bp-ink-dim); font-weight: 700;
}

/* ---- parts rail --------------------------------------------------------- */
.bp-rail { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bp-part {
  --cat: #888;
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0) 60%),
    var(--bp-panel-2);
  border: 1px solid var(--bp-line);
  border-left: 3px solid var(--cat);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--bp-ink);
  cursor: grab;
  font-family: var(--bp-font);
  transition: transform .16s cubic-bezier(.2,.9,.25,1),
              background .16s ease, border-color .16s ease, box-shadow .16s ease;
  will-change: transform;
  touch-action: none;
}
/* the category rail lights up on hover */
.bp-part::before {
  content: ""; position: absolute; left: -3px; top: 0; bottom: 0; width: 3px;
  background: var(--cat); border-radius: 3px;
  box-shadow: 0 0 0 rgba(0,0,0,0);
  transition: box-shadow .18s ease;
}
.bp-part:hover {
  background:
    linear-gradient(180deg, rgba(120,200,255,0.10), rgba(255,255,255,0) 60%),
    #163257;
  border-color: rgba(91,214,255,0.55);
  transform: translateX(4px) scale(1.02);
  box-shadow: -2px 0 18px -6px rgba(91,214,255,0.5),
              0 6px 20px -10px rgba(0,0,0,0.6);
}
.bp-part:hover::before { box-shadow: 0 0 12px 1px var(--cat); }
.bp-part:hover .bp-part-ic { transform: scale(1.14) translateY(-1px); }
.bp-part:hover .bp-part-nm { color: #fff; }
.bp-part:active { cursor: grabbing; transform: translateX(1px) scale(0.975); box-shadow: none; }
.bp-part:focus-visible { outline: 2px solid var(--bp-accent); outline-offset: 2px; }
.bp-part-ic {
  font-size: 22px; line-height: 1; width: 26px; text-align: center;
  transition: transform .16s cubic-bezier(.2,.9,.25,1);
}
/* storybook silhouette thumbnail (Phase 25) */
.bp-part-thumb {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 8px;
  background:
    radial-gradient(120% 120% at 30% 25%, rgba(255,255,255,0.06), rgba(0,0,0,0.12)),
    color-mix(in srgb, var(--cat) 12%, #0e2038);
  border: 1px solid color-mix(in srgb, var(--cat) 35%, var(--bp-line));
  transition: transform .16s cubic-bezier(.2,.9,.25,1),
              box-shadow .16s ease, border-color .16s ease;
}
.bp-part:hover .bp-part-thumb {
  transform: scale(1.08) translateY(-1px);
  border-color: color-mix(in srgb, var(--cat) 65%, #fff);
  box-shadow: 0 0 14px -3px color-mix(in srgb, var(--cat) 70%, transparent);
}
.bp-part-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bp-part-nm { font-size: 13.5px; font-weight: 600; transition: color .16s ease; }
.bp-part-mt { font-size: 10.5px; color: var(--bp-ink-dim); font-family: var(--bp-mono); }

@media (prefers-reduced-motion: reduce) {
  .bp-part, .bp-part-ic { transition: background .12s ease, border-color .12s ease; }
  .bp-part:hover, .bp-part:active { transform: none; }
  .bp-part:hover .bp-part-ic { transform: none; }
}

/* ---- canvas ----------------------------------------------------------------*/
.bp-canvas-wrap {
  position: relative;
  background:
    radial-gradient(760px 420px at 50% -8%, rgba(91,214,255,0.10), transparent 65%),
    var(--bp-panel);
  border: 1px solid var(--bp-line);
  border-radius: var(--bp-radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: inset 0 1px 0 rgba(120,200,255,0.06);
}
/* Phase 22 — a faint studio vignette on the grid, matching the Phase 21
   Assembly Bay's glass aesthetic, without ever dulling the grid itself */
.bp-canvas-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 90px 14px rgba(3,8,20,0.35);
}
#bp-canvas { flex: 1; width: 100%; height: 100%; display: block; cursor: crosshair; }

.bp-canvas-tools {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  display: flex; gap: 6px;
}
.bp-canvas-tools button {
  background: rgba(10,24,48,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--bp-line);
  color: var(--bp-ink);
  border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--bp-mono);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.bp-canvas-tools button:hover { border-color: var(--bp-accent); color: var(--bp-accent); transform: translateY(-1px); }
.bp-canvas-tools .bp-tool-accent {
  border-color: rgba(91,214,255,0.5); color: #bfefff;
  background: rgba(33,80,127,0.55);
}
.bp-canvas-tools .bp-tool-accent:hover { border-color: var(--bp-accent); color: #fff; }

.bp-legend {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--bp-mono); font-size: 10px; color: var(--bp-ink-dim);
  background: rgba(10,24,48,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--bp-line);
  border-radius: 7px; padding: 6px 9px;
}
.bp-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ---- telemetry -----------------------------------------------------------*/
.bp-telem { margin: 0; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.bp-telem > div {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; padding: 3px 0;
  border-bottom: 1px dashed rgba(120,180,255,0.10);
  animation: bp-telem-in .26s cubic-bezier(.2,.9,.25,1);
}
@keyframes bp-telem-in {
  from { opacity: 0; transform: translateX(4px); }
  to   { opacity: 1; transform: translateX(0); }
}
.bp-telem dt { color: var(--bp-ink-dim); margin: 0; }
.bp-telem dd { margin: 0; font-family: var(--bp-mono); text-align: right; }
/* TWR glow — same red/amber/green thresholds as the 3D Assembly Bay's
   Telemetry Deck (Phase 21), so the two panels read as one system. */
.bp-twr { font-family: inherit; }
.bp-twr.bad  { color: var(--bp-no);  text-shadow: 0 0 10px rgba(255,138,122,0.6); animation: bp-twr-warn .9s ease-in-out infinite; }
.bp-twr.warn { color: #ffce40; text-shadow: 0 0 8px rgba(255,206,64,0.5); }
.bp-twr.good { color: var(--bp-go);  text-shadow: 0 0 10px rgba(95,224,168,0.6); }
@keyframes bp-twr-warn { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.bp-verdict {
  margin: 6px 0 0; text-align: center; font-weight: 700; font-size: 13px;
  padding: 7px; border-radius: 8px;
}
.bp-verdict.ok { background: rgba(95,224,168,0.14); color: var(--bp-go); }
.bp-verdict.no { background: rgba(255,138,122,0.12); color: var(--bp-no); }
@media (prefers-reduced-motion: reduce) {
  .bp-telem > div { animation: none; }
  .bp-twr.bad { animation: none; }
}

/* ---- status strip -------------------------------------------------------- */
.bp-status {
  margin: 0 20px; padding: 9px 14px;
  background: var(--bp-panel-2);
  border: 1px solid var(--bp-line);
  border-radius: 8px;
  font-family: var(--bp-mono); font-size: 12px; color: var(--bp-ink-dim);
}

/* ---- physics stub panel ------------------------------------------------- */
.bp-sim {
  margin: 14px 20px 24px;
  background: var(--bp-panel);
  border: 1px solid var(--bp-line);
  border-radius: var(--bp-radius);
  padding: 14px 16px;
}
.bp-sim-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bp-sim-head h2 {
  margin: 0; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--bp-ink-dim);
}
.bp-btn {
  background: linear-gradient(180deg, #2a7d5c, #1d5f45);
  border: 1px solid rgba(95,224,168,0.5);
  color: #eafff5; border-radius: 8px; padding: 8px 16px;
  font-family: var(--bp-font); font-weight: 700; font-size: 13px; cursor: pointer;
}
.bp-btn:hover { filter: brightness(1.12); }
.bp-btn[disabled] { opacity: 0.4; cursor: not-allowed; filter: none; }

.bp-sim-out {
  margin-top: 12px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.bp-stat {
  background: var(--bp-panel-2); border: 1px solid var(--bp-line);
  border-radius: 8px; padding: 9px 11px;
}
.bp-stat span { display: block; font-size: 10.5px; color: var(--bp-ink-dim); font-family: var(--bp-mono); letter-spacing: 0.06em; }
.bp-stat b { font-size: 18px; font-family: var(--bp-mono); }
#bp-trace { width: 100%; height: 120px; margin-top: 10px; display: block;
  background: var(--bp-bg); border: 1px solid var(--bp-line); border-radius: 8px; }
.bp-sim-note { margin: 8px 0 0; font-size: 11px; color: var(--bp-ink-dim); }

/* ---- centre column: the pure 2D drafting board ----------------------- */
.bp-center { display: flex; flex-direction: column; min-height: 0; }
.bp-center .bp-canvas-wrap { flex: 1 1 0; min-height: 340px; }
.bp-preview-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--bp-ink-dim); font-size: 12px; font-family: var(--bp-mono);
  pointer-events: none;   /* Phase 21: never let this label eat clicks meant for the ghost part */
}
.bp-preview-empty[hidden] { display: none; }

/* ---- flight events + diagnostics ------------------------------------- */
.bp-analysis {
  margin-top: 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 820px) { .bp-analysis { grid-template-columns: 1fr; } }
.bp-analysis section {
  background: var(--bp-panel-2); border: 1px solid var(--bp-line);
  border-radius: 8px; padding: 10px 12px;
}
.bp-analysis h3 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--bp-ink-dim);
}
.bp-events { list-style: none; margin: 0; padding: 0; }
.bp-events li {
  display: grid; grid-template-columns: 58px 1fr; gap: 8px;
  padding: 4px 0; font-size: 12px;
  border-bottom: 1px dashed rgba(120,180,255,0.10);
}
.bp-events .bp-ev-t { font-family: var(--bp-mono); color: var(--bp-accent); text-align: right; }
.bp-events .bp-ev-type { font-weight: 700; font-size: 10px; letter-spacing: 0.06em; color: var(--bp-ink-dim); }

.bp-diag { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bp-diag li {
  display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: start;
  font-size: 12px;
}
.bp-diag .bp-chip {
  font-family: var(--bp-mono); font-size: 9.5px; font-weight: 700;
  text-align: center; border-radius: 5px; padding: 2px 0; height: fit-content;
}
.bp-chip.OK   { background: rgba(95,224,168,0.16);  color: var(--bp-go); }
.bp-chip.WARN { background: rgba(255,206,64,0.16);  color: #ffce40; }
.bp-chip.FAIL { background: rgba(255,138,122,0.16); color: var(--bp-no); }
.bp-diag .bp-diag-msg { font-weight: 600; }
.bp-diag .bp-diag-detail { display: block; font-size: 10.5px; color: var(--bp-ink-dim); font-family: var(--bp-mono); margin-top: 1px; }

/* ---- misc --------------------------------------------------------------- */
.bp-foot {
  padding: 14px 20px 30px; color: var(--bp-ink-dim); font-size: 11px;
  border-top: 1px solid var(--bp-line);
}
.bp-foot a { color: var(--bp-accent); }
.bp-foot code { background: var(--bp-panel-2); padding: 1px 5px; border-radius: 4px; }
