/* ═══════════════════════════════════════════
   Web7 Foundation — Shared Stylesheet v1.0
   ═══════════════════════════════════════════ */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface2: #f4f4f5;
  --border: #e4e4e7;
  --text: #09090b;
  --muted: #71717a;
  --subtle: #a1a1aa;
  --accent: #6c47ff;
  --accent-light: #ede9fe;
  --green: #059669;
  --green-light: #d1fae5;
  --orange: #ea580c;
  --red: #dc2626;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 10px;
  --radius-lg: 16px;
  --nav-h: 64px;
  --max-w: 1100px;
  --content-w: 760px;
}

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

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

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

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

/* ── NAV ──────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,250,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  will-change: transform;
  transform: translateZ(0);
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.nav-logo .logo-mark {
  width: 28px;
  height: 28px;
  background: var(--text);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.04em;
}
.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}
.nav-links a {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}
.nav-cta {
  margin-left: auto;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--text); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }

/* ── LAYOUT ───────────────────────────────── */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.content { max-width: var(--content-w); margin: 0 auto; padding: 0 24px; }

/* ── PAGE HERO ─────────────────────────────── */
.page-hero {
  padding: 80px 0 64px;
  border-bottom: 1px solid var(--border);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.badge-protocol { background: var(--accent-light); color: var(--accent); }
.badge-docs { background: var(--green-light); color: var(--green); }
.badge-rfc { background: #fef3c7; color: #92400e; }
.badge-version { background: var(--surface2); color: var(--muted); }
h1.hero-title {
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 20px;
}
.hero-sub {
  font-size: 20px;
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 32px;
  line-height: 1.5;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── SECTIONS ──────────────────────────────── */
section { padding: 64px 0; }
section + section { border-top: 1px solid var(--border); }
.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
h2.section-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
h3.subsection { font-size: 20px; font-weight: 600; margin: 40px 0 12px; letter-spacing: -0.01em; }
.section-desc { font-size: 17px; color: var(--muted); max-width: 560px; margin-bottom: 40px; }

/* ── CARDS ─────────────────────────────────── */
.cards { display: grid; gap: 16px; }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: 0 8px 32px rgba(0,0,0,0.07); transform: translateY(-2px); }
.card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
  background: var(--surface2);
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.card p { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.5; }
.card-link { display: block; color: var(--text); text-decoration: none; }
.card-link:hover { text-decoration: none; }

/* ── CODE BLOCKS ───────────────────────────── */
pre, code {
  font-family: var(--mono);
  font-size: 13px;
}
code:not(pre code) {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.88em;
  color: var(--accent);
}
pre {
  background: #0a0a0a;
  color: #d4d4d4;
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-x: auto;
  margin: 24px 0;
  line-height: 1.7;
}
pre code { color: inherit; background: none; border: none; padding: 0; font-size: 13px; }
.code-block { position: relative; }
.code-label {
  position: absolute;
  top: 12px; right: 16px;
  font-size: 11px;
  color: #666;
  font-family: var(--mono);
}
.token-keyword { color: #c792ea; }
.token-string { color: #c3e88d; }
.token-comment { color: #546e7a; font-style: italic; }
.token-type { color: #82aaff; }
.token-fn { color: #82aaff; }
.token-number { color: #f78c6c; }
.token-property { color: #ffcb6b; }

/* ── TABLES ─────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 24px 0; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--surface2); font-weight: 600; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.check { color: var(--green); font-weight: 700; }
.cross { color: var(--red); }

/* ── SPEC BLOCKS ────────────────────────────── */
.spec-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 24px 0;
}
.spec-block-header {
  padding: 16px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.spec-block-body { padding: 20px; }
.spec-row {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.spec-row:last-child { border-bottom: none; }
.spec-key { font-family: var(--mono); font-size: 13px; color: var(--accent); min-width: 140px; flex-shrink: 0; }
.spec-val { color: var(--muted); }
.spec-type { font-size: 12px; color: var(--subtle); font-family: var(--mono); margin-top: 2px; }

/* ── CALLOUTS ───────────────────────────────── */
.callout {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 24px 0;
  font-size: 14px;
  border: 1px solid;
}
.callout-info { background: var(--accent-light); border-color: #c4b5fd; color: #4c1d95; }
.callout-success { background: var(--green-light); border-color: #6ee7b7; color: #064e3b; }
.callout-warning { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ── STEPS / TIMELINE ───────────────────────── */
.steps { display: flex; flex-direction: column; gap: 0; position: relative; }
.step {
  display: flex;
  gap: 20px;
  padding-bottom: 32px;
  position: relative;
}
.step:last-child { padding-bottom: 0; }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.step::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  width: 2px;
  height: calc(100% - 32px);
  background: var(--border);
}
.step:last-child::before { display: none; }
.step-content { padding-top: 4px; }
.step-content h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.step-content p { font-size: 14px; color: var(--muted); margin: 0; }

/* ── MILESTONE TABLE ────────────────────────── */
.milestone-row { position: relative; }
.milestone-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-right: 6px;
}
.milestone-dot.done { background: var(--green); }
.milestone-dot.planned { background: var(--subtle); }
.phase-header { background: var(--accent-light) !important; font-weight: 600; }
.phase-header td { color: var(--accent); }

/* ── PROTOCOL NAV (sidebar-like) ─────────────── */
.layout-proto {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  padding: 48px 0;
  align-items: start;
}
.proto-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}
.proto-nav-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  padding: 8px 12px;
}
.proto-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.proto-nav a:hover, .proto-nav a.active {
  color: var(--text);
  background: var(--surface2);
}
.proto-nav a.active { font-weight: 500; }
.proto-content { min-width: 0; }
.proto-content h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 48px 0 16px; }
.proto-content h2:first-child { margin-top: 0; }
.proto-content h3 { font-size: 19px; font-weight: 600; margin: 32px 0 12px; }
.proto-content p { margin-bottom: 16px; color: #333; line-height: 1.7; }
.proto-content ul, .proto-content ol { margin: 12px 0 16px 20px; }
.proto-content li { margin-bottom: 6px; font-size: 15px; color: #333; line-height: 1.6; }

/* ── RFC ────────────────────────────────────── */
.rfc-card {
  display: flex;
  gap: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: box-shadow 0.2s;
  text-decoration: none;
  color: var(--text);
}
.rfc-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); text-decoration: none; }
.rfc-num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  padding-top: 2px;
}
.rfc-info h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.rfc-info p { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.rfc-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.tag-draft { background: #fef3c7; color: #92400e; }
.tag-active { background: var(--green-light); color: var(--green); }
.tag-final { background: var(--accent-light); color: var(--accent); }
.tag-withdrawn { background: var(--surface2); color: var(--subtle); }

/* ── STACK DIAGRAM ──────────────────────────── */
.stack-diagram {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}
.stack-layer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.15s;
}
.stack-layer:last-child { border-bottom: none; }
.stack-layer:hover { background: rgba(255,255,255,0.04) !important; }
.layer-num {
  font-size: 11px;
  font-weight: 700;
  color: #666;
  min-width: 24px;
}
.layer-name {
  font-weight: 700;
  min-width: 160px;
  color: #e4e4e7;
}
.layer-desc { color: #a1a1aa; font-size: 12px; flex: 1; }
.layer-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(108,71,255,0.25);
  color: #c4b5fd;
}
.l0 { background: #0f172a; }
.l1 { background: #0f1a2e; }
.l2 { background: #0f1e35; }
.l3 { background: #10223c; }
.l4 { background: #111f44; }
.l5 { background: #12234c; }
.l6 { background: #132754; }
.l7 { background: #142b5c; }

/* ── FOOTER ─────────────────────────────────── */
footer {
  background: var(--text);
  color: #a1a1aa;
  padding: 60px 0 40px;
  margin-top: 80px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 40px;
  margin-bottom: 48px;
}
.footer-col h4 {
  font-size: 13px;
  font-weight: 600;
  color: #e4e4e7;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}
.footer-col a {
  display: block;
  font-size: 13px;
  color: #71717a;
  margin-bottom: 8px;
  text-decoration: none;
  transition: color 0.15s;
}
.footer-col a:hover { color: #e4e4e7; text-decoration: none; }
.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid #27272a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}
.footer-logo {
  font-weight: 700;
  color: #e4e4e7;
  font-size: 14px;
  letter-spacing: -0.01em;
}

/* ── UTILITY ─────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-40 { margin-top: 40px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-40 { margin-bottom: 40px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: var(--mono); }
.divider { border: none; border-top: 1px solid var(--border); margin: 48px 0; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .layout-proto { grid-template-columns: 1fr; }
  .proto-sidebar { display: none; }
  h1.hero-title { font-size: 36px; }
  .hero-sub { font-size: 16px; }
  .cards-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stack-layer { flex-wrap: wrap; }
  .layer-name { min-width: unset; }
}
