/* ── Custom Properties ──────────────────────────────────────────────── */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1a2744;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6c6c84;
  --border: #2a2a4a;
  --border-light: #3a3a5a;

  --english: #4A9EFF;
  --english-dim: rgba(74, 158, 255, 0.15);
  --english-glow: rgba(74, 158, 255, 0.3);
  --lojban: #FFB347;
  --lojban-dim: rgba(255, 179, 71, 0.15);
  --lojban-glow: rgba(255, 179, 71, 0.3);
  --accent: #7c5cfc;
  --success: #4ade80;
  --warning: #fbbf24;
  --chance: #ef4444;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Libre Baskerville', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
}

/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; }
code, pre, .mono { font-family: var(--font-mono); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--english); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Navigation ────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.nav-links { display: flex; gap: 24px; }

.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text-primary); }

/* ── Hero ──────────────────────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 60px;
  background:
    radial-gradient(ellipse at 30% 20%, var(--english-dim) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, var(--lojban-dim) 0%, transparent 50%),
    var(--bg-primary);
}

.hero-content { max-width: 800px; }

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1.15;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--english) 0%, var(--lojban) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 40px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--english), var(--lojban));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.hero-cta {
  display: inline-block;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 28px;
  transition: all 0.2s;
}
.hero-cta:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.1);
}

/* ── Sections ──────────────────────────────────────────────────────── */
.section {
  padding: 80px 0;
}

.section-alt {
  background: var(--bg-secondary);
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  text-align: center;
  margin-bottom: 12px;
}

.section-intro {
  text-align: center;
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto 48px;
  font-size: 1.05rem;
}

/* ── Lojban Comparison ─────────────────────────────────────────────── */
.comparison-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 40px;
}

.comparison-side {
  padding: 32px;
  background: var(--bg-card);
}

.comparison-side h3 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.comparison-english h3 { color: var(--english); }
.comparison-lojban h3 { color: var(--lojban); }

.comparison-text {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  margin-bottom: 12px;
  line-height: 1.5;
}

.comparison-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.properties-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

.property-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.property-card h4 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lojban);
  margin-bottom: 8px;
}

.property-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.property-card code {
  background: rgba(124, 92, 252, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
}

/* ── Tokenizer Demo ────────────────────────────────────────────────── */
.tokenizer-demo {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.tokenizer-demo h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.demo-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.tokenizer-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.tokenizer-panel label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.tokenizer-panel:first-child label { color: var(--english); }
.tokenizer-panel:last-child label { color: var(--lojban); }

.tokenizer-panel textarea {
  width: 100%;
  height: 60px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 12px;
  resize: none;
  transition: border-color 0.2s;
}
.tokenizer-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.token-display {
  margin-top: 12px;
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.8;
}

.token-span {
  padding: 2px 4px;
  border-radius: 3px;
  white-space: pre;
}

.token-count {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Timeline ──────────────────────────────────────────────────────── */
.timeline {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 72px;
  margin-bottom: 40px;
}

.timeline-item:last-child { margin-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: 16px;
  top: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
}

.timeline-item.status-completed .timeline-dot { border-color: var(--success); color: var(--success); }
.timeline-item.status-invalidated .timeline-dot { border-color: var(--chance); color: var(--chance); }
.timeline-item.status-confounded .timeline-dot { border-color: var(--warning); color: var(--warning); }
.timeline-item.status-improved .timeline-dot { border-color: var(--english); color: var(--english); }

.timeline-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.timeline-version {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.timeline-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
}

.timeline-params {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.5;
}

.timeline-body strong {
  color: var(--text-primary);
}

.timeline-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 4px;
}

.badge-invalidated { background: rgba(239,68,68,0.15); color: var(--chance); }
.badge-completed { background: rgba(74,222,128,0.15); color: var(--success); }
.badge-confounded { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-improved { background: rgba(74,158,255,0.15); color: var(--english); }

/* ── Charts ────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.chart-card h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.chart-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ── Samples ───────────────────────────────────────────────────────── */
.sample-tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 32px;
}

.sample-tab {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.sample-tab:hover { border-color: var(--accent); color: var(--text-primary); }
.sample-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sample-group {
  margin-bottom: 32px;
}

.sample-group-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.sample-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.sample-panel {
  background: var(--bg-card);
  padding: 20px;
}

.sample-lang {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.sample-panel:first-child .sample-lang { color: var(--english); }
.sample-panel:last-child .sample-lang { color: var(--lojban); }

.sample-prompt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow: auto;
}

.sample-generated {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  padding: 8px;
  background: rgba(0,0,0,0.1);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow: auto;
  line-height: 1.5;
}

.sample-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
}

/* ── Playground ────────────────────────────────────────────────────── */
.playground-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.playground-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
}

.english-accent { color: var(--english); }
.lojban-accent { color: var(--lojban); }

.model-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.model-badge.model-pending {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.model-badge.model-loading {
  background: rgba(74, 158, 255, 0.15);
  color: var(--english);
}

.model-badge.model-ready {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.model-badge.model-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--chance);
}

.playground-input {
  width: 100%;
  height: 80px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 12px;
  resize: vertical;
  transition: border-color 0.2s;
}
.playground-input:focus { outline: none; border-color: var(--accent); }

.playground-controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 80px;
}

.control-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.control-group span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

.btn-generate {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-generate:hover { background: #6b4be0; }
.btn-generate.disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-generate.generating {
  background: var(--border);
  cursor: wait;
}

.playground-output {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 120px;
  max-height: 300px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.output-prompt {
  color: var(--text-muted);
}

.output-generated {
  color: var(--success);
}

/* ── Methodology ───────────────────────────────────────────────────── */
.method-details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.method-details summary {
  padding: 16px 24px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  transition: color 0.2s;
  list-style: none;
}
.method-details summary::-webkit-details-marker { display: none; }
.method-details summary::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 12px;
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.method-details[open] summary::before {
  transform: rotate(90deg);
}
.method-details summary:hover { color: var(--accent); }

.method-content {
  padding: 0 24px 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.method-content ul, .method-content ol {
  padding-left: 20px;
}
.method-content li { margin-bottom: 8px; }
.method-content strong { color: var(--text-primary); }

.arch-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.arch-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
}

.arch-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.arch-section-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  margin: 16px 0 8px;
}
.arch-section-label:first-child { margin-top: 0; }

/* ── Footer ────────────────────────────────────────────────────────── */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 32px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-links a {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.footer-links a:hover { color: var(--text-primary); }

.footer-attr {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Fade-in Animation ─────────────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stat-cards { grid-template-columns: 1fr; gap: 12px; }
  .comparison-box { grid-template-columns: 1fr; }
  .properties-grid { grid-template-columns: 1fr; }
  .tokenizer-panels { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .sample-pair { grid-template-columns: 1fr; }
  .playground-panels { grid-template-columns: 1fr; }
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 0.75rem; }
  .section { padding: 48px 0; }
  .hero { padding: 80px 16px 40px; }
  .footer-inner { flex-direction: column; gap: 12px; text-align: center; }
  .playground-controls { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .nav-links { display: none; }
  .stat-value { font-size: 1.5rem; }
}
