/* ---------- Tokens ---------- */
:root {
  --bg: #05080d;
  --bg-elev: #0a0f16;
  --bg-card: #0d141d;
  --line: #1b2836;
  --line-strong: #2a3b4e;
  --text: #e6edf3;
  --muted: #93a4b5;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.14);
  --accent-ink: #04222a;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --gutter: 16px;
  --header-h: 64px;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); font-weight: 750; }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); font-weight: 700; }
h3 { font-size: clamp(1.3rem, 2.6vw, 1.75rem); font-weight: 700; }
p { margin: 0; }

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

.skip-link {
  position: absolute; left: var(--gutter); top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 6px; font-weight: 600;
}
.skip-link:focus { top: 8px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 14px;
}
.lead { color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 60ch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  font-weight: 600; font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #67e8f9; }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(5, 8, 13, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.logo { white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.logo:hover { text-decoration: none; }
.logo-mark { color: var(--accent); }

.main-nav { display: flex; gap: 26px; }
.main-nav a { color: var(--muted); font-size: 0.93rem; font-weight: 500; }
.main-nav a:hover { color: var(--text); text-decoration: none; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}
.lang-switch button {
  background: transparent; color: var(--muted);
  border: 0; padding: 6px 11px;
  font: 600 0.78rem var(--mono); letter-spacing: 0.06em;
  cursor: pointer;
}
.lang-switch button + button { border-left: 1px solid var(--line-strong); }
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.menu-toggle {
  display: none;
  width: 40px; height: 36px;
  background: transparent; border: 1px solid var(--line-strong); border-radius: 8px;
  cursor: pointer; padding: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.menu-toggle span { width: 16px; height: 2px; background: var(--text); border-radius: 1px; }

/* ---------- Hero ---------- */
.hero { padding: clamp(40px, 8vw, 96px) 0 clamp(32px, 6vw, 72px); }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; align-items: center; }
.hero-copy h1 { margin-bottom: 20px; }
.hero-copy .lead { margin-bottom: 28px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 36px; }

.stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin: 0; padding-top: 24px; border-top: 1px solid var(--line); }
.stats dt { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 650; }

.hero-visual, .project-visual { margin: 0; min-width: 0; }

/* ---------- Frames ---------- */
.frame {
  background: #000;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.04), 0 30px 80px -20px rgba(34, 211, 238, 0.18), 0 10px 30px rgba(0, 0, 0, 0.5);
}
.frame img, .frame svg { width: 100%; }
.frame-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  font: 0.75rem var(--mono); color: var(--muted);
}
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.frame-title { flex: 1; text-align: center; padding-right: 45px; }
.frame-browser { border-radius: 12px; }

/* ---------- Sections ---------- */
.section { padding: clamp(48px, 8vw, 96px) 0; }
.section-last { padding-bottom: clamp(56px, 9vw, 112px); }
.section-head { margin-bottom: clamp(32px, 5vw, 56px); }
.section-head h2 { margin-bottom: 14px; }

/* ---------- Family diagram ---------- */
.fit { display: flex; flex-direction: column; align-items: center; }
.fit-core {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 16px 32px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-dim);
  text-align: center;
  font-family: var(--mono);
}
.fit-core strong { font-size: 1.15rem; color: var(--accent); }
.fit-core span { font-size: 0.8rem; color: var(--muted); }

.fit-branches {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
  width: 100%; margin-top: 44px;
}
.fit-branches::before {               /* trunk from the core box */
  content: ""; position: absolute; left: 50%; top: -44px; width: 1px; height: 44px;
  background: var(--accent);
}
.fit-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.fit-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.fit-card p { color: var(--muted); font-size: 0.93rem; }
.fit-name { font: 700 1.05rem var(--mono); color: var(--accent); }
.fit-kind { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }

