/* === CSS Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 0;
}

html {
  scroll-behavior: smooth;
}

/* === Design Tokens === */
:root {
  --color-bg: #000;
  --color-text: #fff;
  --color-dim: #999;
  --color-accent: #fff;
  --font: 'JetBrains Mono', 'Fira Code', monospace;
  --grid: 8px;
  --max-width: 1200px;
  --border: 1px solid #fff;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --section-padding: 48px 16px;
  --line-height-body: 1.6;
  --line-height-heading: 1.2;
}

/* === Reveal Animation === */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* === Body === */
body {
  overflow-x: hidden;
  background-color: var(--color-bg);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 47px, #222 47px, #222 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, #222 47px, #222 48px);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--line-height-body);
  min-height: 100vh;
}

/* === Typography === */
h1, h2, h3 {
  line-height: var(--line-height-heading);
  font-weight: 700;
}

h1 {
  font-size: clamp(32px, 5vw, 64px);
}

h2 {
  font-size: 32px;
}

h3 {
  font-size: 24px;
}

small {
  font-size: 12px;
}

/* === Links === */
a {
  color: var(--color-accent);
  text-decoration: underline;
  transition: background-color 0.15s, color 0.15s;
}

a:hover {
  background-color: var(--color-text);
  color: var(--color-bg);
}

a:focus-visible {
  background-color: var(--color-text);
  color: var(--color-bg);
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.section {
  padding: var(--section-padding);
  border-bottom: 1px solid #333;
}

/* === Components === */

/* Block / Card */
.block {
  border: var(--border);
  padding: 24px;
  transition: background-color 0.15s, color 0.15s;
}

.block:hover {
  background-color: var(--color-text);
  color: var(--color-bg);
}

.block:focus-visible {
  background-color: var(--color-text);
  color: var(--color-bg);
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Button */
.btn {
  display: inline-block;
  border: var(--border);
  padding: 16px 32px;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn:hover {
  background-color: var(--color-text);
  color: var(--color-bg);
}

.btn:focus-visible {
  background-color: var(--color-text);
  color: var(--color-bg);
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Terminal */
.terminal {
  background-color: var(--color-bg);
  border: var(--border);
  font-family: var(--font);
  overflow: hidden;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: var(--border);
}

.terminal-titlebar::before {
  content: '\25CF  \25CF  \25CF';
  font-size: 12px;
  color: var(--color-dim);
  letter-spacing: 2px;
}

.terminal-body {
  padding: 16px;
  font-size: 14px;
  line-height: var(--line-height-body);
  color: var(--color-dim);
}

/* === Hero === */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  position: relative;
}

.hero-note {
  position: absolute;
  top: 24px;
  font-size: 12px;
  color: var(--color-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hero-logo {
  margin-bottom: 32px;
}

.hero-headline {
  margin-bottom: 24px;
  max-width: 800px;
}

.cursor {
  display: inline-block;
  width: 3px;
  height: 0.85em;
  background-color: var(--color-text);
  margin-left: 4px;
  vertical-align: baseline;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.hero-sub {
  font-size: 18px;
  color: var(--color-dim);
  max-width: 600px;
  margin-bottom: 48px;
  line-height: var(--line-height-body);
}

.hero-cta {
  font-size: 18px;
  padding: 20px 40px;
}

/* === How It Works === */
#how-it-works {
  padding: 96px 16px;
}

.section-title {
  text-align: center;
  margin-bottom: 64px;
  text-transform: uppercase;
  letter-spacing: 4px;
}

.loop-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: var(--max-width);
  margin: 0 auto 48px;
}

.loop-diagram .block {
  width: 100%;
  max-width: 280px;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.loop-diagram .block.visible {
  opacity: 1;
  transform: translateY(0);
}

.block-number {
  display: inline-block;
  width: 36px;
  height: 36px;
  line-height: 36px;
  border: var(--border);
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
}

.block-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.block-desc {
  font-size: 13px;
  color: var(--color-dim);
  line-height: var(--line-height-body);
}

/* Arrows — vertical on mobile */
.arrow {
  width: 1px;
  height: 32px;
  background: var(--color-text);
  position: relative;
  flex-shrink: 0;
}

.arrow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--color-text);
}

/* Loop-back indicator */
.loop-back {
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-dim);
  border-top: none;
  border-left: none;
  border-radius: 0 0 8px 0;
  position: relative;
  margin-top: 8px;
}

.loop-back::after {
  content: 'loops back to 1';
  position: absolute;
  top: 50%;
  left: calc(100% + 12px);
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--color-dim);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.loop-explain {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  color: var(--color-dim);
  font-size: 15px;
  line-height: var(--line-height-body);
}

/* Desktop: horizontal layout */
@media (min-width: 768px) {
  .loop-diagram {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .loop-diagram .block {
    max-width: 200px;
    flex: 0 1 200px;
  }

  .arrow {
    width: 40px;
    height: 1px;
    background: var(--color-text);
  }

  .arrow::after {
    bottom: auto;
    top: 50%;
    left: auto;
    right: 0;
    transform: translateY(-50%);
    border-left: 8px solid var(--color-text);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: none;
  }

  .loop-back {
    width: 32px;
    height: 32px;
    margin-top: 0;
    margin-left: 8px;
    border-radius: 0 0 0 8px;
    border: 1px solid var(--color-dim);
    border-top: none;
    border-right: none;
  }

  .loop-back::after {
    top: auto;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }
}

/* === Features Grid === */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.features-grid .block {
  padding: 24px;
  text-align: left;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: var(--border);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.features-grid .block-title {
  margin-bottom: 8px;
}

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

/* === Responsive === */
@media (min-width: 768px) {
  .section {
    padding: 72px 24px;
  }
}

@media (min-width: 1024px) {
  .section {
    padding: 96px 24px;
  }
}

/* === Architecture Terminal === */
#architecture .terminal {
  max-width: 600px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #444;
}

#architecture .terminal-titlebar {
  background: #333;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #444;
}

#architecture .terminal-titlebar::before {
  content: none;
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }

.terminal-title {
  font-size: 13px;
  color: var(--color-dim);
}

#architecture .terminal-body {
  background: #1a1a1a;
  padding: 20px;
  min-height: 200px;
}

