:root {
  color-scheme: dark;
  --bg: #10100f;
  --panel: #1b1c1a;
  --panel-strong: #25241f;
  --text: #f6f1e4;
  --muted: #b8b0a0;
  --line: rgba(246, 241, 228, 0.18);
  --teal: #39d4c5;
  --green: #8fe388;
  --amber: #f0b84a;
  --coral: #f06f5f;
  --ink: #080808;
  --max: 1160px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(246, 241, 228, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246, 241, 228, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 8px 10px;
  background: var(--text);
  color: var(--ink);
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: rgba(16, 16, 15, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.top-nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--teal);
  box-shadow: inset 0 0 0 4px var(--bg), 0 0 18px rgba(57, 212, 197, 0.4);
}

.top-nav {
  gap: clamp(10px, 2vw, 22px);
  color: var(--muted);
  font-size: 0.95rem;
}

.top-nav a {
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  color: var(--text);
}

.hero {
  position: relative;
  min-height: min(780px, 88vh);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

#topologyCanvas,
#cleanTopologyCanvas,
#protocolTopologyCanvas,
.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#topologyCanvas {
  opacity: 0.64;
}

.map-canvas {
  opacity: 0;
  transition: opacity 260ms ease;
}

.map-canvas.active {
  opacity: 1;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(16, 16, 15, 0.94), rgba(16, 16, 15, 0.58) 48%, rgba(16, 16, 15, 0.2));
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(118px, 16vh, 168px) clamp(18px, 4vw, 48px) 130px;
}

.eyebrow,
.domain-label,
.mode-label {
  margin: 0 0 12px;
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(3.8rem, 10vw, 8.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  max-width: 780px;
  margin-bottom: 22px;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.16rem;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.42rem);
}

.signal-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  max-width: 680px;
  color: var(--text);
  font-size: clamp(1rem, 1.8vw, 1.28rem);
}

.signal-word {
  color: var(--teal);
  font-weight: 800;
}

.signal-word.swap {
  animation: text-scan 420ms ease both;
}

@keyframes text-scan {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.button.primary {
  background: var(--teal);
  color: var(--ink);
  border-color: var(--teal);
}

.button.secondary {
  background: rgba(246, 241, 228, 0.06);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mode-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(246, 241, 228, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.mode-button.active,
.mode-button:focus-visible {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.topology-caption {
  min-height: 48px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.section {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(64px, 10vw, 112px) 0;
  scroll-margin-top: 82px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 6vw, 72px);
  align-items: start;
}

.topology-grid,
.domain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.topology-grid article,
.domain-card {
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.topology-grid article:nth-child(2),
.domain-card.featured {
  background: var(--panel-strong);
}

.topology-grid p,
.domain-card p,
.docs-section p,
.flow-list p,
.section-heading p {
  color: var(--muted);
}

.section-heading {
  margin-bottom: 28px;
}

.live-map-section {
  width: min(1520px, calc(100% - 36px));
}

.map-stage {
  display: grid;
  gap: 18px;
}

.map-stage-heading {
  display: grid;
  grid-template-columns: minmax(0, 0.58fr) minmax(260px, 0.42fr);
  gap: clamp(18px, 4vw, 46px);
  align-items: end;
}

.map-stage-heading h3 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 3.25rem);
  line-height: 1.02;
}

.map-stage-heading p {
  margin-bottom: 4px;
  color: var(--muted);
}

.map-theater {
  position: relative;
  min-height: clamp(640px, 74vw, 880px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10100f;
}

.map-theater::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(16, 16, 15, 0.08), rgba(16, 16, 15, 0.28)),
    radial-gradient(circle at 50% 50%, transparent 0 56%, rgba(16, 16, 15, 0.42) 100%);
}

.map-tabs {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 16, 15, 0.72);
  backdrop-filter: blur(18px);
}

.map-tab {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
}

.map-tab.active,
.map-tab:focus-visible {
  border-color: var(--teal);
  background: rgba(57, 212, 197, 0.12);
  color: var(--text);
}

.map-theater-controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 16, 15, 0.78);
  backdrop-filter: blur(18px);
}

.map-control-panel {
  display: grid;
  grid-template-columns: 84px minmax(0, 650px) minmax(280px, 1fr);
  gap: 12px;
  align-items: center;
}

.map-control-panel[hidden] {
  display: none;
}

.map-control-panel .mode-label,
.map-control-panel .topology-caption {
  margin: 0;
}

.protocol-segmented {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.domain-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.domain-card {
  display: flex;
  flex-direction: column;
}

.domain-card h3 {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  word-break: break-word;
}

.domain-card a {
  margin-top: auto;
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.domain-card a:hover,
.domain-card a:focus-visible {
  text-decoration: underline;
}

.flow-list {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
  counter-reset: flow;
}

.flow-list li {
  position: relative;
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  counter-increment: flow;
}

.flow-list li::before {
  content: counter(flow, decimal-leading-zero);
  display: block;
  margin-bottom: 26px;
  color: var(--coral);
  font-weight: 900;
}

.flow-list span {
  display: block;
  margin-bottom: 10px;
  font-weight: 900;
}

.docs-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(28px, 6vw, 72px);
  align-items: start;
}

.doc-links {
  display: grid;
  gap: 10px;
}

.doc-links a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(246, 241, 228, 0.05);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.doc-links a:hover,
.doc-links a:focus-visible {
  border-color: var(--teal);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 48px);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

@media (max-width: 960px) {
  .top-nav {
    display: none;
  }

  .hero {
    min-height: 780px;
  }

  .hero::after {
    background: linear-gradient(rgba(16, 16, 15, 0.94), rgba(16, 16, 15, 0.48));
  }

  .hero-inner {
    padding-bottom: 150px;
  }

  .split,
  .docs-section,
  .map-stage-heading {
    grid-template-columns: 1fr;
  }

  .domain-grid,
  .topology-grid {
    grid-template-columns: 1fr;
  }

  .map-control-panel {
    grid-template-columns: 1fr;
  }

  .map-theater {
    min-height: 740px;
  }

  .flow-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 14px 18px;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 5rem);
  }

  .hero-actions,
  .signal-line {
    display: grid;
  }

  .button,
  .mode-button {
    width: 100%;
    justify-content: center;
  }

  .segmented,
  .flow-list {
    grid-template-columns: 1fr;
  }

  .map-theater {
    min-height: 820px;
  }

  .map-tabs {
    left: 12px;
    right: 12px;
    grid-template-columns: 1fr;
  }

  .map-theater-controls {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .protocol-segmented {
    grid-template-columns: 1fr;
  }

  .flow-list li {
    min-height: 0;
  }

  .site-footer {
    display: grid;
  }
}

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