:root {
  --bg: #05070a;
  --bg-alt: #0a0e14;
  --surface: #10151d;
  --surface-border: #1f2733;
  --text: #e7ecf3;
  --text-dim: #8b96a5;
  --accent: #dba928;
  --accent-dim: #8e6e1a;
  --accent-soft: rgba(219, 169, 40, 0.12);
  --accent-contrast: #1a1405;
  --danger: #ff5c5c;
  --header-bg: rgba(5, 7, 10, 0.75);
  --grid-line: rgba(255, 255, 255, 0.025);
  --glow: rgba(219, 169, 40, 0.15);
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --max-width: 1120px;
  --radius: 14px;
  color-scheme: dark;
}

/* Explicit dark override (matches the default above; lets a manual choice
   win over a "light" system preference when data-theme="dark" is set). */
:root[data-theme="dark"] {
  --bg: #05070a;
  --bg-alt: #0a0e14;
  --surface: #10151d;
  --surface-border: #1f2733;
  --text: #e7ecf3;
  --text-dim: #8b96a5;
  --accent: #dba928;
  --accent-dim: #8e6e1a;
  --accent-soft: rgba(219, 169, 40, 0.12);
  --accent-contrast: #1a1405;
  --danger: #ff5c5c;
  --header-bg: rgba(5, 7, 10, 0.75);
  --grid-line: rgba(255, 255, 255, 0.025);
  --glow: rgba(219, 169, 40, 0.15);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-alt: #eceff3;
  --surface: #ffffff;
  --surface-border: #dbe1e8;
  --text: #10151d;
  --text-dim: #59626e;
  --accent: #96721c;
  --accent-dim: #7a5c16;
  --accent-soft: rgba(150, 114, 28, 0.1);
  --accent-contrast: #ffffff;
  --danger: #c92a2a;
  --header-bg: rgba(246, 248, 250, 0.8);
  --grid-line: rgba(16, 21, 29, 0.04);
  --glow: rgba(150, 114, 28, 0.12);
  color-scheme: light;
}

/* "System" mode (no data-theme attribute set): follow the OS preference. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f6f8fa;
    --bg-alt: #eceff3;
    --surface: #ffffff;
    --surface-border: #dbe1e8;
    --text: #10151d;
    --text-dim: #59626e;
    --accent: #96721c;
    --accent-dim: #7a5c16;
    --accent-soft: rgba(150, 114, 28, 0.1);
    --accent-contrast: #ffffff;
    --danger: #c92a2a;
    --header-bg: rgba(246, 248, 250, 0.8);
    --grid-line: rgba(16, 21, 29, 0.04);
    --glow: rgba(150, 114, 28, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }

/* Prevents a flash of the wrong language for non-English visitors:
   i18n-init.js adds this class before paint only when it resolves a
   language other than English (the static markup is already English),
   and i18n.js removes it once translations are applied. */
html.i18n-loading body { visibility: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

code {
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  padding: 0.1em 0.4em;
  border-radius: 6px;
  font-size: 0.9em;
  color: var(--accent);
}

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

.accent { color: var(--accent); }

.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--surface-border);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-block;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  background-color: var(--accent);
  -webkit-mask: url('../img/logo-mark.png?v=1') center / contain no-repeat;
  mask: url('../img/logo-mark.png?v=1') center / contain no-repeat;
}

.nav {
  display: flex;
  gap: 28px;
  flex: 1;
  justify-content: center;
}

