/* =========================================================
   CodeGraph product site — design tokens & layout
   Style anchor: Sourcegraph / Linear infra aesthetics + graph hero
   ========================================================= */

:root {
  --bg: #0a0e12;
  --bg-elev: #12181f;
  --bg-elev-2: #182029;
  --line: #1e2833;
  --line-strong: #2a3644;
  --ink: #e7eef6;
  --ink-muted: #7f8fa3;
  --ink-dim: #5a6a7c;

  --code: #3dffc5;
  --code-dim: rgba(61, 255, 197, 0.14);
  --decision: #ffb454;
  --decision-dim: rgba(255, 180, 84, 0.14);
  --git: #6ba3ff;
  --git-dim: rgba(107, 163, 255, 0.14);
  --danger: #ff6b7a;

  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;

  --max: 1120px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(61, 255, 197, 0.07), transparent 55%),
    radial-gradient(900px 500px at 10% 20%, rgba(107, 163, 255, 0.05), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--code);
  background: var(--code-dim);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}

em {
  font-style: normal;
  color: var(--decision);
}

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 24px;
  backdrop-filter: blur(14px);
  background: rgba(10, 14, 18, 0.72);
  border-bottom: 1px solid transparent;
}

.nav.is-scrolled {
  border-bottom-color: var(--line);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--code);
  background: var(--code-dim);
  border: 1px solid rgba(61, 255, 197, 0.25);
}

.nav__name {
  font-family: var(--font-mono);
  font-size: 15px;
}

.nav__links {
  display: flex;
  gap: 22px;
  margin-left: auto;
  font-size: 14px;
  color: var(--ink-muted);
}

.nav__links a:hover {
  color: var(--ink);
}

.nav__cta {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s;
}

.nav__cta:hover {
  border-color: var(--code);
  background: var(--code-dim);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 48px;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 72px 24px 96px;
}

.eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hero h1 {
  margin: 0 0 22px;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.hero__accent {
  background: linear-gradient(120deg, var(--code), var(--git) 55%, var(--decision));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lead {
  margin: 0 0 28px;
  max-width: 34em;
  font-size: 17px;
  color: var(--ink-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn--primary {
  color: #04120d;
  background: var(--code);
  box-shadow: 0 0 0 1px rgba(61, 255, 197, 0.3), 0 10px 30px rgba(61, 255, 197, 0.18);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(61, 255, 197, 0.45), 0 14px 36px rgba(61, 255, 197, 0.25);
}

.btn--ghost {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: rgba(18, 24, 31, 0.6);
}

.btn--ghost:hover {
  border-color: var(--git);
  background: var(--git-dim);
}

.hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero__tags li {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 24, 31, 0.55);
}

/* Graph stage */

.hero__visual {
  min-height: 420px;
}

.graph-stage {
  position: relative;
  height: 100%;
  min-height: 420px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 70% 30%, rgba(255, 180, 84, 0.08), transparent 40%),
    radial-gradient(circle at 30% 70%, rgba(61, 255, 197, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(18, 24, 31, 0.95), rgba(10, 14, 18, 0.9));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.graph-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(42, 54, 68, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 54, 68, 0.35) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, #000 35%, transparent 80%);
  opacity: 0.5;
}

.graph-svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 380px;
  display: block;
}

.graph-legend {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot--code { background: var(--code); box-shadow: 0 0 8px rgba(61, 255, 197, 0.7); }
.dot--decision { background: var(--decision); box-shadow: 0 0 8px rgba(255, 180, 84, 0.7); }
.dot--git { background: var(--git); box-shadow: 0 0 8px rgba(107, 163, 255, 0.7); }

.graph-node-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--ink);
}

.graph-node-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--ink-muted);
}

.graph-edge {
  fill: none;
  stroke-width: 1.4;
  opacity: 0.75;
}

