/* shared.css — Design tokens, reset, typography, reusable components
   Theme: Electric blueprint · red primary */

:root {
  /* Surfaces */
  --bg: #0a0e1a;
  --bg-elevated: #141b2e;

  /* Text */
  --fg: #e8ecf7;
  --fg-dim: #a8b0c4;
  --muted: #6a7188;

  /* Brand colors */
  --primary: #ef4444;   /* brand red — active states, primary buttons, agent names */
  --accent: #00d4b4;    /* cyan — links, inline code, output badges */
  --warn: #e6a02d;      /* opt-in / EVOLUTION / DARWIN — kept warm for opt-in semantics */

  /* Borders */
  --border: #232b45;
  --border-dim: #1a2035;
  --border-strong: #4a5678;

  /* Typography */
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 78% 38% at 50% 0%, rgba(239, 68, 68, 0.16), transparent 65%),
    radial-gradient(ellipse 28% 22% at 92% 8%, rgba(0, 212, 180, 0.09), transparent 55%),
    radial-gradient(circle at 2px 2px, rgba(232, 236, 247, 0.025) 1px, transparent 0);
  background-size: 100% 980px, 100% 980px, 28px 28px;
  background-position: 0 0, 0 0, 0 0;
  background-repeat: no-repeat, no-repeat, repeat;
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 820px;
  width: 100%;
  padding: 2rem 1.5rem;
}

/* ----- Typography ----- */
h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  letter-spacing: -0.01em;
}

h2::before {
  content: '';
  width: 4px;
  height: 1.25rem;
  background: var(--accent);
  border-radius: 2px;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
}

p {
  margin-bottom: 1rem;
  color: var(--fg-dim);
}

p:last-child { margin-bottom: 0; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

/* ----- Links ----- */
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- Sections ----- */
section {
  margin-top: 3.5rem;
}

/* ----- Buttons ----- */
.btn {
  display: inline-block;
  padding: 0.6rem 1.3rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  border: 1px solid transparent;
  font-family: var(--sans);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: #dc2626;
  border-color: #dc2626;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--fg-dim);
  text-decoration: none;
}

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

/* ----- Cards ----- */
.deeper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.deeper-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.15rem;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.deeper-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.deeper-card h3 {
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.deeper-card p {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin: 0;
}

/* ----- Footer ----- */
footer {
  margin-top: 3.5rem;
  padding: 1.5rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  width: 100%;
  max-width: 820px;
}

footer a { margin: 0 0.4rem; }

/* ===== Subpage patterns ===== */

/* Breadcrumb nav */
.page-nav {
  padding: 1.5rem 0 0;
  font-size: 0.9rem;
}

.page-nav a {
  color: var(--fg-dim);
  font-weight: 500;
}

.page-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}

.page-nav .ape {
  font-family: var(--mono);
  color: var(--primary);
}

/* Page hero (subpages) */
.page-hero {
  padding: 2.5rem 0 2rem;
  max-width: 60ch;
}

.page-hero h1 {
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--fg);
}

.page-subhead {
  font-size: 1.1rem;
  color: var(--fg-dim);
  line-height: 1.6;
  max-width: 60ch;
}

/* Section intro paragraph */
.section-intro {
  color: var(--fg-dim);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 64ch;
  margin-bottom: 1.5rem;
}

/* Pull quote */
.pull-quote {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  font-weight: 500;
  color: var(--fg);
  line-height: 1.4;
  padding: 1.25rem 1.5rem;
  border-left: 3px solid var(--primary);
  background: var(--bg-elevated);
  border-radius: 0 6px 6px 0;
  margin: 0.5rem 0 1.5rem;
}

/* Code block (reusable) */
.code-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--fg);
  margin: 1rem 0 1.5rem;
}

.code-block .comment { color: var(--muted); }
.code-block .key { color: var(--accent); }
.code-block .string { color: var(--primary); }

/* Data table (reusable) */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table thead {
  background: rgba(110, 118, 129, 0.08);
}

.data-table th,
.data-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-dim);
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tbody th {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.data-table tbody td {
  color: var(--fg-dim);
  line-height: 1.55;
}

/* FSM diagram container (reusable) */
.fsm-diagram {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem 1rem;
  margin: 0.5rem 0 1.25rem;
  overflow-x: auto;
}

.fsm-diagram img,
.fsm-diagram svg {
  width: 100%;
  height: auto;
  max-width: 760px;
  display: block;
  margin: 0 auto;
}

/* Callout box (for privacy/important notices) */
.callout {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
  color: var(--fg-dim);
}

.callout--warn { border-left-color: var(--warn); }
.callout--ok { border-left-color: var(--primary); }
.callout strong { color: var(--fg); }

/* ----- Responsive ----- */
@media (max-width: 540px) {
  .container { padding: 1.5rem 1rem; }
  .data-table th,
  .data-table td { padding: 0.6rem 0.75rem; font-size: 0.85rem; }
  .data-table tbody th { font-size: 0.82rem; }
  .pull-quote { padding: 1rem 1.15rem; }
}