.nav a {
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

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

.nav-cta { white-space: nowrap; flex-shrink: 0; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.theme-icon {
  display: none;
  width: 18px;
  height: 18px;
}

.theme-toggle[data-pref="system"] .theme-icon-system,
.theme-toggle[data-pref="light"] .theme-icon-light,
.theme-toggle[data-pref="dark"] .theme-icon-dark {
  display: block;
}

.lang-toggle {
  display: flex;
  align-items: stretch;
  height: 36px;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-btn + .lang-btn {
  border-left: 1px solid var(--surface-border);
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

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

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover { background: #f0c65a; }

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

.btn-outline:hover { border-color: var(--accent-dim); }

.btn-ghost {
  border-color: var(--surface-border);
  color: var(--text-dim);
  padding: 9px 18px;
  font-size: 0.85rem;
}

.btn-ghost:hover { color: var(--text); border-color: var(--accent-dim); }

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  padding: 96px 0 72px;
  display: grid;
  gap: 48px;
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 20px;
}

.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  font-weight: 800;
}

.lede {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 620px;
  margin: 0 0 36px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 48px;
}

.hero-badge {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 32px;
}

.hero-badge img { display: block; }

.hero-stats {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  row-gap: 16px;
}

.stat { display: flex; flex-direction: column; }

.stat-num {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.hero-terminal {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  max-width: 720px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 24px 26px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  overflow-x: auto;
  box-shadow: 0 20px 60px -20px var(--glow);
}

.hero-terminal code { background: none; border: none; padding: 0; color: var(--text); }

.tk-c { color: var(--accent); }
.tk-ok { color: var(--accent); }
.tk-dim { color: var(--text-dim); }

/* Sections */
.section {
  position: relative;
  z-index: 1;
  padding: 88px 0;
  border-top: 1px solid var(--surface-border);
}

.section-alt { background: var(--bg-alt); }

.kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}

.section-lede {
  color: var(--text-dim);
  max-width: 680px;
  font-size: 1.05rem;
  margin: 0 0 40px;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 26px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.94rem;
}

/* Stack grid */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 36px;
}

.stack-col {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 24px 26px;
}

.stack-col h3 {
  margin: 0 0 16px;
  font-size: 0.95rem;
  color: var(--accent);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tag-list li {
  font-size: 0.94rem;
  padding-left: 18px;
  position: relative;
  color: var(--text);
}

.tag-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.cta-row { margin-top: 8px; }

/* Architecture diagram */
.arch-diagram {
  margin: 8px 0 32px;
  padding: 0;
}

.arch-diagram-scroll {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 4px;
}

.arch-diagram svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}

.arch-diagram figcaption {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 640px;
}

.arch-diagram figcaption code {
  font-size: 0.85em;
}

/* Pillars */
.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.pillar {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  position: relative;
}

.pillar-index {
  font-family: var(--font-mono);
  color: var(--accent-dim);
  font-size: 0.8rem;
  display: block;
  margin-bottom: 14px;
}

.pillar h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.pillar p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Contribute */
.contribute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.contribute-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 26px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

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

.contribute-card h3 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  color: var(--accent);
}

.contribute-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Contact */
.contact-inner { text-align: left; }

.contact-form {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}

.form-row input,
.form-row textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 12px 14px;
  resize: vertical;
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.form-row-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.contact-form .btn {
  align-self: flex-start;
}

.form-status {
  margin: 0;
  font-size: 0.9rem;
}

.form-status[data-state="success"] { color: var(--accent); }
.form-status[data-state="error"] { color: var(--danger); }

.contact-fallback {
  color: var(--text-dim);
  font-size: 0.92rem;
}

.contact-fallback a { color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--surface-border);
  padding: 32px 0;
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

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

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-privacy {
  margin: 12px auto 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  max-width: var(--max-width);
}

.footer-privacy a { color: var(--text-dim); text-decoration: underline; }
.footer-privacy a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 860px) {
  .hero { padding: 64px 0 48px; }
  .header-inner { justify-content: space-between; gap: 12px; }

  .nav-toggle { display: flex; order: 3; }

  .nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    padding: 16px 24px 20px;
  }

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

  .nav a { padding: 10px 0; font-size: 1rem; }

  .nav-cta { order: 2; }
}

@media (max-width: 480px) {
  /* The hero already has its own "View the project on GitHub" CTA, so the
     header's ghost-button duplicate is dropped once space gets tight. */
  .nav-cta { display: none; }
}

@media (max-width: 560px) {
  .hero-stats { flex-wrap: wrap; row-gap: 16px; }
  .hero-terminal { font-size: 0.78rem; padding: 18px; }
}
