/* ==========================================================================
   biometal XPD co-fold viewer — hand-written dark scientific theme
   Agent B scope only. No framework. No reset library.
   ========================================================================== */

:root {
  --bg-0:        #0a0d12;
  --bg-1:        #0f141b;
  --bg-2:        #151b24;
  --bg-3:        #1c2430;
  --line:        #232c3b;
  --line-soft:   #1a212c;
  --fg:          #d7dee8;
  --fg-dim:      #9aa5b4;
  --fg-mute:     #5c6777;
  --accent:      #5fd2c8;
  --accent-dim:  #2a7a73;
  --ok:          #47c97a;
  --ok-bg:       rgba(71, 201, 122, 0.09);
  --warn:        #e2b14a;
  --warn-bg:     rgba(226, 177, 74, 0.10);
  --fail:        #e5616b;
  --fail-bg:     rgba(229, 97, 107, 0.10);
  --skip:        #6b7687;
  --skip-bg:     rgba(107, 118, 135, 0.10);

  --font-sans:  ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono:  ui-monospace, "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;

  --radius-s:   4px;
  --radius-m:   7px;
  --radius-l:   11px;

  --shadow-soft: 0 1px 2px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(95,210,200,0.04), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(95,210,200,0.03), transparent 60%),
    var(--bg-0);
}

/* ---------- Top header ---------- */

.top-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: baseline;
}

#title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  margin: 0;
}

#title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--accent);
}

#subtitle {
  font-size: 12.5px;
  color: var(--fg-dim);
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.top-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Main layout ---------- */

.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 0;
  min-height: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

/* ---------- Viewer pane (left) ---------- */

.viewer-pane {
  position: relative;
  background: var(--bg-0);
  min-height: 520px;
  border-right: 1px solid var(--line);
}

@media (max-width: 900px) {
  .viewer-pane {
    border-right: none;
    border-bottom: 1px solid var(--line);
    min-height: 420px;
  }
}

#viewer {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #111722 0%, #07090d 100%);
}

#controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 5;
  max-width: calc(100% - 24px);
}

#controls button {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 11px;
  background: rgba(21, 27, 36, 0.85);
  color: var(--fg-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 120ms, color 120ms, border-color 120ms;
  letter-spacing: 0.01em;
}

#controls button:hover {
  color: var(--fg);
  border-color: var(--accent-dim);
  background: rgba(30, 38, 50, 0.92);
}

#controls button.active,
#controls button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(42, 122, 115, 0.18);
}

/* ---------- Info column (right) ---------- */

.info-col {
  background: var(--bg-1);
  overflow-y: auto;
  padding: 18px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  max-height: 100vh;
}

@media (max-width: 900px) {
  .info-col {
    max-height: none;
    padding: 18px 16px 40px;
  }
}

/* Thin custom scrollbar for the info column */
.info-col::-webkit-scrollbar { width: 8px; }
.info-col::-webkit-scrollbar-track { background: transparent; }
.info-col::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.info-col::-webkit-scrollbar-thumb:hover { background: var(--line-soft); background: #2a3446; }

/* ---------- Blurb ---------- */

.blurb {
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.55;
  padding: 10px 12px;
  background: var(--bg-2);
  border-left: 2px solid var(--accent-dim);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  margin: 0;
}

/* ---------- Status banner ---------- */

#status-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-m);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

#status-banner.visible { display: flex; }

#status-banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

#status-banner[data-status="sample"] {
  background: var(--warn-bg);
  border-color: rgba(226, 177, 74, 0.25);
  color: #f1d38a;
}
#status-banner[data-status="sample"] .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

#status-banner[data-status="live"] {
  background: var(--ok-bg);
  border-color: rgba(71, 201, 122, 0.25);
  color: #a6e3b9;
}
#status-banner[data-status="live"] .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

#status-banner[data-status="awaiting"] {
  background: var(--skip-bg);
  border-color: rgba(107, 118, 135, 0.25);
  color: #b9c1cd;
}
#status-banner[data-status="awaiting"] .dot { background: var(--skip); }

/* ---------- Generic panel (card) ---------- */

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-m);
  overflow: hidden;
}

.panel-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header::before {
  content: "";
  width: 3px;
  height: 11px;
  background: var(--accent);
  border-radius: 2px;
}

.panel-body {
  padding: 12px 14px 14px;
}

.panel-body.empty {
  padding: 18px 14px;
  color: var(--fg-mute);
  font-size: 12.5px;
  font-style: italic;
  text-align: center;
}

/* ---------- Confidence bars ---------- */

.conf-row {
  display: grid;
  grid-template-columns: 130px 1fr 54px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.conf-row + .conf-row {
  border-top: 1px dashed var(--line-soft);
}

.conf-label {
  font-size: 12.5px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

.conf-bar {
  position: relative;
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}

.conf-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 500ms cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 0 6px rgba(95, 210, 200, 0.3);
}

.conf-row[data-tier="low"] .conf-bar > span {
  background: linear-gradient(90deg, #8a3a42, var(--fail));
  box-shadow: 0 0 6px rgba(229, 97, 107, 0.3);
}

.conf-row[data-tier="mid"] .conf-bar > span {
  background: linear-gradient(90deg, #8a6a28, var(--warn));
  box-shadow: 0 0 6px rgba(226, 177, 74, 0.3);
}

.conf-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Gates table ---------- */

.gates-table {
  display: flex;
  flex-direction: column;
}

.gate-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 10px 2px;
  align-items: start;
}

.gate-row + .gate-row {
  border-top: 1px dashed var(--line-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 56px;
  text-align: center;
}

.badge-pass { background: var(--ok-bg);   color: var(--ok);   border: 1px solid rgba(71, 201, 122, 0.3); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(226, 177, 74, 0.3); }
.badge-fail { background: var(--fail-bg); color: var(--fail); border: 1px solid rgba(229, 97, 107, 0.3); }
.badge-skip,
.badge-pending { background: var(--skip-bg); color: var(--skip); border: 1px solid rgba(107, 118, 135, 0.3); }

.gate-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 2px;
}

.gate-detail {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-mute);
  line-height: 1.45;
  word-break: break-word;
}

/* ---------- Entities / Sites lists ---------- */

.item-list {
  display: flex;
  flex-direction: column;
}

.item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 8px 2px;
  align-items: baseline;
}

.item + .item {
  border-top: 1px dashed var(--line-soft);
}

.chip {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-top: 2px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.item-primary {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}

.item-secondary {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-mute);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

/* ---------- Footer ---------- */

.app-footer {
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-align: center;
  background: var(--bg-1);
}

.app-footer a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}
.app-footer a:hover { color: var(--accent); border-color: var(--accent-dim); }

/* ---------- Utility ---------- */

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Selection */
::selection { background: rgba(95, 210, 200, 0.25); color: #fff; }

/* Focus ring — accessible but subtle */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
