/* ─── Self-hosted fonts ──────────────────────────────────────── */
@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/jetbrains-mono-latin-ext-400-normal.woff2") format("woff2"),
       url("../assets/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/jetbrains-mono-latin-ext-600-normal.woff2") format("woff2"),
       url("../assets/fonts/jetbrains-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/jetbrains-mono-latin-ext-700-normal.woff2") format("woff2"),
       url("../assets/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  --bg:      #0f0f0f;
  --surface: #1a1a1a;
  --border:  #2a2a2a;
  --text:    #e8e6e0;
  --muted:   #888880;
  --accent:  #c8a96e;
  --green:   #6ab187;
  --amber:   #d4924a;
  --red:     #c0645a;

  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  --font-serif: "iA Writer Quattro", Georgia, "Times New Roman", serif;

  --max-width: 720px;
  --px: 1.5rem;
  --nav-h: 60px;
}

/* ─── Base ──────────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h3 { font-size: 1.1rem; color: var(--accent); }
h4 { font-size: 1rem; }

p { max-width: 66ch; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover { opacity: 0.8; }

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

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

/* ─── Layout ────────────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--px);
}

section {
  padding: 4rem 0;
}

/* ─── Navigation ─────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, backdrop-filter 0.2s, background 0.2s;
}

.site-nav.scrolled {
  border-color: var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(15, 15, 15, 0.85);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--px);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 2rem;
}

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

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

.nav-menu a.nav-github {
  color: var(--accent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
  transform-origin: center;
}

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

/* ─── Hero ───────────────────────────────────────────────────── */
.hero {
  padding: 5rem 0 4rem;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.hero-tagline {
  margin-bottom: 1.5rem;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 54ch;
  margin-bottom: 2.5rem;
}

.store-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
  min-width: 160px;
}

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

.store-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.store-btn-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.store-btn-text small {
  font-size: 0.7rem;
  opacity: 0.65;
  font-weight: 400;
}

.store-btn-text strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.hero-note {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 2px solid var(--border);
  padding-left: 0.875rem;
  margin-top: 0.25rem;
}

/* ─── Problem strip ──────────────────────────────────────────── */
.problems {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.problem-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.problem-list li {
  font-size: 1.05rem;
  color: var(--muted);
  padding-left: 1.5rem;
  position: relative;
}

.problem-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--border);
}

/* ─── Features ───────────────────────────────────────────────── */
.features {
  padding: 4rem 0;
}

.features-grid {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.feature {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.feature-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--border);
  letter-spacing: 0.1em;
}

.feature-title {
  margin: 0;
}

.feature-body {
  color: var(--muted);
  max-width: 60ch;
}

