/* ===================================================================
   The Bible, Mapped — Design System
   A dark, scholarly aesthetic: midnight + antique gold + muted tones.
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Tokens --- */
:root {
  --bg:          #0a0a12;
  --surface:     #13132a;
  --surface-hi:  #1c1c3a;
  --border:      #2a2a4a;
  --border-soft: #1e1e38;
  --text:        #e8e4dc;
  --text-dim:    #8b8b9e;
  --text-faint:  #5a5a70;
  --gold:        #c9a84c;
  --gold-dim:    #9a7f3a;
  --blue:        #5b7fa5;
  --red-muted:   #a05c5c;
  --radius:      8px;
  --radius-lg:   12px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --mono:        'JetBrains Mono', ui-monospace, monospace;
  --max-w:       1440px;
  --header-h:    56px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; transition: color .15s; }
a:hover { color: var(--text); }

::selection { background: rgba(201,168,76,.25); }

/* --- Typography --- */
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; color: var(--text-dim); font-weight: 500; }

.mono { font-family: var(--mono); }
.dim  { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.gold { color: var(--gold); }
.small { font-size: 0.85rem; }

/* --- Header & Navigation --- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(10,10,18,.85);
  backdrop-filter: blur(16px) saturate(120%);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
}

nav {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.nav-brand span { color: var(--gold); }

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color .15s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--gold); }

/* --- Layout --- */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-soft);
}
.page-header h1 { margin-bottom: 0.5rem; }
.page-header p { color: var(--text-dim); max-width: 720px; }

section { margin-bottom: 3rem; }

/* --- Cards (landing page tiles) --- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.tile:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  color: var(--text);
}

.tile-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

.tile h2 { margin-bottom: 0.5rem; font-size: 1.3rem; }
.tile p { color: var(--text-dim); font-size: 0.9rem; }

/* --- Visualization Containers --- */
.viz-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.viz-full {
  width: 100%;
  min-height: 600px;
}

.viz-split {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 650px;
}

.viz-main {
  position: relative;
  min-height: 600px;
}

.viz-panel {
  background: var(--surface-hi);
  border-left: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 700px;
}

.viz-panel h3 { margin-bottom: 1rem; color: var(--gold); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Info Sections --- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.info-box h3 {
  color: var(--gold);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.info-box p, .info-box li {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.7;
}
.info-box ul {
  list-style: none;
  padding: 0;
}
.info-box li::before {
  content: "→ ";
  color: var(--gold-dim);
}

/* --- Controls & Filters --- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.controls label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.controls select,
.controls input[type="range"],
.controls input[type="text"] {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

.controls select { cursor: pointer; }
.controls select:focus,
.controls input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.controls input[type="range"] {
  width: 120px;
  accent-color: var(--gold);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  background: var(--gold-dim);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background .15s;
}
.btn:hover { background: var(--gold); }

/* --- Stat Cards (complexity dashboard) --- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card .stat-value {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--gold);
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

/* --- Tooltip (for D3 network) --- */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text);
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 200;
  opacity: 0;
  transition: opacity .12s;
}
.tooltip.visible { opacity: 1; }
.tooltip .tt-ref { color: var(--gold); font-weight: 600; font-size: 0.78rem; }
.tooltip .tt-text { color: var(--text-dim); margin-top: 0.3rem; line-height: 1.5; }

/* --- Neighbors List (map side panel) --- */
.neighbor-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.neighbor-item:last-child { border-bottom: none; }
.neighbor-ref { color: var(--gold); font-size: 0.82rem; font-weight: 600; }
.neighbor-score {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  float: right;
}
.neighbor-text { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.25rem; }

/* --- Legend --- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Loading State --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.loading::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Hero (landing page) --- */
.hero {
  text-align: center;
  padding: 4rem 2rem 3rem;
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  line-height: 1.8;
  max-width: 600px;
  margin: 0 auto;
}

.hero .meta-line {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 0.78rem;
}

/* --- Plotly overrides --- */
.js-plotly-plot .plotly .modebar { top: 8px !important; right: 8px !important; }
.js-plotly-plot .plotly .modebar-btn { color: var(--text-dim) !important; }
.js-plotly-plot .plotly .modebar-btn:hover { color: var(--gold) !important; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .viz-split { grid-template-columns: 1fr; }
  .viz-panel { border-left: none; border-top: 1px solid var(--border); max-height: 400px; }
  .info-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.2rem; }
  nav { padding: 0 1rem; }
  .nav-links { gap: 1rem; }
  main { padding: 1rem; }
}

@media (max-width: 600px) {
  .nav-links a { font-size: 0.75rem; }
  .tile-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .controls { flex-direction: column; align-items: stretch; }
}
