
/* ═══════════════════════════════════════════════════
   BigBounce — Spin-Torsion Cosmology Research
   Terminal-first · Sidebar nav · Editorial precision
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-code: #f6f6f6;
  --bg-sidebar: #1a1a1a;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-secondary: #444444;
  --text-tertiary: #666666;
  --text-muted: #999999;
  --accent-link: #0a0a0a;
  --accent-link-hover: #000000;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
  --radius: 0px;
  --sidebar-w: 240px;
  --topbar-h: 36px;
  --max-width: 720px;
  --wide-width: 980px;
  --transition: 100ms ease;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}

/* ══════════════════════════════════
   Shell Layout: topbar + sidebar + content
   ══════════════════════════════════ */

/* Top bar — thin metadata strip */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; z-index: 90;
  height: var(--topbar-h);
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.topbar a { color: var(--text-muted); text-decoration: none !important; text-transform: uppercase; letter-spacing: 0.06em; }
.topbar a:hover { color: var(--text); text-decoration: none !important; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Left sidebar — dark, CLI tree */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); z-index: 100;
  background: var(--bg-sidebar);
  padding: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  transition: transform 200ms ease;
}
.sidebar-brand {
  padding: 20px 24px 16px;
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  color: #ffffff !important; text-decoration: none !important; display: block;
  letter-spacing: -0.01em;
  border-bottom: 1px solid #333;
}
.sidebar-brand:hover { color: #ccc !important; text-decoration: none !important; }

.sidebar-nav {
  display: block !important; /* Override any nav{display:none} */
  padding: 16px 0; flex: 1;
}
.sidebar-section {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 24px; margin-bottom: 2px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  color: #888 !important; text-decoration: none !important;
  transition: color var(--transition);
}
.sidebar-section:hover { color: #fff !important; }
.sidebar-section.active { color: #fff !important; }
.sidebar-section::before { content: '~'; color: #555; }
.sidebar-section::after { content: '>'; color: #555; margin-left: -2px; }

.sidebar-link {
  display: block; padding: 6px 24px 6px 36px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 400;
  color: #999 !important; text-decoration: none !important;
  transition: color var(--transition), background var(--transition);
  position: relative;
}
.sidebar-link::before {
  content: '>'; position: absolute; left: 22px; color: #555;
  font-size: 11px; opacity: 0; transition: opacity var(--transition);
}
.sidebar-link:hover { color: #fff !important; background: rgba(255,255,255,0.05); text-decoration: none !important; }
.sidebar-link:hover::before { opacity: 1; }
.sidebar-link.active { color: #fff !important; background: rgba(255,255,255,0.08); font-weight: 500; }
.sidebar-link.active::before { opacity: 1; content: '>'; color: #fff; }

/* Sidebar sub-items (for data/ tree) */
.sidebar-sub { padding-left: 0; }
.sidebar-sub .sidebar-link { padding-left: 48px; font-size: 12px; color: #777 !important; }
.sidebar-sub .sidebar-link::before { left: 36px; content: '-'; }
.sidebar-sub .sidebar-link:hover { color: #fff !important; }

.sidebar-group-label { display: flex; align-items: center; justify-content: space-between; padding: 6px 24px; margin-top: 12px; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #555; cursor: pointer; user-select: none; }
.sidebar-group-label:hover { color: #888; }
.sidebar-group-label::after { content: '▾'; font-size: 8px; transition: transform 0.15s; }
.sidebar-group-label.collapsed::after { transform: rotate(-90deg); }
.sidebar-group { overflow: hidden; max-height: 500px; transition: max-height 0.2s ease; }
.sidebar-group.collapsed { max-height: 0; }
.sidebar-sep { height: 1px; background: #333; margin: 8px 20px; }

.sidebar-footer {
  padding: 12px 24px; border-top: 1px solid #333;
  font-family: var(--font-mono); font-size: 10px; color: #555;
  line-height: 1.5;
}

/* Content area — offset by sidebar */
.site-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left 200ms ease;
}
main {
  padding: 32px 48px 48px;
  max-width: 860px;
}
main.container { max-width: 860px; padding: 32px 48px 48px; }
main.wide-container { max-width: 1040px; padding: 32px 48px 48px; }

/* Hamburger toggle for sidebar */
.sidebar-toggle {
  position: fixed; top: 0; left: 0; z-index: 300;
  width: var(--topbar-h); height: var(--topbar-h);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  display: none; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { color: var(--text); }
.sidebar-toggle svg { display: block; width: 18px; height: 18px; }

/* Close button inside sidebar — always visible */
.sidebar-close {
  display: block; position: absolute; top: 14px; right: 14px;
  background: none; border: none; cursor: pointer;
  color: #777; font-family: var(--font-mono); font-size: 24px;
  padding: 4px 8px; line-height: 1; letter-spacing: -4px;
}
.sidebar-close:hover { color: #fff; }

/* When sidebar is collapsed on desktop, shift content back */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); transition: transform 200ms ease; }
body.sidebar-collapsed .site-content { margin-left: 0; transition: margin-left 200ms ease; }
body.sidebar-collapsed .topbar { left: 0; padding-left: 40px; transition: left 200ms ease, padding-left 200ms ease; }
body.sidebar-collapsed .sidebar-toggle { display: flex; }

/* Hide old nav elements — sidebar replaces them */
body > nav { display: none; }

/* ══════════════════════════════════
   Typography — tighter, more technical
   ══════════════════════════════════ */
h1, h2, h3, h4 { font-family: var(--font-sans); color: var(--text); line-height: 1.3; letter-spacing: -0.025em; }
h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
h2 {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
  font-family: var(--font-mono);
  margin: 36px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
h3 { font-size: 14px; font-weight: 600; margin: 18px 0 5px; }
h4 { font-size: 12px; font-weight: 600; margin: 14px 0 4px; color: var(--text-secondary); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
p { color: var(--text-secondary); margin: 6px 0; font-size: 14px; line-height: 1.65; }
strong { color: var(--text); font-weight: 600; }
small, .text-sm { font-size: 12px; }
.text-xs {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 500; color: var(--text-muted); font-family: var(--font-mono);
}
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.sans { font-family: var(--font-sans); }

/* ── Links ── */
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; transition: text-decoration-color var(--transition); }
a:hover { text-decoration-color: var(--text); }

/* ══════════════════════════════════
   Cards
   ══════════════════════════════════ */
.card {
  background: var(--bg); border: 1px solid var(--border);
  padding: 20px 22px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-strong); }
.card-accent { border-left: 2px solid var(--text); }
.card + .card { margin-top: 10px; }

/* ── Grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; font-size: 11px; font-weight: 500;
  font-family: var(--font-mono); letter-spacing: 0.02em;
  border: 1px solid var(--border); color: var(--text-tertiary);
  background: var(--bg);
}
.badge-accent { color: var(--text-secondary); }
.badge-success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.badge-warning { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.badge-neutral { color: var(--text-muted); }

/* ── Progress ── */
.progress-bar { height: 1px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--text); }

/* ══════════════════════════════════
   Timeline
   ══════════════════════════════════ */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 3px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--text-muted);
}
.timeline-item.completed::before { background: var(--text); border-color: var(--text); }
.timeline-date { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-bottom: 2px; }
.timeline-title { font-weight: 600; color: var(--text); margin-bottom: 2px; font-size: 14px; }
.timeline-body { color: var(--text-secondary); font-size: 13.5px; }

/* ══════════════════════════════════
   Tables
   ══════════════════════════════════ */
table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--font-mono); }
thead th {
  padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--text); background: var(--bg);
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; }
tbody tr:hover td { background: var(--bg-subtle); }

/* ── Code ── */
code { font-family: var(--font-mono); background: var(--bg-code); padding: 2px 5px; font-size: 13px; color: var(--text); }
pre { background: var(--bg-code); border: 1px solid var(--border); padding: 14px 18px; overflow-x: auto; line-height: 1.5; font-size: 13px; }
pre code { background: none; padding: 0; }

/* ── Blockquote ── */
blockquote { border-left: 2px solid var(--border); padding: 12px 20px; margin: 16px 0; }
blockquote p { color: var(--text-secondary); font-style: italic; font-size: 14px; }

/* ══════════════════════════════════
   Hero
   ══════════════════════════════════ */
.hero { margin-bottom: 36px; padding-top: 16px; }
.hero h1 { font-size: 1.75rem; margin-bottom: 12px; line-height: 1.25; font-weight: 700; }
.hero .subtitle { font-size: 15px; color: var(--text-secondary); max-width: 640px; line-height: 1.7; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; font-family: var(--font-mono); }

/* ── Stat Cards — monochrome, no colored values ── */
.stat { text-align: center; padding: 16px 12px; }
.stat-value {
  font-size: 1.5rem; font-weight: 600; color: var(--text) !important;
  font-family: var(--font-mono); letter-spacing: -0.02em; line-height: 1.1;
}
.stat-label {
  font-size: 10px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: 6px; font-family: var(--font-mono);
}
.stat-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; font-family: var(--font-mono); }

/* Override any colored stat values from inline styles */
.stat-card .stat-value,
.stat-card.clr-blue .stat-value,
.stat-card.clr-green .stat-value,
.stat-card.clr-red .stat-value,
.stat-card.clr-orange .stat-value,
.stat-card.clr-purple .stat-value,
.stat-card.clr-cyan .stat-value { color: var(--text) !important; }

/* ── Equation Display ── */
.equation-display { border: 1px solid var(--border); border-left: 2px solid var(--text); padding: 20px 22px; margin: 16px 0; text-align: center; overflow-x: auto; background: var(--bg); }
.equation-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ── Charts ── */
.chart-container { position: relative; padding: 14px; background: var(--bg); border: 1px solid var(--border); margin: 14px 0; }
canvas { max-width: 100%; }

/* ══════════════════════════════════
   Buttons
   ══════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 12px; font-weight: 500;
  font-family: var(--font-mono); cursor: pointer;
  transition: all var(--transition); text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--text); color: var(--bg); border: 1px solid var(--text); }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text); color: var(--text); }

/* ── Separator ── */
hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* ── Abstract ── */
.abstract { border: 1px solid var(--border); border-left: 2px solid var(--text); padding: 20px 24px; margin: 20px 0; font-size: 13.5px; line-height: 1.75; }
.abstract p { color: var(--text-secondary); }

/* ══════════════════════════════════
   Footer
   ══════════════════════════════════ */
footer { border-top: 1px solid var(--border); padding: 20px 0; margin-top: 48px; text-align: left; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); text-decoration: underline; }
footer p { margin: 2px 0; color: var(--text-muted); }

/* ══════════════════════════════════
   PDF Viewer
   ══════════════════════════════════ */
.pdf-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 36px; background: rgba(255,255,255,0.96); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; font-family: var(--font-mono); font-size: 12px; }
.pdf-bar a { color: var(--text-muted); text-decoration: none; }
.pdf-bar a:hover { color: var(--text); }
.pdf-bar .pdf-title { color: var(--text-secondary); flex: 1; }
.pdf-bar .pdf-author { color: var(--text-muted); }
.pdf-bar .pdf-download { margin-left: 16px; padding: 3px 10px; border: 1px solid var(--border); font-size: 11px; color: var(--text-secondary); }

/* ══════════════════════════════════
   Responsive
   ══════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
    width: 240px;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; z-index: 150; /* below sidebar z-index 200 */ }
  .sidebar-close { display: block; }
  .topbar { left: 0; padding-left: 40px; }
  .topbar-right { display: none; }
  .site-content { margin-left: 0; }
  main, main.container, main.wide-container { padding: 24px 20px 40px; max-width: none; }
  .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  body { font-size: 14px; }
  h1 { font-size: 1.35rem; }
  .hero h1 { font-size: 1.35rem; }
  .stat-value { font-size: 1.25rem; }
  /* Overlay behind sidebar on mobile */
  .sidebar.open::after {
    content: ''; position: fixed; top: 0; left: 240px; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); z-index: -1;
  }
}
@media (max-width: 480px) {
  .hero h1 { font-size: 1.15rem; }
  .topbar { font-size: 10px; padding: 0 12px 0 40px; }
  .topbar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Legacy compat ── */
body > nav, .nav-inner { display: none; } /* Old top nav hidden — sidebar is primary */
.nav-toggle { display: none; }
.nav-links { display: none; }
.phase-bar { display: flex; gap: 2px; }
.phase-segment { height: 1px; flex: 1; background: var(--border); }
.phase-segment.completed { background: var(--text); }
details { margin: 10px 0; }
details summary { cursor: pointer; font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-secondary); padding: 4px 0; }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 6px; }
.prose { font-family: var(--font-sans); font-size: 15px; line-height: 1.75; }

