/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --bg: #faf9f6;
  --bg-raised: #ffffff;
  --text: #14140f;
  --text-muted: #5b5a52;
  --border: #e6e3da;
  --accent: #a8730f;
  --accent-strong: #7a5308;
  --accent-soft: #f2e6cd;
  --bronze: #b8763f;
  --silver: #9a978d;
  --gold: #c99a2e;
  --code-bg: #14140f;
  --code-text: #e9e6da;
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.04), 0 8px 24px rgba(20, 20, 15, 0.05);
  --radius: 10px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --max-w: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0d0b;
    --bg-raised: #17160f;
    --text: #f2f0e6;
    --text-muted: #a19d8d;
    --border: #2a2820;
    --accent: #e0ab3d;
    --accent-strong: #f2c667;
    --accent-soft: #2b230f;
    --code-bg: #0a0a08;
    --code-text: #e9e6da;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0e0d0b;
  --bg-raised: #17160f;
  --text: #f2f0e6;
  --text-muted: #a19d8d;
  --border: #2a2820;
  --accent: #e0ab3d;
  --accent-strong: #f2c667;
  --accent-soft: #2b230f;
  --code-bg: #0a0a08;
  --code-text: #e9e6da;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Reset
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

img { max-width: 100%; display: block; }
svg { max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

section { position: relative; }

/* ==========================================================================
   Utility
   ========================================================================== */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 16px;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent);
}

.section-head {
  max-width: 640px;
  margin-bottom: 56px;
}

.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.section-head p {
  color: var(--text-muted);
  font-size: 1.02rem;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Nav
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 20px;
  height: 20px;
  flex: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 30px;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.nav-links a:hover { color: var(--text); }

.nav-cta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.icon-btn svg { width: 16px; height: 16px; }

.nav-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.mobile-panel {
  display: none;
  position: fixed;
  inset: 68px 0 0 0;
  background: var(--bg);
  z-index: 99;
  padding: 32px 24px;
}

.mobile-panel.is-open { display: block; }

.mobile-panel a {
  display: block;
  padding: 16px 0;
  font-size: 1.3rem;
  border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 560;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { background: var(--accent); color: #14140f; }
}

:root[data-theme="dark"] .btn-primary { background: var(--accent); color: #14140f; }

.btn-primary:hover { background: var(--accent-strong); color: #fff; }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--text-muted); }

.btn svg { width: 16px; height: 16px; }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  padding: 168px 0 96px;
  background-image:
    radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0);
  background-size: 28px 28px;
  background-position: center top;
}

.hero-inner { max-width: 780px; }

.hero h1 {
  font-size: clamp(2.4rem, 5.4vw, 3.8rem);
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 22px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent-strong);
}

.hero .lede {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 620px;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 56px;
}

.stack-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stack-pill {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
}

/* Stats */

.stats {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.stat {
  padding: 32px 24px;
  border-left: 1px solid var(--border);
}

.stat:first-child { border-left: none; }

.stat .n {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  color: var(--accent-strong);
  display: block;
  margin-bottom: 4px;
}

.stat .l {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Generic section spacing
   ========================================================================== */

.section { padding: 108px 0; }
.section-alt { background: var(--bg-raised); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ==========================================================================
   Overview
   ========================================================================== */

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: start;
}

.overview-text p {
  color: var(--text-muted);
  margin-bottom: 18px;
}

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

.req-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.req-list li {
  display: flex;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.req-list .num {
  font-family: var(--font-mono);
  color: var(--accent-strong);
  font-size: 0.85rem;
  flex: none;
}

.req-list h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.req-list span.d {
  font-size: 0.87rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Architecture diagram
   ========================================================================== */

.arch-diagram {
  width: 100%;
  padding: 32px 8px 8px;
  overflow-x: auto;
}

.layer-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 48px;
}

.layer-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--bg-raised);
}

.layer-card .tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.tag-bronze { background: #f2e3d4; color: #8a5324; }
.tag-silver { background: #e8e7e2; color: #56544a; }
.tag-gold { background: var(--accent-soft); color: var(--accent-strong); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag-bronze { background: #2c2013; color: #e0a868; }
  :root:not([data-theme="light"]) .tag-silver { background: #232219; color: #c9c6b8; }
}

:root[data-theme="dark"] .tag-bronze { background: #2c2013; color: #e0a868; }
:root[data-theme="dark"] .tag-silver { background: #232219; color: #c9c6b8; }

.layer-card h3 { font-size: 1.05rem; margin-bottom: 10px; }
.layer-card p { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 14px; }

.layer-card code.pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  margin: 0 4px 4px 0;
  display: inline-block;
}

/* ==========================================================================
   Data model
   ========================================================================== */

.model-diagram {
  overflow-x: auto;
  padding: 8px 0 24px;
}

.model-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 8px;
}

.model-notes .note {
  padding: 20px;
  border-left: 2px solid var(--accent);
  background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.model-notes .note h4 { font-size: 0.95rem; margin-bottom: 8px; }
.model-notes .note p { font-size: 0.88rem; color: var(--text-muted); }

/* ==========================================================================
   Engineering cards
   ========================================================================== */

.eng-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.eng-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 26px;
  box-shadow: var(--shadow);
}

.eng-card h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.eng-card h3 .ix {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-strong);
}

.eng-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

pre.code {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
}

pre.code .kw { color: #e0ab3d; }
pre.code .cm { color: #7c7a6d; font-style: italic; }
pre.code .fn { color: #7fb0e0; }
pre.code .st { color: #a3d9a5; }

/* ==========================================================================
   Analytics
   ========================================================================== */

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.mini-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.mini-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.mini-card h4 {
  font-size: 0.94rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-card p { font-size: 0.85rem; color: var(--text-muted); }

.mini-card .go {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.reports-callout {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.report-card {
  padding: 24px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--accent-soft), transparent);
  border: 1px solid var(--border);
}

.report-card h4 { margin-bottom: 8px; font-size: 1rem; }
.report-card p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 12px; }
.report-card ul { display: flex; flex-wrap: wrap; gap: 6px; }
.report-card li {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
}

/* ==========================================================================
   Explore repo
   ========================================================================== */

.explore-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.explore-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.explore-card svg { width: 20px; height: 20px; color: var(--accent-strong); }
.explore-card h4 { font-size: 0.92rem; }
.explore-card p { font-size: 0.82rem; color: var(--text-muted); flex-grow: 1; }
.explore-card a { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent-strong); }
.explore-card a:hover { text-decoration: underline; }

/* ==========================================================================
   CTA / Contact
   ========================================================================== */

.cta {
  padding: 100px 0;
  text-align: center;
}

.cta h2 {
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  max-width: 620px;
  margin: 0 auto 18px;
}

.cta p { color: var(--text-muted); max-width: 520px; margin: 0 auto 32px; }
.cta .hero-actions { justify-content: center; margin-bottom: 0; }

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 22px;
  align-items: center;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer-links a:hover { color: var(--text); }
.footer-links svg { width: 15px; height: 15px; }

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 920px) {
  .overview-grid,
  .eng-grid,
  .analytics-grid,
  .reports-callout { grid-template-columns: 1fr; }
  .layer-cards { grid-template-columns: 1fr; }
  .model-notes { grid-template-columns: 1fr; }
  .explore-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: none; }
}

@media (max-width: 720px) {
  .nav-links, .nav-cta .icon-btn.gh-desktop { display: none; }
  .nav-toggle { display: inline-flex; }
  .hero { padding: 140px 0 72px; }
  .section { padding: 76px 0; }
  .explore-grid { grid-template-columns: 1fr; }
}
