/* ==========================================================================
   Terminal-style draggable window for the home page. Fully namespaced under
   .bbg so it does not touch the rest of the site.
   ========================================================================== */
.bbg {
  --t-amber:  #ff9d1c;
  --t-field:  #f2a41c;
  --t-red:    #a51212;
  --t-gray:   #2b2b2b;
  --t-blue:   #1d4f9e;
  --t-purple: #5c2a90;
  --t-line:   #3c3c3c;

  position: relative;
  z-index: 50;
  width: 740px;
  max-width: 100%;
  background: #000;
  color: #e6e6e6;
  font: 13px/1.25 "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  border: 1px solid #555;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px #000;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
.bbg.is-floating { position: absolute; z-index: 9999; }
.bbg.is-dragging { box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px #000; }

.bbg * { box-sizing: border-box; }
.bbg i { font-style: normal; }

/* window title bar (the drag handle) */
.bbg-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(#2c2c2c, #1b1b1b);
  border-bottom: 1px solid #000;
  padding: 3px 6px;
  font-size: 11px;
  color: #bdbdbd;
  cursor: grab;
  touch-action: none;
}
.bbg.is-dragging .bbg-titlebar { cursor: grabbing; }
.bbg-panelno {
  background: var(--t-amber);
  color: #000;
  font-weight: bold;
  padding: 0 5px;
  font-size: 10px;
}
.bbg-titletext { flex: 1; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bbg-winbtns i { display: inline-block; width: 16px; text-align: center; color: #999; }

/* red menu bar */
.bbg-menubar {
  display: flex;
  background: linear-gradient(#bf1b1b, #8c0d0d);
}
.bbg-menubar span {
  flex: 1;
  text-align: center;
  padding: 3px 0;
  font-size: 13px;
  color: #fff;
  border-right: 1px solid #5a0707;
  white-space: nowrap;
}
.bbg-menubar span:last-child { border-right: 0; flex: 1.3; }

/* gray toolbar */
.bbg-toolbar { display: flex; background: #3b3b3b; border-bottom: 1px solid #111; }
.bbg-toolbar span {
  flex: 1;
  text-align: center;
  padding: 2px 0;
  font-size: 12px;
  color: #eee;
  border-right: 1px solid #1e1e1e;
}
.bbg-toolbar span:last-child { border-right: 0; }

.bbg-row { display: flex; align-items: center; gap: 6px; padding: 2px 6px; white-space: nowrap; overflow: hidden; }
.bbg-spacer { flex: 1; }
.bbg-h { color: var(--t-amber); font-size: 13px; }
.bbg-field {
  display: inline-block;
  background: var(--t-field);
  color: #000;
  padding: 0 6px;
  min-width: 70px;
  line-height: 16px;
  white-space: nowrap;
}
.bbg-field-sm { min-width: 40px; }
.bbg-field-purple { background: var(--t-purple); color: #fff; }

.bbg-tabs { display: flex; background: #000; border-bottom: 1px solid #666; padding: 2px 4px 0; overflow: hidden; }
.bbg-tabs span {
  padding: 2px 9px;
  margin-right: 2px;
  color: #ccc;
  background: #2b2b2b;
  border: 1px solid #444;
  border-bottom: 0;
  font-size: 12px;
  white-space: nowrap;
}
.bbg-tabs span.on { background: #a3a3a3; color: #000; }

.bbg-section { background: var(--t-blue); color: #fff; padding: 2px 8px; font-size: 12px; }

/* body: chart + panel */
.bbg-body { display: flex; border-top: 1px solid var(--t-line); }
.bbg-chart { flex: 1 1 auto; min-width: 0; border-right: 1px solid var(--t-line); background: #000; }
.bbg-chartbar { display: flex; background: #2b2b2b; border-bottom: 1px solid #111; }
.bbg-chartbar span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: #bbb;
  padding: 1px 0;
  border-right: 1px solid #1a1a1a;
}
.bbg-chartbar span.on { background: var(--t-blue); color: #fff; }
.bbg-chart canvas { display: block; width: 100%; height: 250px; cursor: move; touch-action: none; }

.bbg-panel { flex: 0 0 255px; width: 255px; }
.bbg-panel h4, .bbg-results h4 {
  margin: 0;
  background: #3b3b3b;
  color: #fff;
  font-weight: normal;
  font-size: 13px;
  padding: 1px 6px;
}
.bbg-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  padding: 3px 6px;
  align-items: center;
  line-height: 1.15;
}
.bbg-kv-tight { padding-top: 0; }
.bbg .k { color: var(--t-amber); font-size: 13px; white-space: nowrap; }
.bbg .v { color: #fff; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bbg .v.field { background: var(--t-field); color: #000; padding: 0 4px; line-height: 15px; }
.bbg .radio {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid #7cb8ff;
  vertical-align: -1px;
  margin-right: 4px;
}
.bbg .radio.on { background: #3a8fff; box-shadow: inset 0 0 0 2px #000; }
.bbg .check {
  display: inline-block;
  width: 10px; height: 10px;
  background: #3a8fff;
  vertical-align: -1px;
  margin-right: 5px;
  position: relative;
}
.bbg .check::after {
  content: "";
  position: absolute;
  left: 3px; top: 0;
  width: 3px; height: 6px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* results */
.bbg-results { border-top: 1px solid var(--t-line); }
.bbg-grid4 {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 2px 10px;
  padding: 3px 6px;
  align-items: center;
  line-height: 1.15;
}
.bbg-btn { background: #555; color: #fff; padding: 0 8px; font-size: 12px; line-height: 16px; display: inline-block; }

/* status bar */
.bbg-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #151515;
  border-top: 1px solid #333;
  padding: 2px 6px;
  font-size: 11px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}
.bbg-status .up { color: #2ecc40; }
.bbg-status .dn { color: #ff4136; }
#bbg-clock::after { content: "\2588"; margin-left: 4px; animation: bbg-blink 1s steps(1) infinite; color: var(--t-amber); }
@keyframes bbg-blink { 50% { opacity: 0; } }

@media (max-width: 720px) {
  /* Compact window: chart + a short stats strip, decorative rows hidden. */
  .bbg { width: 100%; font-size: 11px; }
  .bbg-titlebar { cursor: default; font-size: 10px; }
  .bbg-menubar span { font-size: 11px; padding: 2px 0; }
  .bbg-menubar span:last-child { display: none; }
  .bbg-toolbar, .bbg-deal, .bbg-chartbar, .bbg-results, .bbg-kv-tight, .bbg-opt,
  .bbg-tabs, .bbg-row, .bbg-section { display: none; }   /* mobile: title, menu, chart, stats, status */
  .bbg-tabs span { padding: 2px 6px; font-size: 11px; }
  .bbg-row .bbg-field { min-width: 0; }
  .bbg-field-purple { overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
  .bbg-h { font-size: 11px; }

  .bbg-body { flex-direction: column; }
  .bbg-chart { border-right: 0; border-bottom: 1px solid var(--t-line); }
  .bbg-chart canvas { height: 210px; }

  .bbg-panel { width: auto; flex: none; }
  .bbg-panel h4 { font-size: 11px; padding: 1px 6px; }
  /* hide "Calibration Parameters" and its rows */
  .bbg-panel h4:nth-of-type(2), .bbg-panel h4:nth-of-type(2) ~ .bbg-kv { display: none; }
  .bbg-kv { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 3px 8px; padding: 4px 6px; }
  .bbg .v { overflow: hidden; text-overflow: ellipsis; }
  .bbg .k { font-size: 11px; }
  .bbg .v.field { line-height: 14px; }

  .bbg-status { font-size: 10px; }
  .bbg-status #bbg-msg { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #bbg-clock::after { animation: none; }
}
