/* ---------------------------------------------------------------- */
/* Tokens                                                            */
/* ---------------------------------------------------------------- */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "IBM Plex Mono", "Fira Code", Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --max-width: 1180px;

  /* dark (default) */
  --bg: #0a0d12;
  --bg-alt: #0e1218;
  --surface: #12161ee6;
  --surface-solid: #12161e;
  --surface-raised: #171c26;
  --border: #232a37;
  --border-strong: #313a4b;
  --text: #eef1f6;
  --text-dim: #a7b0c0;
  --text-faint: #6b7486;
  --accent: #5ee6c8;
  --accent-strong: #7ef2d6;
  --accent-contrast: #04231c;
  --warn: #ffb454;
  --warn-strong: #ffcf8a;
  --danger: #ff6b6b;
  --pass: #5ee6a8;
  --link: #8fd7ff;
  --shadow: 0 20px 60px -30px rgba(0,0,0,0.65);
}

[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-alt: #eef0f3;
  --surface: #ffffffcc;
  --surface-solid: #ffffff;
  --surface-raised: #ffffff;
  --border: #dfe3ea;
  --border-strong: #c7cdd8;
  --text: #12151c;
  --text-dim: #4b5566;
  --text-faint: #7c8497;
  --accent: #0f9d7c;
  --accent-strong: #0b7d63;
  --accent-contrast: #ffffff;
  --warn: #b26a00;
  --warn-strong: #8a5300;
  --danger: #c43d3d;
  --pass: #128f6c;
  --link: #0a6fa3;
  --shadow: 0 20px 50px -35px rgba(20,24,34,0.35);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9;
    --bg-alt: #eef0f3;
    --surface: #ffffffcc;
    --surface-solid: #ffffff;
    --surface-raised: #ffffff;
    --border: #dfe3ea;
    --border-strong: #c7cdd8;
    --text: #12151c;
    --text-dim: #4b5566;
    --text-faint: #7c8497;
    --accent: #0f9d7c;
    --accent-strong: #0b7d63;
    --accent-contrast: #ffffff;
    --warn: #b26a00;
    --warn-strong: #8a5300;
    --danger: #c43d3d;
    --pass: #128f6c;
    --link: #0a6fa3;
    --shadow: 0 20px 50px -35px rgba(20,24,34,0.35);
  }
}

* { box-sizing: border-box; }

html {
  color-scheme: dark light;
}
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.2s var(--ease);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

a { color: var(--link); }

h1, h2, h3 { font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(2.1rem, 4vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }

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

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

/* ---------------------------------------------------------------- */
/* Header                                                             */
/* ---------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.mark-block { fill: var(--surface-raised); stroke: var(--border-strong); }
.mark-a { fill: var(--accent); stroke: none; }
.mark-link { stroke: var(--text-faint); stroke-width: 1.4; fill: none; }

.main-nav {
  display: flex;
  gap: 22px;
  margin-right: auto;
}
.main-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
.main-nav a:hover { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-dim);
  cursor: pointer;
}
.theme-toggle svg { stroke: currentColor; stroke-width: 1.6; fill: none; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-lg { padding: 13px 26px; font-size: 1rem; }

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

.hero { padding: 76px 0 40px; }

.hero-inner {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 20px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent);
}

.hero-lede {
  color: var(--text-dim);
  font-size: 1.08rem;
  max-width: 46ch;
  margin: 18px 0 28px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-note {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-faint);
  max-width: 44ch;
}

/* ---------------------------------------------------------------- */
/* Calculation block                                                  */
/* ---------------------------------------------------------------- */

.calc-block {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calc-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.calc-block-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.calc-block-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.calc-block-tag {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.calc-block-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.calc-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(4px);
  animation: rowIn 0.5s var(--ease) forwards;
}
.calc-row code { color: var(--text); }
.calc-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  min-width: 84px;
}
.calc-row-result {
  background: color-mix(in srgb, var(--pass) 12%, transparent);
}
.calc-row-result code { color: var(--pass); font-weight: 600; }
.calc-check {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--pass);
  border: 1px solid color-mix(in srgb, var(--pass) 45%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}

#hero-calc-block .calc-row-sub { animation-delay: 0.5s; }
#hero-calc-block .calc-row-result { animation-delay: 1s; }

.calc-block-lg .calc-row { animation: none; opacity: 0; transform: translateY(6px); }
.calc-block-lg .calc-row.is-visible {
  animation: rowIn 0.45s var(--ease) forwards;
}

@keyframes rowIn {
  to { opacity: 1; transform: translateY(0); }
}

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

.section { padding: 88px 0; }
.section-alt { background: var(--bg-alt); }

.section-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 56px;
  align-items: center;
}
.section-grid-reverse .section-copy { order: 2; }
.section-grid-reverse .section-visual { order: 1; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.section-copy p { color: var(--text-dim); max-width: 52ch; }
.in-dev-note {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
}

.section-visual [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.section-visual [data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------------------------------------------------------- */
/* Dependency graph                                                    */
/* ---------------------------------------------------------------- */

.graph-panel {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
#graph-svg { width: 100%; height: auto; display: block; }
.graph-node rect {
  fill: var(--surface-raised);
  stroke: var(--border-strong);
  stroke-width: 1.2;
}
.graph-node text {
  fill: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
}
.graph-node-active rect { stroke: var(--accent); }
.graph-node-active text { fill: var(--text); }
.graph-node-warn rect { stroke: var(--warn); }

.graph-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.6;
  stroke-dasharray: 5 5;
  animation: dashMove 2.2s linear infinite;
}
@keyframes dashMove { to { stroke-dashoffset: -20; } }

.graph-edge-cycle {
  stroke: var(--danger);
  stroke-dasharray: 4 4;
  animation: dashMove 1.4s linear infinite, cyclePulse 2.6s ease-in-out infinite;
}
@keyframes cyclePulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.graph-flag {
  opacity: 0;
  animation: flagIn 2.6s ease-in-out infinite;
}
.graph-flag rect {
  fill: color-mix(in srgb, var(--danger) 16%, var(--surface-solid));
  stroke: var(--danger);
  stroke-width: 1;
}
.graph-flag text {
  fill: var(--danger);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-sans);
}
@keyframes flagIn {
  0%, 45% { opacity: 0; transform: translateY(4px); }
  60%, 90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

/* ---------------------------------------------------------------- */
/* Advisory card                                                       */
/* ---------------------------------------------------------------- */

.advisory-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.advisory-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface-raised));
}
.advisory-icon {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--warn);
  color: #241602;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.advisory-title { margin: 0; font-weight: 700; font-size: 0.95rem; }
