/* ============================================================
   MB · BRAIN ;  state-of-the-art company brain (MacBook demo)
   Prefix: bd-  |  Accent: cyan --see (perception)
   Renders on the page-level fixed design stage (.mac-fit wrapper,
   components.css): 720×450 desktop, 520×325 under 980px viewport,
   scaled by main.js to fill .mac-screen. Base styles below are the
   720×450 geometry; the @media (max-width: 980px) block is the
   tighter 520×325 geometry. px units, stage-logical.
   Consumes tokens.css + base.css. Redefines nothing shared.
   ============================================================ */

.bd-app {
  position: absolute;
  inset: 0; /* fallback when no .mac-fit wrapper is applied */
  z-index: 1; /* below notch (40) and glare (50) */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font-mono);
  user-select: none;
}
/* subtle captured-screen scan lines over everything, under notch/glare */
.bd-app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: repeating-linear-gradient(var(--line) 0 1px, transparent 1px 4px);
  opacity: 0.13;
}

/* ---------- titlebar ---------- */
.bd-bar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.bd-dots { display: inline-flex; gap: 5px; flex: none; }
.bd-dots i { width: 8px; height: 8px; border-radius: 50%; }
.bd-dots i:nth-child(1) { background: var(--danger); opacity: 0.8; }
.bd-dots i:nth-child(2) { background: var(--warm);   opacity: 0.8; }
.bd-dots i:nth-child(3) { background: var(--act);    opacity: 0.8; }

.bd-live { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.bd-live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--see);
  position: relative;
  flex: none;
  box-shadow: 0 0 6px var(--see-glow);
}
.bd-live-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--see);
  animation: bd-ring 1.8s var(--ease-out) infinite;
}
@keyframes bd-ring {
  0%   { transform: scale(0.55); opacity: 0.9; }
  100% { transform: scale(1.6);  opacity: 0; }
}
.bd-live-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--see);
}
.bd-counter {
  margin-left: auto; /* right edge ;  clear of the top-center notch */
  font-size: 10px;
  color: var(--fg-dim);
  white-space: nowrap;
}
.bd-count { color: var(--fg-muted); }

/* ---------- main ---------- */
.bd-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

/* search field, rendered focused (cyan halo, live caret) */
.bd-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 13px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--see-soft), 0 0 14px -4px var(--see-glow);
}
.bd-search-ic { width: 15px; height: 15px; flex: none; color: var(--see); }
.bd-typed {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
}
.bd-q {
  font-size: 13px;
  line-height: 1;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
}
.bd-caret {
  display: inline-block;
  width: 2px;
  height: 16px;
  margin-left: 3px;
  background: var(--see);
  flex: none;
  animation: bd-blink 1.05s step-end infinite;
}
@keyframes bd-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* ---------- results ---------- */
.bd-results {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: opacity 0.5s var(--ease);
}
.bd-results--out { opacity: 0; } /* fade the old set, height stays */

.bd-card {
  /* 0 1 auto: if the stage geometry ever runs a few px short the three
     cards give up bottom padding evenly instead of the last one being
     chopped by the source strip. */
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out);
}
.bd-card--in { opacity: 1; transform: none; }

.bd-card-logo { width: 16px; height: 16px; flex: none; margin-top: 1px; object-fit: contain; }
.bd-card-body { flex: 1 1 auto; min-width: 0; }
.bd-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bd-card-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  color: var(--fg);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bd-score {
  flex: none;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  color: var(--see);
  background: var(--see-soft);
  border: 1px solid var(--see-glow);
  border-radius: var(--r-sm);
  padding: 2px 7px;
}
.bd-card-meta {
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bd-preview {
  margin-top: 5px;
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* top-result detection flash: detect-frame--see sized for the card.
   JS layers .detect-frame .detect-frame--see + these two bd- classes;
   only prefixed selectors are styled here. */
.bd-card--framed { --len: 10px; --thick: 2px; --inset: 0px; }
.bd-card--framed::after { transition: opacity 0.45s var(--ease); }
.bd-card--frameoff::after { opacity: 0; }

/* ---------- source strip ---------- */
.bd-strip {
  flex: none;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
}
.bd-strip-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.bd-strip-logos { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.bd-strip-logo { width: 14px; height: 14px; flex: none; object-fit: contain; opacity: 0.92; }
.bd-strip-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--fg-dim);
  white-space: nowrap;
}
.bd-strip-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--see); flex: none; }

/* ---------- 520×325 stage (page swaps stage size at 980px viewport) ---------- */
@media (max-width: 980px) {
  .bd-bar { height: 26px; gap: 8px; padding: 0 12px; }
  .bd-dots { gap: 4px; }
  .bd-dots i { width: 6px; height: 6px; }
  .bd-live { gap: 5px; margin-left: 2px; }
  .bd-live-dot { width: 5px; height: 5px; }
  .bd-live-label { font-size: 8.5px; }
  .bd-counter { font-size: 8.5px; }

  .bd-main { gap: 10px; padding: 10px 12px; }
  .bd-search { gap: 7px; height: 30px; padding: 0 10px; }
  .bd-search-ic { width: 12px; height: 12px; }
  .bd-q { font-size: 11px; }
  .bd-caret { height: 13px; margin-left: 2px; }

  .bd-results { gap: 8px; }
  .bd-card { gap: 8px; padding: 7px 10px; }
  .bd-card-logo { width: 13px; height: 13px; }
  .bd-card-top { gap: 8px; }
  .bd-card-title { font-size: 11.5px; }
  .bd-score { font-size: 8.5px; padding: 2px 5px; }
  .bd-card-meta { margin-top: 2px; font-size: 9.5px; }
  .bd-preview { margin-top: 4px; font-size: 9.5px; }
  .bd-card--framed { --len: 8px; --thick: 1.5px; }

  .bd-strip { height: 26px; gap: 10px; padding: 0 12px; }
  .bd-strip-label { font-size: 8px; }
  .bd-strip-logos { gap: 10px; }
  .bd-strip-logo { width: 12px; height: 12px; }
  .bd-strip-status { gap: 4px; font-size: 8px; }
  .bd-strip-dot { width: 4px; height: 4px; }
}

/* ---------- reduced motion: static query 1 end-state ---------- */
@media (prefers-reduced-motion: reduce) {
  .bd-caret { display: none; }
  .bd-card { opacity: 1; transform: none; }
  .bd-live-dot::after { display: none; } /* frozen ring reads as a stray outline */
}
