/* NIGHTWING Whitepaper Series — Light Scientific Journal Theme */
/* Fonts: Source Sans 3 (body) + Source Serif 4 (headings) via Google Fonts */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --blue-700: #1a56db;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;
  --red-600:  #dc2626;
  --green-600:#16a34a;
  --amber-600:#d97706;
  --sidebar-w: 260px;
  --content-max: 780px;
  --font-body:  'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  --font-head:  'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--gray-800);
  background: var(--white);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout: Sidebar + Main ─────────────────────────────────── */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar / Table of Contents */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--gray-50);
  border-right: 1px solid var(--gray-200);
  padding: 2rem 1.25rem;
  z-index: 100;
}

.sidebar-logo {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-700);
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-300);
}

.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }

.sidebar nav a {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: 4px;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.sidebar nav a:hover {
  color: var(--blue-700);
  background: var(--blue-50);
}

.sidebar nav a.active {
  color: var(--blue-700);
  background: var(--blue-50);
  border-left-color: var(--blue-600);
  font-weight: 600;
}

.sidebar nav a.section-heading {
  font-weight: 600;
  color: var(--gray-800);
  margin-top: 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.sidebar nav a.sub {
  padding-left: 1.5rem;
  font-size: 0.8rem;
}

/* Paper navigation at bottom of sidebar */
.sidebar-papers {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-300);
}

.sidebar-papers .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.sidebar-papers a {
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.sidebar-papers a:hover { color: var(--blue-700); background: var(--blue-50); }
.sidebar-papers a.current { color: var(--blue-700); font-weight: 600; }

/* ── Main Content ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

/* ── Title Block ────────────────────────────────────────────── */
.title-block {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--blue-600);
}

.paper-number {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue-600);
  margin-bottom: 0.5rem;
}

.title-block h1 {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.title-block .subtitle {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 400;
  font-style: italic;
  color: var(--gray-600);
  margin-bottom: 1rem;
}

.title-block .meta {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.title-block .meta span + span::before {
  content: '·';
  margin: 0 0.5rem;
}

/* ── Typography ─────────────────────────────────────────────── */
h2 {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
}

h2:first-of-type { border-top: none; padding-top: 0; }

h3 {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 2rem 0 0.75rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 1.5rem 0 0.5rem;
}

p { margin-bottom: 1rem; }

strong { font-weight: 600; color: var(--gray-900); }
em { font-style: italic; }

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Lists ──────────────────────────────────────────────────── */
ul, ol {
  margin: 0 0 1rem 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

li > ul, li > ol { margin-top: 0.35rem; }

/* ── Code ───────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--gray-100);
  color: var(--gray-800);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--gray-200);
}

pre {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--gray-700);
}

/* ── Tables ─────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--gray-800);
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--blue-600);
  background: var(--blue-50);
}

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
}

tbody tr:hover { background: var(--gray-50); }

/* ── Blockquotes / Callouts ─────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--blue-500);
  background: var(--blue-50);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
  color: var(--gray-700);
}

blockquote p:last-child { margin-bottom: 0; }

.callout {
  border-left: 3px solid var(--amber-600);
  background: #fffbeb;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
}

/* ── Figures / Diagrams ─────────────────────────────────────── */
.figure {
  margin: 2rem 0;
  text-align: center;
}

.figure pre {
  display: inline-block;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--gray-300);
  font-size: 0.78rem;
  line-height: 1.4;
}

.figure-caption {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--gray-500);
  margin-top: 0.75rem;
}

/* ── Abstract Box ───────────────────────────────────────────── */
.abstract {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  margin-bottom: 2.5rem;
}

.abstract h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue-600);
  margin: 0 0 0.75rem;
  border: none;
  padding: 0;
}

.abstract p { color: var(--gray-700); font-size: 0.95rem; }
.abstract p:last-child { margin-bottom: 0; }

