/* ============================================
   JD Codec — Design System
   "Signal Noir" — dark, precise, electric accents
   ============================================ */

:root {
  --accent: #3cffd0;
  --accent-glow: rgba(60, 255, 208, 0.12);
  --accent-warm: #ffd43b;
  --bg: #05070a;
  --surface: #0c0f16;
  --surface-2: #141820;
  --surface-3: #1c2030;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(60, 255, 208, 0.15);
  --text: #e4e7ec;
  --text-muted: #8a8fa0;
  --text-dim: #3d4250;
  --green: #22c55e;
  --red: #ef4444;
}

/* ============================================
   Nav — evaporate on load, materialise on scroll
   ============================================ */

#site-nav {
  border-bottom: 1px solid transparent;
  transition: background 0.4s ease, border-color 0.4s ease, backdrop-filter 0.4s ease;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#site-nav.scrolled {
  background: rgba(5, 7, 10, 0.82);
  border-bottom-color: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ============================================
   Hero — atmospheric parallax layers
   ============================================ */

/* 1px teal gradient stripe at top of hero */
.hero-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(60, 255, 208, 0.5) 30%, rgba(60, 255, 208, 0.5) 70%, transparent);
  z-index: 2;
  pointer-events: none;
}

/* Large teal bloom — moves at 0.28x scroll */
.hero-glow-1 {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 1100px;
  height: 750px;
  background: radial-gradient(ellipse at 50% 18%, rgba(60, 255, 208, 0.14) 0%, rgba(60, 255, 208, 0.04) 40%, transparent 65%);
  pointer-events: none;
  will-change: transform;
}

/* Secondary bloom — moves at 0.45x */
.hero-glow-2 {
  position: absolute;
  bottom: -80px;
  right: -100px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(60, 255, 208, 0.05) 0%, transparent 60%);
  pointer-events: none;
  will-change: transform;
}

/* Grid texture — moves at 0.12x */
.hero-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  will-change: transform;
  background-image:
    linear-gradient(rgba(60, 255, 208, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 255, 208, 0.022) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, black 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, black 0%, transparent 80%);
}

/* Hero logo mark — floats at 0.18x */
.hero-mark-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  will-change: transform;
}

.hero-mark-glow {
  position: relative;
  display: inline-block;
}

.hero-mark-glow::before {
  content: '';
  position: absolute;
  inset: -48px;
  background: radial-gradient(circle, rgba(60, 255, 208, 0.08) 0%, transparent 65%);
  border-radius: 50%;
}

.hero-mark-glow img {
  height: 96px;
  width: auto;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 12px rgba(60, 255, 208, 0.2));
}

/* Text selection */
::selection {
  background: rgba(60, 255, 208, 0.25);
  color: #fff;
}

/* Grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* Background radial glow */
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(60, 255, 208, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Typography overrides */
.font-display {
  font-family: 'Instrument Serif', Georgia, serif;
}
.font-body {
  font-family: 'Figtree', system-ui, sans-serif;
}
.font-mono {
  font-family: 'Fira Code', monospace;
}

/* Headline tight tracking */
h1, h2, h3 {
  letter-spacing: -0.03em;
}

/* Body line height */
body {
  line-height: 1.7;
}

/* ============================================
   Components
   ============================================ */

/* Metric cards */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow),
              0 0 0 1px var(--border-accent);
}

/* Form input */
.waitlist-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1.25rem;
  color: var(--text);
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.waitlist-input::placeholder {
  color: var(--text-muted);
}

.waitlist-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Submit button */
.waitlist-btn {
  background: var(--accent);
  color: #05070a;
  font-family: 'Figtree', system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  padding: 0.875rem 2rem;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease,
              opacity 0.15s ease;
  white-space: nowrap;
}

.waitlist-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

.waitlist-btn:active {
  transform: translateY(0);
}

.waitlist-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   Race animation
   ============================================ */

.race-panel {
  transition: box-shadow 0.3s ease;
}

