/* === Terminal token system === */
:root {
  --bg: #050c05;
  --bg-elevated: #081308;
  --line: rgba(68, 255, 136, 0.12);
  --text: #ccffd8;
  --muted: #6c9b7e;
  --accent: #44ff88;
  --accent-dim: #22a855;
  --real: #44ff88;
  --concept: #ffb84d;
  --built: #8ec5ff;
  --danger: #ff7b7b;
  --font: ui-monospace, "Cascadia Code", "JetBrains Mono", "Fira Code", Menlo, monospace;
  --max-width: 1120px;
  --space: clamp(16px, 4vw, 32px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

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

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

button, select, input, textarea {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  color: inherit;
}

/* === Layout shell === */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  left: var(--space);
  top: var(--space);
  width: auto;
  height: auto;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--line);
  z-index: 1000;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--space);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 12, 5, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.brand strong {
  display: block;
  font-weight: 700;
  line-height: 1.1;
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.85em;
}

.nav {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover, .nav a:focus {
  color: var(--accent);
}

.cmd-trigger {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

main, .guide-main {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space);
}

/* === Hero === */
.hero-terminal {
  display: grid;
  gap: var(--space);
}
@media (min-width: 960px) {
  .hero-terminal {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: end;
  }
}

.hero-terminal__window {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9em;
}
.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #febc2e; }
.terminal-dot.green { background: #28c840; }

.terminal-body {
  padding: 18px;
}
.terminal-body p {
  margin: 0 0 8px;
}
.prompt {
  color: var(--muted);
  margin-right: 8px;
}
.typed {
  color: var(--accent);
}
.cursor {
  display: inline-block;
  width: 8px;
  color: var(--accent);
}
.terminal-muted {
  color: var(--muted);
  font-size: 0.95em;
}
.terminal-key {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.85em;
}

.hero-copy .eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.92em;
  margin: 0 0 10px;
}
.hero-copy h1 {
  font-size: clamp(1.35rem, 3.2vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 12px;
  max-width: 70ch;
}
.hero-copy .lede {
  color: var(--muted);
  margin-top: 4px;
  max-width: 68ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  padding: 10px 14px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.button.primary {
  background: var(--accent);
  color: #041a08;
  border-color: var(--accent);
}
.button.secondary {
  background: transparent;
}
.ghost-button {
  display: inline-flex;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  color: var(--text);
  cursor: pointer;
}

/* === Sections === */
.section {
  padding: var(--space) 0;
  border-top: 1px solid var(--line);
}
.section-kicker {
  color: var(--muted);
  font-size: 0.92em;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}
.split-heading {
  display: grid;
  gap: 12px;
  max-width: 72ch;
}
@media (min-width: 800px) {
  .split-heading {
    grid-template-columns: 1fr 1.2fr;
  }
}
.split-heading h2 {
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  margin: 0;
  line-height: 1.15;
}
.split-heading p {
  color: var(--muted);
  margin: 0;
}

/* === Filters === */
.terminal-controls {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  margin-bottom: 14px;
}
@media (min-width: 760px) {
  .terminal-controls {
    grid-template-columns: 1.2fr auto;
    align-items: end;
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  color: var(--muted);
  font-size: 0.92em;
}
input[type="search"], input[type="text"], input[type="url"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 0;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.filter-rail {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.filter-chip.active {
  color: #041a08;
  background: var(--accent);
  border-color: var(--accent);
}

/* === Proof grid === */
.proof-grid {
  display: grid;
  gap: 14px;
}
@media (min-width: 860px) {
  .proof-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.proof-card {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 16px;
  display: grid;
  gap: 10px;
}
.proof-card[hidden] {
  display: none;
}
.proof-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.proof-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.92em;
}
.proof-meta dt {
  color: #3c6b52;
}
.proof-card h3 {
  margin: 0;
  font-size: 1.05em;
  line-height: 1.25;
}
.proof-card p {
  margin: 0;
  color: var(--muted);
}
.proof-card a, .proof-card button {
  margin-top: 4px;
}

.label {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid currentColor;
  font-size: 0.85em;
}
.real-label { color: var(--real); border-color: rgba(68, 255, 136, 0.35); }
.concept-label { color: var(--concept); border-color: rgba(255, 184, 77, 0.35); }
.built-label { color: var(--built); border-border: rgba(142, 197, 255, 0.35); }

/* === Form === */
.form-grid {
  display: grid;
  gap: 12px;
}
@media (min-width: 720px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid .field:first-child,
  .form-grid .field:nth-child(5) {
    grid-column: 1 / -1;
  }
}

.proof-form {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  display: grid;
  gap: 12px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.form-result {
  padding: 10px;
  border: 1px solid var(--line);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Spec / closing === */
.spec-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}
.spec-list li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
}
@media (min-width: 640px) {
  .spec-list li {
    grid-template-columns: 160px 1fr;
  }
}
.spec-list strong {
  color: var(--accent);
}

/* === Dialog panels === */
.concept-panel {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 5, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space);
  z-index: 100;
}
.concept-panel[hidden] {
  display: none;
}
.concept-panel.is-open {
  display: flex;
}
.panel-card {
  width: 100%;
  max-width: 540px;
  max-height: min(90vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 16px;
}
.panel-close {
  float: right;
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

/* === Command palette === */
.command-palette {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 5, 0.8);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--space);
  z-index: 120;
}
.command-palette.is-open {
  display: flex;
}
.command-card {
  width: 100%;
  max-width: 680px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 12px;
  position: relative;
}
.command-body {
  margin-top: 10px;
}
.command-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 40vh;
  overflow: auto;
}
.command-results li {
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.command-results li mark {
  color: var(--accent);
  background: transparent;
}
.command-results .result-meta {
  color: var(--muted);
  font-size: 0.9em;
}
#cmd-hint {
  margin-top: 10px;
}
#cmd-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  padding: 6px 10px;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  .scanlines,
  .cursor {
    animation: none !important;
    opacity: 1;
  }
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: repeating-linear-gradient(
    0deg,
    rgba(68, 255, 136, 0.04),
    rgba(68, 255, 136, 0.04) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  animation: scanline-drift 12s linear infinite;
}
@keyframes scanline-drift {
  from { transform: translateY(0); }
  to { transform: translateY(12px); }
}

/* === Overflow fallback === */
.overflow-fallback {
  overflow-x: auto;
  padding-bottom: 8px;
}

/* === Guide === */
.guide-article {
  display: grid;
  gap: 22px;
  max-width: 70ch;
}
.guide-grid {
  display: grid;
  gap: 12px;
}
@media (min-width: 560px) {
  .guide-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.pass-list {
  padding-left: 20px;
}
.pass-list li + li {
  margin-top: 8px;
}

.footer {
  padding: 22px var(--space);
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.terminal-pre {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0 0;
}

.cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