.graph-edge--uses { stroke: var(--code); }
.graph-edge--decided { stroke: var(--decision); stroke-dasharray: 4 3; }
.graph-edge--time { stroke: var(--git); stroke-dasharray: 2 4; }

/* ---------- Sections ---------- */

.section {
  position: relative;
  z-index: 1;
  padding: 104px 0;
}

.section--alt {
  background: linear-gradient(180deg, rgba(18, 24, 31, 0.35), rgba(18, 24, 31, 0.08));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.section__label {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.section h2 {
  margin: 0 0 16px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.section__intro {
  margin: 0 0 40px;
  max-width: 46em;
  color: var(--ink-muted);
  font-size: 16.5px;
}

/* Pain grid */

.pain-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.pain-card {
  padding: 22px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: border-color 0.2s, transform 0.2s;
}

.pain-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.pain-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

.pain-card p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-muted);
  line-height: 1.65;
}

/* Architecture */

.arch {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 48px;
}

.arch__col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.arch__node {
  flex: 1;
  padding: 18px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.arch__node strong {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.arch__node span:last-child {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.arch__kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim) !important;
}

.arch__node--accent {
  border-color: rgba(61, 255, 197, 0.35);
  background: linear-gradient(180deg, rgba(61, 255, 197, 0.08), rgba(18, 24, 31, 0.9));
}

.arch__node--store {
  border-color: rgba(255, 180, 84, 0.3);
  background: linear-gradient(180deg, rgba(255, 180, 84, 0.08), rgba(18, 24, 31, 0.9));
}

.arch__flow {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  width: 28px;
}

.arch__flow span {
  display: block;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), var(--code));
  position: relative;
}

.arch__flow span::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -3px;
  border: 4px solid transparent;
  border-left-color: var(--code);
}

/* Why points */

.why-points {
  display: grid;
  gap: 18px;
}

.why-point {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 18px;
  align-items: start;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 24, 31, 0.55);
}

.why-point__num {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--code);
  padding-top: 2px;
}

.why-point h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.why-point p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14.5px;
}

/* Terminal */

.terminal {
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: #0c1117;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #10161d;
}

.terminal__dots {
  display: inline-flex;
  gap: 6px;
}

.terminal__dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
}

.terminal__dots i:nth-child(1) { background: #ff5f57; }
.terminal__dots i:nth-child(2) { background: #febc2e; }
.terminal__dots i:nth-child(3) { background: #28c840; }

.terminal__title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.terminal__replay {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}

.terminal__replay:hover {
  color: var(--code);
  border-color: rgba(61, 255, 197, 0.4);
}

.terminal__body {
  min-height: 340px;
  padding: 22px 24px 28px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
}

.t-line {
  min-height: 1.65em;
  white-space: pre-wrap;
  word-break: break-word;
}

.t-prompt { color: var(--code); }
.t-cmd { color: var(--ink); }
.t-muted { color: var(--ink-dim); }
.t-ok { color: var(--code); }
.t-warn { color: var(--decision); }
.t-git { color: var(--git); }

.t-card {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 180, 84, 0.35);
  background: rgba(255, 180, 84, 0.07);
}

.t-card__title {
  color: var(--decision);
  font-weight: 600;
  margin-bottom: 8px;
}

.t-card__row {
  color: var(--ink-muted);
}

.t-card__row strong {
  color: var(--ink);
  font-weight: 500;
}

/* Commands */

.cmd-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.cmd {
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: border-color 0.2s, transform 0.2s;
}

.cmd:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.cmd--hl {
  border-color: rgba(61, 255, 197, 0.35);
  background: linear-gradient(160deg, rgba(61, 255, 197, 0.08), rgba(18, 24, 31, 0.95));
  grid-column: 1 / -1;
}

.cmd__name {
  display: block;
  background: transparent;
  padding: 0;
  font-size: 13.5px;
  color: var(--code);
  margin-bottom: 8px;
}

.cmd p {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: 14.5px;
}

.cmd__flags {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

/* Schema */

.schema-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.schema-card {
  border-radius: var(--radius);
  border: 1px solid rgba(61, 255, 197, 0.25);
  background: var(--bg-elev);
  overflow: hidden;
}

.schema-card--decision {
  border-color: rgba(255, 180, 84, 0.3);
}

.schema-card--discussion {
  border-color: rgba(107, 163, 255, 0.3);
}

.schema-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.schema-card__type {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--code);
}

.schema-card--decision .schema-card__type { color: var(--decision); }
.schema-card--discussion .schema-card__type { color: var(--git); }

.schema-card__role {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.schema-card ul {
  margin: 0;
  padding: 14px 16px 18px;
  list-style: none;
}

.schema-card li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 7px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-muted);
  border-bottom: 1px dashed rgba(30, 40, 51, 0.9);
}

.schema-card li:last-child {
  border-bottom: 0;
}

.schema-card li span:first-child {
  color: var(--ink);
}

/* Diff */

.diff {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  background: rgba(18, 24, 31, 0.45);
}

.diff h3 {
  margin: 0 0 22px;
  font-size: 18px;
}

.diff__grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
}