.advisory-standard {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.advisory-body { padding: 18px; }
.advisory-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.advisory-line code { color: var(--text); }
.advisory-flag {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn-strong);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- */
/* Templates                                                          */
/* ---------------------------------------------------------------- */

.templates-head { max-width: 68ch; }
.templates-lede { color: var(--text-dim); margin-top: 14px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 40px 0;
}
.stat-tile {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: center;
}
.stat-number {
  display: block;
  font-size: 2.4rem;
  font-weight: 750;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.stat-label {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.pipeline-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}
.pipeline-index {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.pipeline-step-final { color: var(--accent); }
.pipeline-arrow { color: var(--text-faint); }

/* ---------------------------------------------------------------- */
/* Roles                                                               */
/* ---------------------------------------------------------------- */

.roles-panel {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 1;
}
.role-dot { width: 8px; height: 8px; border-radius: 50%; }
.role-chip-author .role-dot { background: var(--accent); }
.role-chip-checker .role-dot { background: var(--warn); }
.role-chip-approver .role-dot { background: var(--link); }
.role-thread {
  position: absolute;
  left: 24px; right: 24px; top: 50%;
  height: 1px;
}
.role-line {
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px);
}

/* ---------------------------------------------------------------- */
/* AI gateway                                                          */
/* ---------------------------------------------------------------- */

.gateway-panel {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.gateway-node {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}
.gateway-gate {
  border-color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gateway-lock { color: var(--accent); }
.gateway-arrow { color: var(--text-faint); font-size: 1.1rem; }

/* ---------------------------------------------------------------- */
/* CTA band                                                            */
/* ---------------------------------------------------------------- */

.cta-band {
  padding: 96px 0;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
  border-top: 1px solid var(--border);
  text-align: center;
}
.cta-inner { max-width: 640px; }
.status-badge-invert { margin-left: auto; margin-right: auto; }
.cta-band p { color: var(--text-dim); margin: 18px auto 30px; max-width: 52ch; }

/* ---------------------------------------------------------------- */
/* Footer                                                              */
/* ---------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 48px 0 0;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  padding-bottom: 36px;
  flex-wrap: wrap;
}
.footer-brand p { color: var(--text-faint); font-size: 0.85rem; margin-top: 8px; max-width: 32ch; }
.wordmark-footer { font-weight: 700; }
.footer-links { display: flex; gap: 56px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 4px;
}
.footer-col a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-col a:hover { color: var(--text); }
.footer-current {
  color: var(--text-faint);
  font-size: 0.9rem;
}
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--text-faint);
  font-size: 0.8rem;
}

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

@media (max-width: 900px) {
  .main-nav { display: none; }
  .hero-inner, .section-grid {
    grid-template-columns: 1fr;
  }
  .section-grid-reverse .section-copy,
  .section-grid-reverse .section-visual { order: initial; }
  .stat-row { grid-template-columns: 1fr; }
  .roles-panel { flex-direction: column; align-items: flex-start; }
  .role-thread { display: none; }
}

@media (max-width: 560px) {
  .header-inner { gap: 12px; }
  .hero { padding: 48px 0 24px; }
  .section { padding: 56px 0; }
  .footer-links { gap: 28px; }
}

/* ---------------------------------------------------------------- */
/* Reduced motion                                                      */
/* ---------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .graph-edge, .graph-edge-cycle, .graph-flag { animation: none !important; opacity: 1; }
  .calc-row { animation: none !important; opacity: 1; transform: none; }
}
