/* ============================================
   l402-train.ai — Bitcoin-native dark theme
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-raised: #111111;
  --bg-code: #1a1a1a;
  --bg-table-header: #1a1a1a;
  --bg-table-row: #0f0f0f;
  --text: #d4d4d4;
  --text-bright: #e8e8e8;
  --text-dim: #888888;
  --text-dimmer: #555555;
  --orange: #f7931a;
  --orange-light: #ffb347;
  --orange-dim: #c47515;
  --lightning: #7b68ee;
  --lightning-dim: #5a4fc4;
  --border: #222222;
  --border-light: #333333;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --max-width: 820px;
  --max-width-wide: 1100px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

a, a:link, a:visited {
  color: var(--orange);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
a:hover {
  border-bottom-color: var(--orange);
}

.section a,
.section a:link,
.section a:visited {
  color: var(--orange);
}

::selection {
  background: var(--orange);
  color: var(--bg);
}

/* ---- Navigation ---- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.nav-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--orange);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-brand:hover {
  color: var(--orange-light);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--orange);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ---- Hero ---- */

.hero {
  padding: 6rem 1.5rem 4rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero h1 {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.hero h1 .accent {
  color: var(--orange);
}

.hero .tagline {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 640px;
  margin: 1.5rem auto 2rem;
}

.hero .protocol-brief {
  font-size: 0.95rem;
  color: var(--text);
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-cta {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.65rem 1.5rem;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.btn-primary,
.btn-primary:link,
.btn-primary:visited {
  background: var(--orange);
  color: var(--bg);
  border: 1px solid var(--orange);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--orange-light);
  border-color: var(--orange-light);
  color: var(--bg);
}

.btn-secondary,
.btn-secondary:link,
.btn-secondary:visited {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  border-color: var(--orange);
  background: rgba(247, 147, 26, 0.06);
}

/* ---- Sections (landing page) ---- */

.section {
  padding: 4rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
}

.section h2 {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.section h2 .accent {
  color: var(--orange);
}

/* How It Works */

.steps {
  display: grid;
  gap: 1.5rem;
}

.step {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1rem;
  align-items: start;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--orange);
  text-align: center;
  line-height: 1;
  padding-top: 0.15rem;
}

.step h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.35rem;
}

.step p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Architecture ASCII */

.ascii-diagram {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.ascii-diagram pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

.ascii-diagram .hl-orange {
  color: var(--orange);
}

.ascii-diagram .hl-lightning {
  color: var(--lightning);
}

/* Roadmap */

.roadmap {
  display: grid;
  gap: 0;
}

.phase {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.phase:last-child {
  border-bottom: none;
}

.phase-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.phase-label .phase-num {
  color: var(--orange);
  display: block;
}

.phase-label .phase-time {
  color: var(--text-dimmer);
  font-size: 0.75rem;
  font-weight: 400;
}

.phase h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-bright);
  margin-bottom: 0.35rem;
}

.phase p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Links grid */

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.link-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.link-card:hover {
  border-color: var(--orange-dim);
  background: rgba(247, 147, 26, 0.03);
}

.link-card h3 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--orange);
  margin-bottom: 0.35rem;
}

.link-card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---- Footer ---- */

.site-footer {
  padding: 3rem 1.5rem;
  text-align: center;
}

.site-footer .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-footer h2 {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--text-bright);
  margin-bottom: 0.75rem;
}

.site-footer p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.site-footer .footer-links {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.site-footer .footer-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
}

.site-footer .footer-links a:hover {
  color: var(--orange);
}

.footer-sep {
  width: 60px;
  height: 1px;
  background: var(--border-light);
  margin: 2rem auto;
}

.footer-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dimmer);
}

/* ---- Document / Article pages ---- */

.doc-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

.doc-sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 2rem 1rem 2rem 1.5rem;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.doc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.doc-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.doc-sidebar h4 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.doc-sidebar ul {
  list-style: none;
}

.doc-sidebar li {
  margin-bottom: 0.25rem;
}

.doc-sidebar a {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  display: block;
  padding: 0.2rem 0;
  line-height: 1.4;
  transition: color 0.15s;
}

.doc-sidebar a:hover {
  color: var(--orange);
}

.doc-sidebar .toc-h3 {
  padding-left: 0.75rem;
  font-size: 0.75rem;
}

.doc-content {
  padding: 2.5rem 2rem 4rem;
  max-width: var(--max-width);
  min-width: 0;
}

/* No sidebar variant */
.doc-content.full-width {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ---- Article typography ---- */

.article {
  line-height: 1.75;
}

.article h1 {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.article .subtitle {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  font-style: italic;
}

.article .doc-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dimmer);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article h2 {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-bright);
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
  letter-spacing: -0.01em;
  border-top: 1px solid var(--border);
}

.article h2:first-of-type {
  border-top: none;
  margin-top: 0;
}

.article h3 {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 2rem 0 0.75rem;
}

.article h4 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

.article p {
  margin-bottom: 1rem;
}

.article a {
  color: var(--orange);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.article a:hover {
  color: var(--orange-light);
  border-bottom-color: var(--orange-light);
}

.article strong {
  color: var(--text-bright);
  font-weight: 600;
}

.article em {
  color: var(--text);
}

.article ul, .article ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

.article li {
  margin-bottom: 0.35rem;
}

.article li > ul, .article li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.article blockquote {
  border-left: 3px solid var(--orange-dim);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1rem 0;
  color: var(--text-dim);
  font-style: italic;
}

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

.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--orange-light);
}

.article pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.5;
}

.article pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text);
}

/* Tables */
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.88rem;
  display: block;
  overflow-x: auto;
}

.article thead th {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-bright);
  background: var(--bg-table-header);
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.article tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.article tbody tr:hover {
  background: rgba(247, 147, 26, 0.02);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
  }

  .doc-content {
    padding: 2rem 1.5rem 3rem;
  }
}

@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero .tagline {
    font-size: 0.9rem;
  }

  .phase {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .step {
    grid-template-columns: 2.5rem 1fr;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    gap: 0.75rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .ascii-diagram pre {
    font-size: 0.65rem;
  }

  .links-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 4rem 1rem 3rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .section {
    padding: 3rem 1rem;
  }

  .doc-content {
    padding: 1.5rem 1rem 3rem;
  }

  .article pre {
    padding: 1rem;
    font-size: 0.75rem;
  }

  .article table {
    font-size: 0.8rem;
  }
}