/* Agent card compat */
.agent-card { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.agent-avatar { width: 28px; height: 28px; background: var(--bg-code); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 10px; color: var(--text-muted); flex-shrink: 0; font-family: var(--font-mono); }
.agent-info { flex: 1; }
.agent-name { font-weight: 600; color: var(--text); font-size: 13px; font-family: var(--font-mono); }
.agent-role { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ══════════════════════════════════
   Dark Mode — academic dark theme
   ══════════════════════════════════ */

/* Auto dark mode via system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --bg-subtle: #111111;
    --bg-code: #161616;
    --bg-sidebar: #050505;
    --bg-raised: #1a1a1a;
    --border: #2a2a2a;
    --border-strong: #3a3a3a;
    --text: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-tertiary: #737373;
    --text-muted: #666666;
    --accent-link: #60a5fa;
    --accent-link-hover: #93c5fd;
  }

  :root:not([data-theme="light"]) .badge-success { color: #4ade80; border-color: #166534; background: #052e16; }
  :root:not([data-theme="light"]) .badge-warning { color: #fbbf24; border-color: #92400e; background: #1c1406; }
  :root:not([data-theme="light"]) .pdf-bar { background: rgba(10,10,10,0.96); }
  :root:not([data-theme="light"]) .sidebar { border-right: 1px solid #1a1a1a; }

  /* Form elements */
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) input[type="text"],
  :root:not([data-theme="light"]) input[type="search"],
  :root:not([data-theme="light"]) input[type="number"],
  :root:not([data-theme="light"]) input[type="email"] {
    background: var(--bg-raised);
    color: var(--text);
    border-color: var(--border);
  }
}

