/* API Explorer
   ========================================================================== */

@import url('fonts.css');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #08080a;
  --surface: #141416;
  --surface-hover: #1c1c20;
  --surface-active: #242428;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f0ede8;
  --text-secondary: #a8a29e;
  --text-dim: #5c5955;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.12);
  --accent-dim: rgba(16, 185, 129, 0.6);

  --type-json: #f59e0b;
  --type-md: #3b82f6;
  --type-dir: #a855f7;
}

/* Light surface override */
[data-surface="light"] {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-hover: #f0ede8;
  --surface-active: #e8e4dc;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text: #14161c;
  --text-secondary: #4a4540;
  --text-dim: #8a8580;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-wrap: pretty;
  overflow-x: hidden;
}

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

code, .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

[data-surface="light"] .site-header {
  background: rgba(245, 244, 239, 0.85);
}

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

.header-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.header-nav { display: flex; gap: 4px; }

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); text-decoration: none; }
.nav-link--active { color: var(--text); background: var(--surface); }

/* Hero */
.api-hero {
  max-width: 1000px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  text-align: center;
}

.hero-eyebrow {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero-lede {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
}

/* Stats row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.stat-block {
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  display: block;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* Content sections */
.api-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

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

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Endpoint table */
.endpoint-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.endpoint-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.endpoint-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.endpoint-table tr:hover td {
  background: var(--surface);
}

.endpoint-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
}

.endpoint-path a {
  color: inherit;
}

.endpoint-desc {
  color: var(--text-secondary);
}

/* Type badges */
.type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-active);
}

.type-badge--json { color: var(--type-json); border: 1px solid rgba(245, 158, 11, 0.2); }
.type-badge--markdown { color: var(--type-md); border: 1px solid rgba(59, 130, 246, 0.2); }
.type-badge--directory { color: var(--type-dir); border: 1px solid rgba(168, 85, 247, 0.2); }

/* Code blocks */
.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.code-block .key { color: var(--accent); }
.code-block .str { color: var(--type-json); }
.code-block .num { color: #ef4444; }
.code-block .comment { color: var(--text-dim); }

/* Pattern list (per-game endpoints) */
.pattern-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.pattern-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.pattern-row:last-child { border-bottom: none; }

.pattern-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}

.pattern-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  background: none;
  padding: 0;
}

.pattern-path .key { color: var(--accent); }

/* Flow diagram (how it works) */
.flow-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.flow-step {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
}

.flow-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  min-width: 100px;
  flex-shrink: 0;
}

.flow-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  background: none;
  padding: 0;
  word-break: break-all;
}

.flow-arrow {
  width: 1px;
  height: 20px;
  margin: 0 0 0 48px;
  background: linear-gradient(to bottom, var(--accent-dim), transparent);
  position: relative;
}

.flow-arrow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -3px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--accent-dim);
  border-bottom: 1px solid var(--accent-dim);
  transform: rotate(45deg);
}

@media (max-width: 768px) {
  .pattern-row { flex-direction: column; gap: 4px; }
  .pattern-label { min-width: unset; }
  .flow-step { flex-direction: column; gap: 4px; }
  .flow-label { min-width: unset; }
}

/* Deprecation table */
.deprecation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.deprecation-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.deprecation-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.deprecation-table .old { color: var(--text-dim); text-decoration: line-through; }
.deprecation-table .new { color: var(--accent); }

/* Links section */
.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.link-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
}

.link-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 0 20px var(--accent-glow);
  text-decoration: none;
}

.link-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.link-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.link-card-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent-dim);
  margin-top: 8px;
  display: block;
}

/* Surface toggle */
.surface-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.surface-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/* Footer */
.site-footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.site-footer-inner {
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

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

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-col:nth-child(2) { align-items: center; }
.footer-col:nth-child(3) { align-items: flex-end; }

.footer-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.footer-col a {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-col a:hover { color: var(--text); }

.footer-version {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
  .api-hero { padding: 40px 16px 32px; }
  .api-content { padding: 0 16px 60px; }
  .stats-row { gap: 20px; }
  .endpoint-table { font-size: 11px; }
  .endpoint-table td, .endpoint-table th { padding: 8px; }
  .footer-columns { grid-template-columns: 1fr; text-align: center; }
  .footer-col:nth-child(2),
  .footer-col:nth-child(3) { align-items: center; }
  .footer-bottom { flex-direction: column; gap: 8px; }
}