.race-check {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.race-step span {
  transition: color 0.3s ease;
}

/* Tabular nums for counters */
#race-left-tokens, #race-left-cost, #race-left-time,
#race-right-tokens, #race-right-cost, #race-right-time {
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Results table
   ============================================ */

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table .totals-row {
  background: var(--surface-2);
  font-weight: 700;
}

.results-table .totals-row td {
  border-top: 2px solid rgba(255, 255, 255, 0.08);
}

/* Reduction badge */
.reduction-badge {
  color: var(--accent);
  font-weight: 700;
  font-family: 'Fira Code', monospace;
}

/* Pass/fail indicators */
.pass { color: var(--green); font-weight: 600; }
.fail { color: var(--red); font-weight: 600; }

/* ============================================
   Steps section
   ============================================ */

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ============================================
   Install tabs + copy button
   ============================================ */

.install-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 0;
  width: fit-content;
  background: var(--surface-2);
  border-radius: 6px 6px 0 0;
  padding: 3px 3px 0;
}

.install-tab {
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  padding: 0.3rem 0.75rem;
  border-radius: 4px 4px 0 0;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  transition: color 0.15s ease, background 0.15s ease;
  letter-spacing: 0.04em;
}

.install-tab:hover { color: var(--text); }

.install-tab.active {
  color: var(--accent);
  background: var(--surface-3);
}

.install-code-wrap {
  background: var(--surface-2);
  border-radius: 0 6px 6px 6px;
  overflow: hidden;
}

.install-panel {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
}

.install-panel.active { display: flex; }

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 2px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s ease;
  margin-left: 0.75rem;
}

.copy-btn:hover { color: var(--accent); }

.copy-btn svg { width: 14px; height: 14px; }

.copy-btn .check-icon { display: none; }
.copy-btn.copied { color: var(--accent); }
.copy-btn.copied .copy-icon { display: none; }
.copy-btn.copied .check-icon { display: block; }

/* ============================================
   Section reveal animations
   ============================================ */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 0.08s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 0.16s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 0.24s; opacity: 1; transform: translateY(0); }

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .demo-panel-body {
    height: 240px;
  }
}

/* ============================================
   Form states
   ============================================ */

.form-success {
  animation: fadeInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(5, 7, 10, 0.3);
  border-top-color: #05070a;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pulsing dots for "Running" badge */
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.2; }
  40%            { opacity: 1;   }
}

.dots-pulse span {
  animation: dot-pulse 1.2s infinite ease-in-out;
}
.dots-pulse span:nth-child(2) { animation-delay: 0.2s; }
.dots-pulse span:nth-child(3) { animation-delay: 0.4s; }

/* ============================================
   C5: Blur-to-clarity hero entrance
   Parallax-safe: only animates opacity/filter.
   JS controls transform on these same elements
   via inline style — different properties, no conflict.
   Triggered by body.hero-loaded set on DOMContentLoaded.
   ============================================ */

@keyframes hero-focus-in {
  0%   { filter: blur(var(--hb, 20px)); opacity: 0; }
  55%  { filter: blur(calc(var(--hb, 20px) * 0.1)); opacity: 0.85; }
  100% { filter: blur(0); opacity: 1; }
}

@keyframes hero-headline-focus {
  0%   { filter: blur(28px); opacity: 0; letter-spacing: 0.06em; }
  55%  { filter: blur(2px);  opacity: 0.9; letter-spacing: -0.01em; }
  100% { filter: blur(0);    opacity: 1;   letter-spacing: -0.03em; }
}

@keyframes hero-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Atmospheric layers: opacity only — parallax JS handles transform */
body.hero-loaded #hero-glow-1,
body.hero-loaded #hero-glow-2,
body.hero-loaded #hero-grid {
  opacity: 0;
  animation: hero-fade-in 1.6s ease 0.1s forwards;
}

/* Logo mark: opacity + filter only — parallax JS owns transform on #hero-mark */
body.hero-loaded #hero-mark {
  --hb: 18px;
  opacity: 0;
  animation: hero-focus-in 0.85s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.3s forwards;
}

/* Eyebrow */
body.hero-loaded #hero-eyebrow {
  --hb: 10px;
  opacity: 0;
  animation: hero-focus-in 0.6s ease 0.5s forwards;
}

/* Headline — tracking tightens as it sharpens */
body.hero-loaded #hero-headline {
  opacity: 0;
  animation: hero-headline-focus 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.7s forwards;
}

/* Subtitle */
body.hero-loaded #hero-subtitle {
  --hb: 14px;
  opacity: 0;
  animation: hero-focus-in 0.9s ease 1.1s forwards;
}

/* CTA form */
body.hero-loaded #waitlist {
  --hb: 10px;
  opacity: 0;
  animation: hero-focus-in 0.8s ease 1.35s forwards;
}