/* Manual dark mode via data attribute */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-subtle: #111111;
  --bg-code: #161616;
  --bg-sidebar: #050505;
  --bg-raised: #1a1a1a;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --text: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --text-muted: #666666;
  --accent-link: #60a5fa;
  --accent-link-hover: #93c5fd;
}

[data-theme="dark"] .badge-success { color: #4ade80; border-color: #166534; background: #052e16; }
[data-theme="dark"] .badge-warning { color: #fbbf24; border-color: #92400e; background: #1c1406; }
[data-theme="dark"] .pdf-bar { background: rgba(10,10,10,0.96); }
[data-theme="dark"] .sidebar { border-right: 1px solid #1a1a1a; }

[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="email"] {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--border);
}

/* Manual light mode via data attribute — forces light regardless of system preference */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-code: #f6f6f6;
  --bg-sidebar: #1a1a1a;
  --bg-raised: #ffffff;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-secondary: #444444;
  --text-tertiary: #666666;
  --text-muted: #999999;
  --accent-link: #0a0a0a;
  --accent-link-hover: #000000;
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1;
  transition: color var(--transition);
  margin-left: 8px;
}
.theme-toggle:hover { color: var(--text); }

/* ══════════════════════════════════
   Print Styles
   ══════════════════════════════════ */
@media print {
  /* Hide interactive/nav elements */
  .sidebar, .sidebar-toggle, .topbar, nav, .nav-inner,
  .astro-bubble, .astro-panel,
  .review-controls, #feedback-widget,
  .btn, button { display: none !important; }

  /* Reset layout */
  .site-content { margin-left: 0 !important; padding: 0 !important; }
  .container { max-width: 100% !important; }

  /* Typography for print */
  body { font-size: 11pt; line-height: 1.6; color: #000; background: #fff; }
  h1 { font-size: 18pt; }
  h2 { font-size: 14pt; }
  h3 { font-size: 12pt; }

  /* Links show URL */
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
  a[href^="http"] { color: #000; text-decoration: underline; }

  /* Tables */
  table { border-collapse: collapse; }
  th, td { border: 1px solid #ccc; padding: 4px 8px; }

  /* Page breaks */
  section { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }

  /* Figures */
  img { max-width: 100%; page-break-inside: avoid; }
}