/* ── Correction Note ──────────────────────────────────────────── */
.correction-note { background: #fff3cd; border-left: 4px solid #e6a817; padding: 0.6rem 1rem; font-size: 0.88rem; margin: 0.5rem 0 1rem; border-radius: 0 4px 4px 0; }

/* ── Comparison Table (RAG/VectorDB) ────────────────────────── */
.comparison-table {
  overflow-x: auto;
}

.comparison-table table { min-width: 700px; }

.comparison-table .check { color: var(--green-600); font-weight: 600; }
.comparison-table .cross { color: var(--gray-400); }
.comparison-table .partial { color: var(--amber-600); }

/* ── Footnotes / References ─────────────────────────────────── */
.references {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
}

.references h2 { font-size: 1.2rem; }

.references ol {
  font-size: 0.88rem;
  color: var(--gray-600);
}

/* ── Series Navigation (bottom) ─────────────────────────────── */
.series-nav {
  display: flex;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 2px solid var(--gray-200);
}

.series-nav a {
  flex: 1;
  display: block;
  padding: 1.25rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.series-nav a:hover {
  background: var(--blue-50);
  border-color: var(--blue-300);
}

.series-nav .nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
}

.series-nav .nav-title {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--blue-700);
  font-size: 0.95rem;
}

.series-nav .next { text-align: right; }

/* ── Print / PDF Styles ─────────────────────────────────────── */
@media print {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { max-width: 100%; padding: 1rem; }
  .series-nav { display: none; }

  body { font-size: 11pt; color: #000; }
  h2 { break-before: auto; }
  pre, table, .figure { break-inside: avoid; }

  a { color: #000; text-decoration: none; }
  a[href]::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #666; }
  a[href^="#"]::after { content: ''; }

  .title-block { border-bottom-color: #000; }
  thead th { background: #f0f0f0; border-bottom-color: #000; }
}

/* ── Hamburger Toggle (hidden on desktop) ──────────────────── */
.sidebar-hamburger {
  display: none;
}

/* ── Mobile / Narrow ────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;
    border-right: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    background: var(--gray-50);
    overflow-y: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar nav { flex-direction: column; gap: 0.15rem; }
  .sidebar nav a { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
  .sidebar nav a.section-heading { display: block; }
  .sidebar nav a.sub { padding-left: 1.5rem; }

  .sidebar-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px; left: 12px;
    width: 40px; height: 40px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1.3rem;
    color: var(--gray-700);
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main { margin-left: 0; }
  .content { padding: 1.5rem 1rem 4rem; }

  .title-block h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.05rem; }

  .series-nav { flex-direction: column; }

  /* Prevent overflow on mobile */
  pre { font-size: 0.72rem; padding: 0.75rem; word-break: break-word; white-space: pre-wrap; }
  table { font-size: 0.8rem; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .comparison-table table { min-width: 0; }
  .figure pre { font-size: 0.68rem; }
  .abstract { padding: 1rem 1.25rem; }
  blockquote { padding: 0.75rem 1rem; }

  img, svg { max-width: 100%; height: auto; }
}

/* ── Scroll Spy Active Section Highlight ────────────────────── */
.sidebar nav a.active {
  color: var(--blue-700);
  background: var(--blue-50);
  border-left-color: var(--blue-600);
  font-weight: 600;
}

/* ── Smooth anchor offset for fixed sidebar ─────────────────── */
:target { scroll-margin-top: 1.5rem; }

/* ── Diagram specific styles ────────────────────────────────── */
.state-diagram {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.state-diagram pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

/* ── Tag / Badge styles ─────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-blue { background: var(--blue-100); color: var(--blue-700); }
.tag-green { background: #dcfce7; color: var(--green-600); }
.tag-amber { background: #fef3c7; color: var(--amber-600); }
.tag-red { background: #fee2e2; color: var(--red-600); }

/* ── Belief State Badges ───────────────────────────────────── */
.belief-state { display: inline-block; padding: 0.15em 0.5em; border-radius: 3px; font-size: 0.85em; font-weight: bold; }
.bs-forming { background: #fff8e0; color: #806000; }
.bs-held { background: #e0f0e0; color: #206020; }
.bs-questioning { background: #f0e0e0; color: #802020; }
.bs-revised { background: #e0e8f8; color: #203080; }
.bs-abandoned { background: #f0f0f0; color: #606060; }
