/* Bitcoin Machine Code (bmc) Documentation Site Stylesheet */
:root {
  --bg: #0b0e14;
  --bg-elev: #111622;
  --bg-card: #151b29;
  --bg-code: #0d111a;
  --border: #232c40;
  --border-strong: #32405e;
  --text: #e6ecf5;
  --text-muted: #9aa7bd;
  --text-dim: #6f7d96;
  --accent: #f7931a;
  --accent-soft: rgba(247, 147, 26, 0.14);
  --accent-2: #58a6ff;
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, 0.14);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, 0.15);
  --amber: #d29922;
  --amber-soft: rgba(210, 153, 34, 0.16);
  --purple: #bc8cff;
  --purple-soft: rgba(188, 140, 255, 0.14);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --sidebar-w: 270px;
  --header-h: 60px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-code: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.11);
  --accent-2: #2563eb;
  --green: #15803d;
  --green-soft: rgba(21, 128, 61, 0.11);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.11);
  --amber: #b45309;
  --amber-soft: rgba(180, 83, 9, 0.12);
  --purple: #7c3aed;
  --purple-soft: rgba(124, 58, 237, 0.11);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f09a2e, #e0821c);
  color: #0b0f17;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 13px;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(247, 147, 26, 0.3);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-icon {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-icon:hover { border-color: var(--border-strong); text-decoration: none; }
.menu-toggle { display: none; }

/* Layout */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}
.sidebar {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 14px 36px;
  z-index: 90;
}
.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 14px 10px 6px;
}
.nav-section:first-child { padding-top: 2px; }
.nav-link {
  display: block;
  padding: 7px 11px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-sub {
  padding-left: 22px;
  font-size: 13px;
  color: var(--text-dim);
}

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  max-width: calc(100% - var(--sidebar-w));
  padding: 36px 48px 80px;
}
.container {
  max-width: 1040px;
  margin: 0 auto;
}

/* Typography */
h1 {
  font-size: 2.15rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
}
h2 {
  font-size: 1.45rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 42px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
h3 {
  font-size: 1.12rem;
  margin: 26px 0 10px;
  color: var(--text);
}
p { margin: 0 0 14px; color: var(--text); }
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 6px; }
.lead {
  font-size: 1.08rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, rgba(247, 147, 26, 0.10), rgba(88, 166, 255, 0.08));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 32px;
  margin-bottom: 28px;
}
.hero-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.btn-primary {
  background: #e69a3e;
  color: #0b0f17;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.btn-primary:hover { opacity: 0.92; text-decoration: none; }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }

/* Metrics Grid */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  margin: 22px 0 30px;
}
.metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.metric-val {
  font-family: var(--font-mono);
  font-size: 1.48rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.metric-val.accent { color: var(--accent); }
.metric-val.green { color: var(--green); }
.metric-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 18px 0 26px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 { margin-top: 0; font-size: 1.03rem; }
.card p:last-child { margin-bottom: 0; }

/* Callouts */
.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  background: var(--bg-card);
}
.callout.warn { border-left-color: var(--amber); background: var(--amber-soft); }
.callout.ok { border-left-color: var(--green); background: var(--green-soft); }
.callout.crit { border-left-color: var(--red); background: var(--red-soft); }
.callout-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}
.b-crit { background: var(--red-soft); color: var(--red); }
.b-high { background: var(--amber-soft); color: var(--amber); }
.b-med  { background: var(--purple-soft); color: var(--purple); }
.b-pass { background: var(--green-soft); color: var(--green); }
.b-info { background: var(--accent-soft); color: var(--accent); }

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1.5px 5px;
  border-radius: 5px;
}
pre {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  overflow-x: auto;
  margin: 14px 0 20px;
  line-height: 1.5;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}
.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
}
th, td {
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: var(--bg-elev);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(127, 127, 127, 0.05); }
.num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }

/* Benchmark Winner / Tie Highlighting */
td.cell-win {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--green);
}
td.cell-win::before {
  content: "✓ ";
  font-weight: 800;
  opacity: 0.9;
}
td.cell-tie {
  background: rgba(88, 166, 255, 0.10);
  color: var(--accent-2);
  font-weight: 600;
}
[data-theme="light"] td.cell-tie {
  background: rgba(37, 99, 235, 0.08);
}
.bench-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 14px 0 22px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
}
.legend-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.swatch-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}
.swatch-win {
  background: var(--green-soft);
  border-left: 3px solid var(--green);
  border-top: 1px solid rgba(63, 185, 80, 0.35);
  border-right: 1px solid rgba(63, 185, 80, 0.35);
  border-bottom: 1px solid rgba(63, 185, 80, 0.35);
}
.swatch-tie {
  background: rgba(88, 166, 255, 0.14);
  border: 1px solid rgba(88, 166, 255, 0.45);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0 16px;
}
.filter-input {
  flex: 1;
  min-width: 220px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
}
.filter-pill {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.filter-pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Diagrams & Bar Charts */
.diagram-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0 26px;
  overflow-x: auto;
}
.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 90px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.bar-track {
  background: var(--bg-code);
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
}
.bar-bmc { background: linear-gradient(90deg, #f7931a, #ea580c); }
.bar-core { background: linear-gradient(90deg, #475569, #64748b); }
.bar-green { background: linear-gradient(90deg, #16a34a, #22c55e); }

/* GUI Screenshot Showcase & Lightbox */
.gui-showcase {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin: 18px 0 28px;
  box-shadow: var(--shadow);
}
.gui-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.gui-tab {
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 13px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.gui-tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.gui-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(247, 147, 26, 0.45);
}
.gui-panel { display: none; }
.gui-panel.active { display: block; }
.gui-shot-card {
  margin: 16px 0 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.gui-panel img,
.gui-shot-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.gui-caption,
.gui-shot-card figcaption {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}
.gui-note {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 10px 0 20px;
}
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 16, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
  cursor: zoom-out;
}
.lightbox-backdrop.open { display: flex; }
.lightbox-backdrop img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

/* Footer */
.footer {
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 920px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0;
    max-width: 100%;
    padding: 24px 18px 60px;
  }
  .bar-row { grid-template-columns: 130px 1fr 74px; font-size: 12.5px; }
}
@media print {
  .topbar, .sidebar, .filter-bar, .copy-btn { display: none !important; }
  .content { margin-left: 0; max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
}
