/* ==========================================================================
   Dark Gravity — Evidence-Based Site Standard Stylesheet (assets/site.css)
   Clean, semantic, accessible CSS with prefers-color-scheme and prefers-reduced-motion
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dark Theme Default */
  --bg-primary: #070a10;
  --bg-surface: #0d121f;
  --bg-surface-elevated: #141c2e;
  --bg-surface-translucent: rgba(13, 18, 31, 0.85);
  
  --border-subtle: #1e293b;
  --border-bright: #334155;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #94a3b8;
  
  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.15);
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --status-verified-bg: rgba(16, 185, 129, 0.12);
  --status-verified-text: #34d399;
  --status-verified-border: #059669;
  
  --status-deployed-bg: rgba(0, 240, 255, 0.12);
  --status-deployed-text: #38bdf8;
  --status-deployed-border: #0284c7;
  
  --status-implemented-bg: rgba(168, 85, 247, 0.12);
  --status-implemented-text: #c084fc;
  --status-implemented-border: #7c3aed;
  
  --status-designed-bg: rgba(245, 158, 11, 0.12);
  --status-designed-text: #fbbf24;
  --status-designed-border: #d97706;

  --focus-ring: #00f0ff;
  --container-max: 1200px;
}

/* Light Theme via prefers-color-scheme */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f1f5f9;
    --bg-surface-translucent: rgba(255, 255, 255, 0.9);
    
    --border-subtle: #cbd5e1;
    --border-bright: #94a3b8;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-subtle: #64748b;
    
    --accent-cyan: #0369a1;
    --accent-cyan-glow: rgba(8, 145, 178, 0.12);
    --accent-purple: #7e22ce;
    --accent-emerald: #047857;
    --accent-amber: #b45309;
    --accent-rose: #be123c;
    
    --status-verified-bg: rgba(4, 120, 87, 0.1);
    --status-verified-text: #065f46;
    --status-verified-border: #047857;
    
    --status-deployed-bg: rgba(8, 145, 178, 0.1);
    --status-deployed-text: #0e7490;
    --status-deployed-border: #0891b2;
    
    --status-implemented-bg: rgba(126, 34, 206, 0.1);
    --status-implemented-text: #6b21a8;
    --status-implemented-border: #7e22ce;
    
    --status-designed-bg: rgba(180, 83, 9, 0.1);
    --status-designed-text: #92400e;
    --status-designed-border: #b45309;

    --focus-ring: #0891b2;
  }
  .btn-primary {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
  }
  .btn-primary:hover {
    background: #0369a1 !important;
    border-color: #0369a1 !important;
    color: #ffffff !important;
  }
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

p, li, td, th {
  max-width: 72ch;
}

h1, h2, h3, h4 {
  color: var(--text-main);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.25rem; margin-bottom: 1rem; }
h2 { font-size: 1.75rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background-color: var(--bg-surface-elevated);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

pre {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

pre code {
  background: transparent;
  padding: 0;
  border: none;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent-cyan);
  color: #000;
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: 4px;
  z-index: 9999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 1rem;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

main {
  flex: 1 0 auto;
  padding-top: 5rem;
  padding-bottom: 4rem;
}

/* Unified Navigation */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
  padding: 0.6rem 0;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1.5rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  text-decoration: none !important;
  white-space: nowrap;
}

.site-brand svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent-cyan);
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none !important;
}

.nav-link[aria-current="page"], .nav-link.active {
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.3);
  font-weight: 600;
}

@media (max-width: 768px) {
  .site-header {
    padding: 0.4rem 0;
  }
  .site-nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .site-brand span {
    font-size: 0.95rem;
  }
  .nav-menu {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0.2rem;
    padding: 0.1rem 0;
  }
  .nav-menu::-webkit-scrollbar {
    display: none;
  }
  .nav-link {
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
  }
}

/* Status Tags Standard */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-tag::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-verified {
  background: var(--status-verified-bg);
  color: var(--status-verified-text);
  border-color: var(--status-verified-border);
}
.status-verified::before { background: var(--status-verified-text); }

.status-deployed {
  background: var(--status-deployed-bg);
  color: var(--status-deployed-text);
  border-color: var(--status-deployed-border);
}
.status-deployed::before { background: var(--status-deployed-text); }

.status-implemented {
  background: var(--status-implemented-bg);
  color: var(--status-implemented-text);
  border-color: var(--status-implemented-border);
}
.status-implemented::before { background: var(--status-implemented-text); }

.status-designed {
  background: var(--status-designed-bg);
  color: var(--status-designed-text);
  border-color: var(--status-designed-border);
}
.status-designed::before { background: var(--status-designed-text); }

/* Status Legend Banner */
.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin: 1.5rem 0 2rem;
  font-size: 0.85rem;
}

.status-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hero Section */
.hero {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.hero-paths {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.path-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.path-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  text-decoration: none;
}

.path-card h3 {
  color: var(--text-main);
  margin-top: 0;
}

.path-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}

.path-card .path-action {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-cyan);
}

/* Tables & Containers */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

