:root {
  --bg: #0a0a0f;
  --surface: #12141c;
  --surface-2: #171a24;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #3ee7d0;
  --accent-dim: rgba(62, 231, 208, 0.14);
  --accent-text: #7ff2e2;
  --text: #e8e8ec;
  --text-dim: #9a9aa5;
  --text-dimmer: #82838f; /* WCAG AA: 5.26:1 on --bg, checked — #6f707c was 4.03:1, failed */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --radius: 12px;
  --wrap: 1080px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.section {
  padding: 96px 0;
}

h1, h2, h3 {
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); margin: 0 0 20px; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin: 0 0 12px; }
h3 { font-size: 1.15rem; margin: 0 0 8px; }

p { margin: 0 0 16px; color: var(--text); }

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

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

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

/* ---------- reveal-on-scroll ----------
   Progressive enhancement: content is fully visible by default (no-JS case).
   main.js adds `.js` to <html> once it runs; only then do sections start
   hidden and get revealed by the IntersectionObserver. */
.reveal {
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal {
  opacity: 0;
  transform: translateY(10px);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- hero ---------- */
.hero {
  padding: 120px 0 100px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(62, 231, 208, 0.10), transparent 70%),
    var(--bg);
  text-align: center;
}
.badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}
.badges img { display: block; height: 20px; }
.hero .lede {
  max-width: 640px;
  margin: 0 auto 32px;
  color: var(--text-dim);
  font-size: 1.1rem;
}
.hero-cta {
  max-width: 560px;
  margin: 0 auto 28px;
  text-align: left;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.95rem;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover, .btn:focus-visible {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--accent);
}
.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- section shared ---------- */
.section-lede {
  color: var(--text-dim);
  max-width: 640px;
  margin-bottom: 36px;
}

/* ---------- problem contrast ---------- */
.contrast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 8px;
}
.contrast-col {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.contrast-col--accent {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-dim), var(--surface) 60%);
}
.contrast-col ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
}
.contrast-col li { margin-bottom: 8px; }
.contrast-col--accent li { color: var(--text); }

/* ---------- architecture diagram ---------- */
.diagram-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}
#arch-svg {
  width: 100%;
  height: auto;
  display: block;
}
.box {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}
.box--accent {
  stroke: var(--accent);
  fill: var(--surface-2);
}
.box--sandbox {
  fill: var(--accent-dim);
  stroke: var(--accent);
  stroke-dasharray: 4 3;
}
.box-title {
  fill: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 650;
}
.box-title--sm { font-size: 14px; }
.box-sub {
  fill: var(--text-dim);
  font-family: var(--sans);
  font-size: 11.5px;
}
.box-sub--sm { font-size: 10.5px; }

.arrow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
}
.arrow--dashed {
  stroke: var(--text-dimmer);
  stroke-dasharray: 5 4;
}
.arrowhead-fill { fill: var(--accent); }

.step-badge {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.5;
}
.step-badge--dashed { stroke: var(--text-dimmer); }
.step-num {
  fill: var(--accent-text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.step-caption {
  fill: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
}

.step {
  transition: opacity 0.5s ease;
}
.js .step {
  opacity: 0;
}
.js .step.is-visible {
  opacity: 1;
}
.step .arrow {
  transition: stroke-dashoffset 0.7s ease;
}
.js .step .arrow {
  stroke-dasharray: 380;
  stroke-dashoffset: 380;
}
.js .step.is-visible .arrow {
  stroke-dashoffset: 0;
}

#sandbox-node {
  transition: opacity 0.5s ease;
}
.js #sandbox-node {
  opacity: 0;
}
.js #sandbox-node.is-visible {
  opacity: 1;
}

.diagram-steps-text {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
}
.diagram-steps-text li {
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.diagram-steps-text code {
  color: var(--accent-text);
}

/* ---------- cards ---------- */
.cards {
  display: grid;
  gap: 20px;
}
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}
.card--accent {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-dim), var(--surface) 55%);
}
.card p { color: var(--text-dim); font-size: 0.94rem; }
.card .code-block { margin-top: 14px; margin-bottom: 0; }

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 8px;
  vertical-align: middle;
  font-family: var(--mono);
}

.ring-num {
  font-family: var(--mono);
  color: var(--accent-text);
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 8px;
}

/* ---------- benchmark stat cards ---------- */
.stat-cards { margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
}
.stat-value {
  font-family: var(--mono);
  font-size: 2.1rem;
  font-weight: 650;
  color: var(--accent-text);
}
.stat-label {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text);
}
.stat-sub {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-dimmer);
}
.disclaimer {
  font-size: 0.85rem;
  color: var(--text-dimmer);
  max-width: 640px;
}

/* ---------- code blocks ---------- */
.code-block {
  min-width: 0;
  background: #0d0e13;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dimmer);
}
.copy-btn {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover, .copy-btn:focus-visible {
  color: var(--accent-text);
  border-color: var(--accent);
}
.copy-btn.copied {
  color: var(--accent-text);
  border-color: var(--accent);
}
.code-block pre {
  margin: 0;
  padding: 14px 16px;
}
.code-block code {
  color: var(--text);
  font-size: 0.85rem;
  /* wrap instead of requiring horizontal scroll — long unbroken tokens
     (e.g. the gateway URL in the curl examples) can still break mid-string */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tok-kw { color: var(--accent-text); }
.tok-str { color: #e3c07a; }

.qs-sub {
  margin-top: 32px;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 600;
}
.qs-sub:first-of-type { margin-top: 0; }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 48px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 0.9rem;
}
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--accent-text); }
.footer img { height: 20px; display: block; }

/* ---------- language switcher ----------
   Injected entirely by js/i18n.js — never present in the no-JS baseline, so
   there is no dead/non-functional control when the script fails to load. */
.lang-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px;
}
.lang-switch button {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.lang-switch button:hover {
  color: var(--text);
}
.lang-switch button.is-active {
  color: var(--bg);
  background: var(--accent);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cards-3 { grid-template-columns: 1fr 1fr; }
  .cards-4 { grid-template-columns: 1fr 1fr; }
  .diagram-wrap { grid-template-columns: 1fr; }
  .contrast { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .section { padding: 64px 0; }
  .hero { padding: 88px 0 64px; }
  .cards-3, .cards-4 { grid-template-columns: 1fr; }
  .cta-row { flex-direction: column; align-items: stretch; }
  .btn { text-align: center; }
}

/* ---------- reduced motion ----------
   Snap everything to its final, fully-visible state instantly. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal,
  .step,
  #sandbox-node,
  .step .arrow,
  .btn,
  .card,
  .copy-btn {
    transition: none !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .js .step { opacity: 1; }
  .js .step .arrow { stroke-dashoffset: 0; }
  .js #sandbox-node { opacity: 1; }
}
