/* ── reset + base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --blue:      #58a6ff;
  --blue-dim:  #1f6feb;
  --green:     #3fb950;
  --purple:    #d2a8ff;
  --orange:    #ffa657;
  --red:       #f78166;
  --yellow:    #e3b341;
  --radius:    8px;
  --radius-lg: 14px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace,
               'SFMono-Regular', 'Menlo', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: #388bfd44; color: var(--text); }

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: #79c0ff; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg3);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--blue);
}

/* ── nav ─────────────────────────────────────────────────────────────────── */
#nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: transparent;
  z-index: 100;
  transition: background var(--transition), border-bottom var(--transition),
              backdrop-filter var(--transition);
}

#nav.scrolled {
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--muted);
  font-family: var(--font-mono);
  transition: color var(--transition);
}
.nav-links a:hover { color: var(--text); }

.nav-gh {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted) !important;
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  transition: color var(--transition), border-color var(--transition) !important;
}
.nav-gh:hover { color: var(--text) !important; border-color: var(--text) !important; }

/* ── hero ────────────────────────────────────────────────────────────────── */
#hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem 4rem;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#mesh-canvas {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.85;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 780px;
}

.hero-logo {
  margin-bottom: 1.5rem;
  animation: fadeUp 0.7s ease both;
}

.hero-logo-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 20px;
  filter: drop-shadow(0 0 32px #58a6ff44);
}

h1 {
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 10vw, 6.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  margin-bottom: 1.25rem;
  animation: fadeUp 0.8s 0.1s ease both;
}

.hero-tagline {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  animation: fadeUp 0.8s 0.2s ease both;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
  animation: fadeUp 0.8s 0.3s ease both;
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius);
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--blue);
  color: var(--bg);
}
.btn-primary:hover { background: #79c0ff; color: var(--bg); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--text); transform: translateY(-1px); }

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  animation: fadeUp 0.8s 0.4s ease both;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 2rem;
}
.stat-n {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-l {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.3rem;
  white-space: nowrap;
}
.stat-sep {
  width: 1px;
  height: 36px;
  background: var(--border);
}

.hero-scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  animation: pulse 2s ease-in-out infinite;
  z-index: 1;
}

/* ── sections ────────────────────────────────────────────────────────────── */
.section {
  padding: 5rem 0;
}
.section-dark {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}
.section-header h2 {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.section-header p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ── concepts grid ───────────────────────────────────────────────────────── */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.concept-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color var(--transition), transform var(--transition);
}
.concept-card:hover {
  border-color: var(--blue-dim);
  transform: translateY(-2px);
}
.concept-icon {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--blue);
  opacity: 0.8;
}
.concept-card h3 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6rem;
}
.concept-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── architecture tabs ───────────────────────────────────────────────────── */
.arch-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.docs-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.tab-btn, .doc-tab-btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover, .doc-tab-btn:hover {
  color: var(--text);
  border-color: var(--text);
}
.tab-btn.active, .doc-tab-btn.active {
  background: var(--blue);
  color: var(--bg);
  border-color: var(--blue);
  font-weight: 700;
}

.tab-content, .doc-content { display: none; }
.tab-content.active, .doc-content.active { display: block; }

/* ── diagrams ────────────────────────────────────────────────────────────── */
.diagram-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0d1117;
}
.diagram-wrap img {
  width: 100%;
  height: auto;
  display: block;
}
.diagram-caption {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ── flow steps ──────────────────────────────────────────────────────────── */
.flow-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.flow-steps::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.flow-step {
  display: flex;
  gap: 2rem;
  padding: 2rem 0 2rem 0;
  position: relative;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--blue);
  background: var(--bg);
  border: 1px solid var(--blue-dim);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.step-body h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.step-body p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.code-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  color: var(--green);
  word-break: break-all;
}

/* ── keys section ────────────────────────────────────────────────────────── */
.keys-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

.key-tree-svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
}

.key-tree {
  padding: 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.kt-root {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.kt-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}
.kt-sub {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.kt-ed    { border-color: var(--purple); color: var(--purple); background: #d2a8ff11; }
.kt-wg    { border-color: var(--blue);   color: var(--blue);   background: #58a6ff11; }
.kt-id    { border-color: var(--green);  color: var(--green);  background: #3fb95011; }
.kt-sig   { border-color: var(--orange); color: var(--orange); background: #ffa65711; }

.kt-branches {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
}

.kt-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.kt-connector {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin-bottom: 0;
}

.key-fact {
  margin-bottom: 1.75rem;
}
.key-fact:last-child { margin-bottom: 0; }
.key-fact h4 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.key-fact p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── DNS table ───────────────────────────────────────────────────────────── */
.dns-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-top: 2rem;
}

.dns-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dns-table th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.9rem 1.2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.dns-table td {
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}
.dns-table tr:last-child td { border-bottom: none; }
.dns-table tr:hover td { background: var(--bg2); }
.dns-table td:last-child { color: var(--muted); font-size: 0.83rem; }

.badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-blue   { background: #58a6ff22; color: var(--blue);   border: 1px solid #58a6ff44; }
.badge-green  { background: #3fb95022; color: var(--green);  border: 1px solid #3fb95044; }
.badge-purple { background: #d2a8ff22; color: var(--purple); border: 1px solid #d2a8ff44; }
.badge-orange { background: #ffa65722; color: var(--orange); border: 1px solid #ffa65744; }
.badge-red    { background: #f7816622; color: var(--red);    border: 1px solid #f7816644; }

/* ── vlans ───────────────────────────────────────────────────────────────── */
.vlan-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

.vlan-vis {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vlan-box {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  background: var(--bg);
}

.vlan-prod   { border-color: #58a6ff44; }
.vlan-storage { border-color: #3fb95044; }

.vlan-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.vlan-nodes {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.vlan-node {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.vlan-node span { color: var(--muted); font-size: 0.75rem; }
.vlan-node.shared {
  border-color: var(--green);
  color: var(--green);
}
.vlan-node.shared span { color: #3fb95099; }

.vlan-note {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.75rem 1rem;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── docs ────────────────────────────────────────────────────────────────── */
.doc-block {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.doc-block h4 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.75rem 1.25rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.doc-block pre {
  margin: 0;
  padding: 1.25rem 1.5rem;
  background: var(--bg);
  overflow-x: auto;
}
.doc-block code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: transparent;
  padding: 0;
  color: var(--text);
  line-height: 1.7;
  white-space: pre;
}
.doc-block code .cm { color: var(--muted); }
.doc-block code .cv { color: var(--orange); }

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

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

.footer-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-links a {
  font-size: 0.875rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.footer-links a:hover { color: var(--text); }

.footer-note {
  font-size: 0.78rem;
  color: var(--muted);
  width: 100%;
  text-align: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

/* ── reveal animation ────────────────────────────────────────────────────── */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── keyframes ───────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1; }
}

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links a:not(.nav-gh):not(:last-child) { display: none; }
  .keys-layout, .vlan-layout { grid-template-columns: 1fr; }
  .kt-branches { flex-direction: column; align-items: center; }
  .kt-connector { height: 16px; }
  .stat { padding: 0 1rem; }
  .flow-steps::before { display: none; }
  .flow-step { flex-direction: column; gap: 1rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