th {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* Callouts & Evidence Boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: var(--bg-surface);
  border-left: 4px solid var(--accent-cyan);
  margin: 1.5rem 0;
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.callout-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Grid & Cards */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
}

/* Unified Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 2.5rem 0 3rem;
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

.footer-bottom {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

.footer-bottom a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Responsive Headings */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
}

/* ==========================================================================
   Navigation & reading aids (v2)
   ========================================================================== */
main { padding-top: 1.5rem; }
@media (max-width: 768px) {
  main { padding-top: 1rem; }
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
code { overflow-wrap: anywhere; }
.card, .callout, .path-card { min-width: 0; }

.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.breadcrumb a { color: var(--text-muted); text-decoration: underline; }
.lede { font-size: 1.15rem; color: var(--text-muted); max-width: 66ch; margin-bottom: 1rem; }

.minute { border: 1px solid var(--accent-cyan); border-radius: 8px; padding: 1rem 1.25rem; background: var(--accent-cyan-glow); margin: 1.25rem 0; }
.minute h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.minute ul { margin-left: 1.25rem; }
.minute li { margin: 0.25rem 0; }

.toc { border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.9rem 1.25rem; background: var(--bg-surface); margin: 1.25rem 0 2rem; }
.toc h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.toc ol { margin-left: 1.25rem; columns: 2 260px; column-gap: 2rem; }
.toc li { margin: 0.2rem 0; break-inside: avoid; }

section[id] { scroll-margin-top: 5rem; }
section > h2 .anchor { margin-left: 0.4rem; font-size: 0.8em; opacity: 0.5; }

.status-line { font-size: 0.9rem; color: var(--text-muted); }
.status-line .status-tag { margin: 0 0.15rem; }
.note { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.steps { counter-reset: step; list-style: none; margin: 1rem 0; display: grid; gap: 0.75rem; }
.steps li { counter-increment: step; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.85rem 1rem 0.85rem 3.2rem; position: relative; max-width: none; }
.steps li::before { content: counter(step); position: absolute; left: 1rem; top: 0.8rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent-cyan); color: #04121a; font-weight: 700; display: grid; place-items: center; font-size: 0.85rem; }
.steps strong { display: block; }

dl.glossary { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr; gap: 0.5rem 1.25rem; margin: 1rem 0; }
dl.glossary dt { font-weight: 700; color: var(--text-main); }
dl.glossary dd { color: var(--text-muted); max-width: 66ch; }
@media (max-width: 560px) { dl.glossary { grid-template-columns: 1fr; gap: 0.1rem; } dl.glossary dd { margin-bottom: 0.6rem; } }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 3rem 0 0; }
.pager a { display: block; border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.9rem 1.1rem; background: var(--bg-surface); color: var(--text-main); }
.pager a:hover { border-color: var(--accent-cyan); text-decoration: none; }
.pager small { display: block; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.pager .next { text-align: right; grid-column: 2; }
.pager .prev { grid-column: 1; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next, .pager .prev { grid-column: 1; text-align: left; } }
.to-top { display: inline-block; margin-top: 1.5rem; font-size: 0.85rem; }

/* Notebook entries */
.entry { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 1.25rem 1.5rem; margin: 1.5rem 0; }
.entry header.entry-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.6rem; margin-bottom: 0.75rem; font-size: 0.85rem; color: var(--text-muted); }
.entry h2 { margin-top: 0; font-size: 1.35rem; }
.entry dl { display: grid; gap: 0.15rem; margin-top: 1rem; }
.entry dt { font-weight: 700; color: var(--accent-cyan); margin-top: 0.7rem; font-size: 0.9rem; }
.entry dd { max-width: 70ch; color: var(--text-main); }
.entry pre { max-width: 100%; }
.entry-index { width: 100%; }
@media print { .site-header, .pager, .to-top { display: none; } }

/* Additional helper styles for notebook chips and responsive video embeds */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.video-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  margin: 1rem 0;
  background: #000;
  border: 1px solid var(--border-subtle);
}
.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Text block links distinguishing without relying solely on color */
p a, td a, li a:not(.nav-link), dd a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nav-link {
  text-decoration: none !important;
}
.footer-title {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.video-container { margin: 1.5rem 0; }
.video-caption { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* Hero enhancements & Buttons */
.hero-tagline {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.research-question {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-cyan);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.15rem;
  margin: 1.25rem 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.98rem;
  color: var(--text-main);
}

.research-question strong {
  color: var(--accent-cyan);
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.cta-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  text-decoration: none !important;
  transition: all 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #04121a !important;
  border: 1px solid var(--accent-cyan);
}

.btn-primary:hover {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  text-decoration: none !important;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main) !important;
  border: 1px solid var(--border-bright);
}

.btn-secondary:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan) !important;
  text-decoration: none !important;
}

/* Collapsible technical details */
details {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin: 0.6rem 0;
}

details[open] {
  border-color: var(--border-bright);
}

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent-cyan);
}

summary:hover {
  text-decoration: underline;
}

details > div, details > p, details > ul {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Acronyms & Abbreviations */
abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}

/* Badges for code execution verification */
.badge-evidence {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

.badge-illustrative {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid #d97706;
}

.badge-verified-run {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid #059669;
}
