/* The demo site's stylesheet. No framework, no build step — the same policy
 * the JS follows, for the same reason.
 *
 * This is the kryptic.sh design system, ported rather than linked. Pulling
 * `https://www.kryptic.sh/assets/css/base.css` would have been DRY-er and is
 * exactly the coupling this site exists to avoid: the demos deploy from their
 * own repo on their own cadence, and a page that renders correctly only while
 * another origin is up is not standalone. Variable names, scale and component
 * classes match the org site so the two read as one family; the accent is
 * `--purple`, the same one www.kryptic.sh/projects/crcbl/ uses.
 */

:root {
  color-scheme: dark;

  --bg: #0b0d10;
  --bg-alt: #11141a;
  --panel: #141820;
  --border: #1f2530;
  --border-strong: #2a3240;
  --fg: #e5e9f0;
  --fg-dim: #8b95a7;
  --fg-muted: #8a93a4;

  --accent: #bb9af7;
  --accent-dim: #5a4b7a;
  --accent-ink: #1a1226;
  --accent-hover: #cdb6fa;

  --orange: #ff9e64;
  --green: #7ee787;
  --blue: #7aa2f7;
  --red: #f7768e;

  --mono:
    'Hack', 'JetBrains Mono', 'DejaVu Sans Mono', 'Liberation Mono', monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(
      circle at 20% 0%,
      rgba(187, 154, 247, 0.08),
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(122, 162, 247, 0.05),
      transparent 45%
    );
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 900px) {
  body {
    background-attachment: fixed;
  }
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--accent);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── the bar back to the rest of the org ─────────────────────────────────── */

.siblings {
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.siblings-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: var(--fg-muted);
  align-items: center;
}

.siblings-inner a {
  color: var(--fg-muted);
}

.siblings-inner a:hover {
  color: var(--accent);
  text-decoration: none;
}

.siblings-inner .current {
  color: var(--accent);
}

.siblings-inner .sep {
  color: var(--border-strong);
}

/* ── top nav ─────────────────────────────────────────────────────────────── */

nav.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  max-width: 1040px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

.brand a {
  color: var(--fg);
}

.brand .prompt {
  color: var(--accent);
}

.brand .cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  vertical-align: middle;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand .cursor {
    animation: none;
  }
}

nav.top .links {
  display: flex;
  gap: 22px;
  font-size: 14px;
  color: var(--fg-dim);
}

nav.top .links a {
  color: var(--fg-dim);
}

nav.top .links a:hover {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 560px) {
  nav.top {
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 16px 20px;
    justify-content: center;
  }

  nav.top .brand,
  nav.top .links {
    width: 100%;
    justify-content: center;
  }

  nav.top .links {
    gap: 14px;
    flex-wrap: wrap;
  }
}

/* ── hero ────────────────────────────────────────────────────────────────── */

header.hero {
  padding: 24px 0 40px;
}

h1 {
  font-size: clamp(36px, 6vw, 62px);
  line-height: 1.05;
  margin: 0 0 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 .grad {
  background: linear-gradient(
    120deg,
    var(--accent) 0%,
    var(--blue) 45%,
    var(--green) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  font-size: 20px;
  line-height: 1.4;
  color: var(--fg-dim);
  margin: 0 0 14px;
  max-width: 680px;
}

.tagline.small {
  font-size: 16px;
  color: var(--fg-muted);
}

.badges {
  margin: 16px 0 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  line-height: 1;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--fg-dim);
  background: var(--bg-alt);
}

.badge.live {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.badge.warn {
  color: var(--orange);
  border-color: #7a4a2a;
}

.cta {
  margin-top: 30px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  font-size: 14px;
  font-weight: 500;
  font-family: var(--mono);
  padding: 11px 18px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  background: var(--bg-alt);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
  border-color: var(--accent-hover);
}

/* ── sections ────────────────────────────────────────────────────────────── */

section {
  padding: 56px 0;
  border-top: 1px solid var(--border);
}

section h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-muted);
  margin: 0 0 8px;
  font-weight: 500;
}

section h2::before {
  content: '## ';
  color: var(--accent);
}

section h3 {
  font-size: 26px;
  line-height: 1.25;
  margin: 0 0 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

section p {
  color: var(--fg-dim);
  max-width: 760px;
}

/* ── the terminal frame, reused for the canvas ───────────────────────────── */

.terminal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.terminal .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #0d1016;
  border-bottom: 1px solid var(--border);
}

.terminal .bar .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.terminal .bar .dot.r {
  background: #ff5f56;
}

.terminal .bar .dot.y {
  background: #ffbd2e;
}

.terminal .bar .dot.g {
  background: #27c93f;
}

.terminal .bar .title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--fg-muted);
  font-size: 12px;
  pointer-events: none;
}

/* ── demo grid ───────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0;
}

.grid > li {
  display: flex;
}

.feat {
  background: var(--bg-alt);
  padding: 24px;
  display: block;
  width: 100%;
  color: inherit;
  transition: background 0.15s;
}

a.feat:hover {
  background: var(--panel);
  text-decoration: none;
}

.feat .icon {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.feat h4 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}

.feat p {
  margin: 0;
  color: var(--fg-dim);
  font-size: 14.5px;
  line-height: 1.55;
}

.feat.soon {
  opacity: 0.5;
}

/* ── the playfield ───────────────────────────────────────────────────────── */

.stage {
  margin: 0 0 28px;
}

#canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Bounded so the playfield and its status bar fit a laptop viewport without
     scrolling. At 1040px wide a 4:3 canvas is 780px tall, which pushes the
     status line — and half the game — off a 768px screen. */
  max-height: 68vh;
  margin: 0 auto;
  background: #000;
  /* The engine reads keys off the canvas, so it has to be focusable — but a
     focus ring drawn over a game viewport reads as a rendering artifact. The
     frame lights up instead: same signal, right idiom. */
  outline: none;
}

.stage:focus-within {
  border-color: var(--accent-dim);
}

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #0d1016;
  font-size: 13px;
  color: var(--fg-dim);
  flex-wrap: wrap;
}

.status .live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
  flex: none;
}

.status.running .live {
  background: var(--green);
}

.status.failed .live {
  background: var(--red);
}

#status.fatal {
  color: var(--red);
}

#detail {
  color: var(--fg-muted);
  font-size: 12px;
  margin-left: auto;
}

.status button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--fg-dim);
  background: var(--bg-alt);
  cursor: pointer;
  transition: all 0.15s;
}

.status button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.status button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── keys ────────────────────────────────────────────────────────────────── */

.keys {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.key-row span {
  color: var(--fg-dim);
}

kbd {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 7px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--accent);
  white-space: nowrap;
}

/* ── callout ─────────────────────────────────────────────────────────────── */

.note {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 18px 22px;
  color: var(--fg-dim);
  max-width: 760px;
}

.note strong {
  color: var(--accent);
}

.note.warn {
  border-left-color: var(--orange);
}

.note.warn strong {
  color: var(--orange);
}

/* ── footer ──────────────────────────────────────────────────────────────── */

footer {
  padding: 40px 0 60px;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

footer a {
  color: var(--fg-dim);
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}