.feature-artifact {
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.feature-artifact pre,
.feature-artifact table {
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

.feature-artifact table {
  width: 100%;
  border-collapse: collapse;
}

.feature-artifact th {
  text-align: left;
  color: var(--text);
  font-weight: 600;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.feature-artifact td {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  vertical-align: middle;
}

.feature-artifact tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15em 0.5em;
  border-radius: 3px;
}

.badge--green  { background: rgba(106,177,135,0.15); color: var(--green); }
.badge--amber  { background: rgba(212,146,74,0.15);  color: var(--amber); }
.badge--red    { background: rgba(192,100,90,0.15);  color: var(--red); }
.badge--muted  { background: rgba(136,136,128,0.15); color: var(--muted); }

/* ─── Schema callout ─────────────────────────────────────────── */
.schema-callout {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
}

.schema-callout pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.schema-callout .json-key   { color: var(--text); }
.schema-callout .json-str   { color: var(--accent); }
.schema-callout .json-num   { color: var(--green); }

.schema-note {
  font-size: 0.9rem;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  font-style: italic;
}

.schema-note a {
  color: var(--accent);
}

/* ─── Download strip ─────────────────────────────────────────── */
.download-strip {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.download-strip h2 {
  margin-bottom: 0.5rem;
}

.download-strip .strip-sub {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.download-strip .store-buttons {
  justify-content: center;
}

.download-strip .strip-meta {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--px);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--text);
  opacity: 1;
}

/* ─── Prose (privacy / docs) ─────────────────────────────────── */
.page-header {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.page-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: 0.5rem;
}

.page-header .page-sub {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.prose {
  padding-bottom: 5rem;
}

.prose section {
  padding: 0;
  margin-bottom: 3rem;
}

.prose h2 {
  font-size: 1.2rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1rem;
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

.prose p {
  color: var(--muted);
  margin-bottom: 0.875rem;
}

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

.prose ul, .prose ol {
  padding-left: 1.5rem;
  color: var(--muted);
  margin-bottom: 0.875rem;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li {
  margin-bottom: 0.3rem;
}

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

/* ─── Docs: in-page TOC ──────────────────────────────────────── */
.docs-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 3rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.docs-toc-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.docs-toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  padding: 0;
  list-style: none;
}

.docs-toc a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.docs-toc a:hover {
  color: var(--accent);
  opacity: 1;
}

.docs-section {
  margin-bottom: 3.5rem;
}

.docs-section h2 {
  font-size: 1.15rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

.docs-qa {
  margin-bottom: 1.75rem;
}

.docs-qa dt {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.docs-qa dt::before {
  content: "Q  ";
  color: var(--accent);
  font-weight: 600;
}

.docs-qa dd {
  color: var(--muted);
  padding-left: 1.5rem;
  font-size: 0.95rem;
}

.docs-qa dd a {
  color: var(--accent);
}

/* ─── 404 ────────────────────────────────────────────────────── */
.not-found {
  min-height: calc(100vh - var(--nav-h) - 100px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 0;
}

.not-found-code {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 1rem;
}

.not-found h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  margin-bottom: 0.75rem;
}

.not-found p {
  color: var(--muted);
  margin-bottom: 2rem;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 0.6rem 1.25rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.btn-back:hover {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
}

/* ─── Scroll fade-in ─────────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ─── Skip link ──────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--bg);
  outline-offset: -4px;
}

/* ─── Focus visible ───────────────────────────────────────────── */
*:focus {
  outline: none;
}
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
/* Store buttons have a light background — use a dark outline instead */
.store-btn:focus-visible {
  outline-color: #3a2e10;
}
/* Back button fills on focus — outline would be redundant */
.btn-back:focus-visible {
  background: var(--accent);
  color: var(--bg);
  outline: none;
}

/* ─── Nav list items ─────────────────────────────────────────── */
.nav-menu > li {
  display: flex;
  align-items: center;
}

/* ─── Language switcher ──────────────────────────────────────── */
.nav-lang-item {
  margin-left: 0.25rem;
}

.lang-switcher {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.15s, border-color 0.15s;
}

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

.lang-btn svg {
  width: 10px;
  height: 10px;
  transition: transform 0.15s;
}

.lang-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.375rem 0;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  list-style: none;
}

.lang-menu [role="option"] button {
  display: block;
  width: 100%;
  padding: 0.45rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.lang-menu [role="option"] button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lang-menu [aria-selected="true"] button {
  color: var(--accent);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --px: 1.125rem; }

  section { padding: 3rem 0; }

  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem var(--px);
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }

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

  .nav-menu a {
    font-size: 0.95rem;
  }

  .nav-toggle {
    display: flex;
  }

  .site-nav {
    position: sticky;
  }

  .hero { padding: 3.5rem 0 3rem; }

  .store-buttons { gap: 0.75rem; }

  .store-btn { min-width: 140px; }

  .download-strip .store-buttons { justify-content: flex-start; }
  .download-strip { text-align: left; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

  .docs-toc ul { flex-direction: column; }

  .nav-lang-item { margin-left: 0; width: 100%; }

  .lang-menu {
    position: static;
    box-shadow: none;
    margin-top: 0.5rem;
    width: 100%;
  }

  .feature-artifact pre,
  .feature-artifact table {
    font-size: 0.72rem;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  :root { --px: 1.25rem; }
}