.terminal-line {
  font-family: var(--font);
  font-size: 14px;
  color: #0f0;
  white-space: pre;
  line-height: 1.8;
  min-height: 1.8em;
  opacity: 0;
}

.terminal-line.visible {
  opacity: 1;
}

.terminal-line .prompt {
  color: #0f0;
}

.terminal-line .typed {
  color: #fff;
}

/* === Demo Terminal === */
#demo {
  padding: 96px 16px;
}

.demo-terminal {
  max-width: 700px;
  margin: 0 auto;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  overflow: hidden;
}

.demo-terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #222;
  border-bottom: 1px solid #333;
}

.demo-terminal-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  min-height: 200px;
}

.demo-line {
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-dim);
  white-space: pre;
  line-height: 1.8;
  min-height: 1.8em;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.demo-line.visible {
  opacity: 1;
}

.demo-line .prompt {
  color: #fff;
  font-weight: 700;
}

.demo-line .typed {
  color: #fff;
}

.label-coordinator,
.label-worker {
  color: #666;
}

.demo-text {
  color: var(--color-dim);
}

.demo-checkmark {
  color: #fff;
  font-weight: 700;
}

.demo-blank {
  min-height: 1.8em;
}

/* === CTA Section === */
.cta {
  text-align: center;
  padding: 96px 16px;
  border-top: 4px solid var(--color-text);
}

.cta h2 {
  font-size: 40px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 4px;
}

.cta-subtitle {
  color: var(--color-dim);
  font-size: 16px;
  margin-bottom: 48px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.cta-buttons .btn {
  border-width: 3px;
  padding: 20px 40px;
  font-size: 16px;
  font-weight: 700;
}

/* === Footer === */
footer {
  border-top: 1px solid #333;
  text-align: center;
  padding: 48px 20px;
}

.footer-wordmark {
  font-family: 'JetBrains Mono', monospace;
  font-weight: bold;
  letter-spacing: 0.3em;
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.footer-links {
  margin-bottom: 24px;
}

.footer-links a {
  color: #fff;
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  opacity: 0.7;
}

.footer-sep {
  margin: 0 12px;
  color: #555;
}

.footer-copyright {
  color: #888;
  font-size: 14px;
  margin-bottom: 8px;
}

.footer-note {
  color: #555;
  font-size: 12px;
}

/* === Mobile (< 768px) === */
@media (max-width: 767px) {
  .container {
    padding: 0 16px;
  }

  .section {
    padding: 32px 16px;
  }

  #how-it-works {
    padding: 48px 16px;
  }

  #demo {
    padding: 48px 16px;
  }

  .cta {
    padding: 48px 16px;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 18px;
  }

  .cta h2 {
    font-size: 28px;
  }

  .section-title {
    margin-bottom: 32px;
    letter-spacing: 2px;
  }

  .hero-sub {
    font-size: 16px;
  }

  .hero-cta {
    font-size: 16px;
    padding: 16px 32px;
  }

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

  .loop-diagram {
    flex-direction: column;
    align-items: center;
  }

  .loop-diagram .block {
    max-width: 100%;
  }

  .arrow {
    width: 1px;
    height: 32px;
  }

  .arrow::after {
    bottom: 0;
    left: 50%;
    top: auto;
    right: auto;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--color-text);
    border-bottom: none;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .cta-buttons .btn {
    width: 100%;
    text-align: center;
  }

  .terminal,
  .demo-terminal,
  #architecture .terminal {
    max-width: 100%;
    overflow-x: auto;
  }

  .terminal-body,
  .demo-terminal-body,
  #architecture .terminal-body {
    overflow-x: auto;
  }

  .terminal-line,
  .demo-line {
    font-size: 12px;
  }
}

/* === Tablet (768px - 1024px) === */
@media (min-width: 768px) and (max-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-title {
    margin-bottom: 48px;
  }

  .cta h2 {
    font-size: 32px;
  }
}

/* === Desktop (> 1024px) === */
@media (min-width: 1025px) {
  .container {
    max-width: var(--max-width);
    margin: 0 auto;
  }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