.diff__title {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
}

.diff__col ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.diff__col li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}

.diff__col li span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}

.diff__arrow {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--code);
}

.diff__col--focus {
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(61, 255, 197, 0.3);
  background: var(--code-dim);
}

.diff__col--focus .diff__title {
  color: var(--code);
}

.diff__col--focus li {
  border-top-color: rgba(61, 255, 197, 0.15);
}

/* Stack table */

.stack-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}

.stack-row {
  display: grid;
  grid-template-columns: 140px 1.1fr 1.4fr;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
  font-size: 14.5px;
}

.stack-row:last-child {
  border-bottom: 0;
}

.stack-row--head {
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.stack-row strong {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--code);
}

.stack-row span:last-child {
  color: var(--ink-muted);
}

/* Closing */

.closing {
  padding-top: 120px;
  padding-bottom: 120px;
}

.closing__inner {
  text-align: center;
  max-width: 760px;
}

.closing__title {
  font-size: clamp(32px, 5vw, 48px) !important;
  margin-bottom: 14px !important;
}

.closing__sub {
  margin: 0 auto 32px;
  max-width: 32em;
  color: var(--ink-muted);
  font-size: 17px;
}

.closing__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Footer */

.footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
}

.footer__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: space-between;
  align-items: baseline;
}

.footer__brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer__brand strong {
  font-family: var(--font-mono);
  font-size: 14px;
}

.footer__brand span,
.footer__note {
  font-size: 13px;
  color: var(--ink-dim);
}

.footer__note {
  margin: 0;
  max-width: 36em;
}

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 48px;
  }

  .hero__visual {
    min-height: 360px;
  }

  .pain-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .arch {
    grid-template-columns: 1fr;
  }

  .arch__flow {
    flex-direction: row;
    width: 100%;
    height: 28px;
    gap: 0;
  }

  .arch__flow span {
    width: 100%;
    height: 1px;
    background: linear-gradient(180deg, var(--line-strong), var(--code));
  }

  .arch__flow span::after {
    display: none;
  }

  .schema-grid {
    grid-template-columns: 1fr;
  }

  .diff__grid {
    grid-template-columns: 1fr;
  }

  .diff__arrow {
    transform: rotate(90deg);
    text-align: center;
  }

  .cmd-list {
    grid-template-columns: 1fr;
  }

  .cmd--hl {
    grid-column: auto;
  }

  .stack-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .nav__links {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 560px) {
  .pain-grid {
    grid-template-columns: 1fr;
  }

  .why-point {
    grid-template-columns: 40px 1fr;
  }

  .terminal__body {
    padding: 16px;
    font-size: 12.5px;
  }

  .section {
    padding: 72px 0;
  }
}