/* ---------- Projects ---------- */
.project {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: center;
  padding: clamp(28px, 5vw, 56px) 0;
  border-top: 1px solid var(--line);
}
.project:first-of-type { border-top: 0; padding-top: 0; }
.project-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.project-copy > p:not(.tag) { color: var(--muted); }
.tag {
  font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); background: var(--accent-dim);
  padding: 4px 10px; border-radius: 999px;
}

.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ticks li { position: relative; padding-left: 26px; }
.ticks li::before {
  content: ""; position: absolute; left: 3px; top: 0.5em;
  width: 10px; height: 5px;
  border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.project-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.badges { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.badges li {
  font: 0.75rem var(--mono); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 9px;
}

/* ---------- Quick start ---------- */
.tabs { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-card); overflow: hidden; }
.tab-list { display: flex; border-bottom: 1px solid var(--line); background: var(--bg-elev); overflow-x: auto; }
.tab-list button {
  flex: 1 0 auto;
  padding: 14px 22px;
  background: transparent; color: var(--muted);
  border: 0; border-bottom: 2px solid transparent;
  font: 600 0.9rem var(--mono);
  cursor: pointer;
}
.tab-list button:hover { color: var(--text); }
.tab-list button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg-card); }
.tab-panel { padding: clamp(18px, 3vw, 28px); display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.tab-panel[hidden] { display: none; }
.tab-panel > p { color: var(--muted); max-width: 70ch; }

.code { position: relative; }
.code pre {
  margin: 0; padding: 20px 18px;
  background: #000; border: 1px solid var(--line); border-radius: 8px;
  overflow-x: auto;
  font: 0.86rem/1.7 var(--mono); color: #cfe3ee;
  tab-size: 2;
}
.code code { font: inherit; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--bg-elev); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 4px 10px; font: 0.72rem var(--mono);
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.is-done { color: var(--accent); border-color: var(--accent); }

/* ---------- Limits ---------- */
.limits { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.limits li {
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
}
.limits h3 { font-size: 1.05rem; margin-bottom: 8px; }
.limits p { color: var(--muted); font-size: 0.95rem; }

/* ---------- Open source ---------- */
.oss {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: center;
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-dim), transparent 60%), var(--bg-card);
}
.oss h2 { margin-bottom: 14px; }
.oss p:not(.eyebrow) { color: var(--muted); max-width: 62ch; }
.oss-links { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.footer-links { display: flex; gap: 20px; }
.footer-links a[hidden] { display: none; }
.site-footer strong { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 819px) {
  .menu-toggle { display: inline-flex; }
  .main-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    display: none; flex-direction: column; gap: 0;
    background: rgba(5, 8, 13, 0.98);
    border-bottom: 1px solid var(--line);
    padding: 8px var(--gutter) 16px;
  }
  .main-nav.is-open { display: flex; }
  .main-nav a { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 1rem; }
  .main-nav a:last-child { border-bottom: 0; }
}

@media (min-width: 820px) {
  :root { --gutter: 24px; }
  .hero-inner { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; }
  .fit-branches { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .fit-branches::before { height: 24px; }
  .fit-branches::after {              /* horizontal bar joining the three branches */
    content: ""; position: absolute; left: calc(100% / 6); right: calc(100% / 6); top: -20px; height: 1px;
    background: var(--accent);
  }
  .fit-card::before {                 /* drop from the bar to each card */
    content: ""; position: absolute; left: 50%; top: -20px; width: 1px; height: 20px;
    background: var(--accent);
  }
  .project { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 56px; }
  .project-flip .project-copy { order: 2; }
  .project-flip .project-visual { order: 1; }
  .limits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .oss { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .oss-links { justify-content: flex-end; }
}

@media (min-width: 1000px) {
  .limits { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 400px) {
  .header-inner { gap: 8px; }
  .logo { font-size: 0.85rem; gap: 6px; }
  .logo-mark { width: 18px; height: 18px; }
  .header-actions { gap: 6px; }
  .lang-switch button { padding: 6px 8px; }
  .menu-toggle { width: 36px; }
}

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