/* ============================================================
   canalyzer_test — signal bench theme
   Dark default: deep charcoal + amber phosphor accent.
   ============================================================ */

:root {
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --content-w: 760px;
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- theme tokens ---------- */
html[data-theme="dark"] {
  --bg: #0d0f12;
  --bg-raise: #14171c;
  --bg-inset: #0a0c0e;
  --line: #23272e;
  --line-strong: #333944;
  --text: #e8e6e1;
  --text-dim: #9aa0a8;
  --text-faint: #5c636d;
  --accent: #f5a623;
  --accent-soft: rgba(245, 166, 35, 0.12);
  --accent-line: rgba(245, 166, 35, 0.35);
  --good: #4ade80;
  --scope-grid: rgba(255, 255, 255, 0.05);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f4ef;
  --bg-raise: #ffffff;
  --bg-inset: #edeae2;
  --line: #ddd8cd;
  --line-strong: #c5bfb1;
  --text: #1c1e21;
  --text-dim: #5a5f66;
  --text-faint: #8b9097;
  --accent: #b56a00;
  --accent-soft: rgba(181, 106, 0, 0.10);
  --accent-line: rgba(181, 106, 0, 0.35);
  --good: #15803d;
  --scope-grid: rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

/* subtle blueprint grid behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--scope-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--scope-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 70%);
  z-index: 0;
}

main, .nav, .footer { position: relative; z-index: 1; }

.mono { font-family: var(--font-mono); }

a { color: inherit; }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  font-family: var(--font-mono);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}

.brand-mark { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 1.1rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text-dim);
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent); }

.nav-links a[aria-current] { color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

html[data-theme="dark"] .theme-icon-light { display: none; }
html[data-theme="light"] .theme-icon-dark { display: none; }

/* ---------- hero ---------- */
.hero {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 5.5rem 1.25rem 3.5rem;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 2.2rem;
}

.hero-title {
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  line-height: 1.05;
  margin-bottom: 1.4rem;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  color: var(--text-dim);
  max-width: 34rem;
  margin-bottom: 2.2rem;
}

.hero-actions { display: flex; gap: 0.9rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  transition: transform 0.15s var(--ease), border-color 0.2s, background 0.2s;
}

.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #14120c;
  font-weight: 500;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-block { display: block; text-align: center; margin-top: 1.1rem; }

.hero-scope {
  margin-top: 3.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-inset);
  overflow: hidden;
}

.hero-scope canvas { display: block; width: 100%; height: 150px; }

.scope-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--line);
}

/* ---------- sections ---------- */
.section {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 1rem;
}

.section-head { margin-bottom: 2.2rem; }

.section-index {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
}

.section-head h2 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  margin: 0.3rem 0 0.6rem;
}

.section-sub { color: var(--text-dim); max-width: 36rem; }

/* ---------- badges ---------- */
.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-version { border-color: var(--accent-line); color: var(--accent); }
.badge-status  { border-color: var(--accent-line); color: var(--accent); }
.badge-active  { border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); }
.badge-wip     { border-color: var(--accent-line); color: var(--accent); }

/* ---------- downloads ---------- */
.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.2rem;
}

.dl-card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.25s, transform 0.25s var(--ease);
}

.dl-card:hover { border-color: var(--accent-line); transform: translateY(-3px); }

.dl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.dl-os {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.dl-card h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

.dl-card > p { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 1.1rem; }

.dl-facts {
  list-style: none;
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
  margin-bottom: 1.1rem;
}

.dl-facts li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.dl-facts li span:first-child { color: var(--text-faint); }

.dl-hash {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.74rem;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.5rem 0.7rem;
}

.hash-label { color: var(--text-faint); }
.hash-value { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; flex: 1; }

.hash-copy {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
}

.hash-copy:hover { text-decoration: underline; }

.dl-note {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.8rem 1rem;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- modules: domain cards ---------- */
.domain {
  display: none;
  background: var(--bg-raise);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 1.8rem;
  margin-bottom: 1.6rem;
}

.domain.open {
  display: block;
  animation: domain-in 0.35s var(--ease);
}

@keyframes domain-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .domain.open { animation: none; }
}

.domain:hover { border-color: var(--line-strong); }

.domain-head {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.domain-num {
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--text-faint);
}

.domain:hover .domain-num { color: var(--accent); }

.domain-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 200px;
}

.domain-title h3 { font-size: 1.45rem; }

.domain-tagline {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.domain-pitch {
  color: var(--text-dim);
  margin: 1rem 0 0.4rem;
  max-width: 40rem;
}

/* ---------- capability rows ---------- */
.caps {
  margin-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.cap {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1.1rem;
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--line);
}

.cap:last-child { border-bottom: none; padding-bottom: 0.3rem; }

.cap-index {
  font-size: 0.8rem;
  color: var(--text-faint);
  padding-top: 0.2rem;
}

.cap:hover .cap-index { color: var(--accent); }

.cap-body h4 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.cap-body > p {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 38rem;
}

.cap-note {
  margin-top: 0.5rem;
  font-size: 0.74rem;
  color: var(--text-faint);
  font-style: italic;
}

.cap-note::before { content: "// "; color: var(--accent); font-style: normal; }

.cap-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.cap-featured .cap-body h4 { color: var(--accent); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.tags span {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  transition: color 0.2s, border-color 0.2s;
}

.cap:hover .tags span { border-color: var(--line-strong); }

/* ---------- bench plan (interactive diagram) ---------- */
.bp-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-inset);
  margin-bottom: 1.2rem;
  overflow: hidden;
  /* break out of the content column, up to 1080px */
  width: min(calc(100vw - 2.5rem), 1080px);
  margin-left: calc(50% - min(calc(50vw - 1.25rem), 540px));
}

.bp-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

#benchplan text {
  font-family: var(--font-mono);
  font-size: 15px;
  fill: var(--text);
  letter-spacing: 0.04em;
  pointer-events: none;
}

#benchplan text.dim { fill: var(--text-faint); font-size: 13px; }
#benchplan text.tiny { font-size: 11px; letter-spacing: 0.12em; }

.bp-node { cursor: pointer; outline: none; }

.bp-node rect {
  fill: var(--bg-raise);
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: stroke 0.2s, fill 0.2s;
}

.bp-node.wip rect { stroke-dasharray: 6 4; }

.bp-node:hover rect,
.bp-node:focus-visible rect,
.bp-node.lit rect {
  stroke: var(--accent);
  fill: var(--accent-soft);
}

.bp-node:hover text,
.bp-node:focus-visible text,
.bp-node.lit text { fill: var(--accent); }

.bp-line, .bp-rail {
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: stroke 0.2s;
}

.bp-rail { stroke-width: 2; }

.bp-line.dashed { stroke-dasharray: 5 5; }

.bp-line.lit, .bp-rail.lit { stroke: var(--accent); }

.bp-info {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--line);
  min-height: 2.1rem;
}

.bp-info strong { color: var(--accent); font-weight: 500; }

.bp-node.selected rect { stroke: var(--accent); fill: var(--accent-soft); }
.bp-node.selected text { fill: var(--accent); }

/* ---------- module pills ---------- */
.mod-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.mod-pills button {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.mod-pills button:hover { color: var(--accent); border-color: var(--accent-line); }

.mod-pills button[aria-selected="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- bench stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.2rem;
}

.stat-value {
  display: block;
  font-size: 2.1rem;
  font-weight: 500;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.framebar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-inset);
  padding: 1rem;
}

.framebar-track {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
  overflow: hidden;
}

.framebar-track i {
  flex: 1;
  min-width: 3px;
  background: var(--accent);
  opacity: 0.75;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s var(--ease);
}

.framebar-caption {
  margin-top: 0.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

/* ---------- license page ---------- */
.hero-compact { padding-bottom: 0; }

.hero-title-sm { font-size: clamp(2.2rem, 5vw, 3.2rem); }

.section-sub a, .about-body a { color: var(--accent); }

.license-doc {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.8rem;
}

.license-doc h3 {
  font-size: 1.15rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.license-clauses {
  margin-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.license-clauses strong { color: var(--text); font-weight: 500; }

.notice-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg-raise);
}

.notice-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.notice-table th, .notice-table td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.notice-table th {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.notice-table td { color: var(--text-dim); }
.notice-table td:first-child { color: var(--text); }
.notice-table tbody tr:last-child td { border-bottom: none; }

.notice-table a { color: var(--accent); text-decoration: none; }
.notice-table a:hover { text-decoration: underline; }

.hw-note { color: var(--text-faint); font-size: 0.9em; }

/* hardware table: wrap instead of scroll */
.hw-table th, .hw-table td { white-space: normal; }
.hw-table table { font-size: 0.76rem; }
.hw-table td:nth-child(4) { white-space: nowrap; }
.hw-table a { white-space: nowrap; }

.dl-note-wrap { white-space: normal; }

/* ---------- bug report builder ---------- */
.bug-form {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 1.4rem;
}

.bug-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bug-form label > span {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.bug-form input[type="text"],
.bug-form textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.6rem 0.8rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}

.bug-form input:focus,
.bug-form textarea:focus { border-color: var(--accent-line); }

.bug-form ::placeholder { color: var(--text-faint); }

.bug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.bug-grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.bug-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.bug-steps li { display: flex; align-items: baseline; gap: 0.7rem; }

.bug-steps li > div span { color: var(--accent); }

.bug-steps li > span {
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.bug-steps strong { color: var(--text); font-weight: 500; }

.bug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.bug-actions .btn { cursor: pointer; }

button.btn {
  background: none;
  color: inherit;
  font-family: var(--font-mono);
}

button.btn.btn-primary {
  background: var(--accent);
  color: #14120c;
}

.bug-status {
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.bug-status.ok { color: var(--good); }
.bug-status.warn { color: var(--accent); }

/* ---------- about / footer ---------- */
.about-body { color: var(--text-dim); max-width: 38rem; padding-bottom: 2rem; }

.footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
}

.footer-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.footer a { color: var(--text-dim); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* ---------- reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover, .dl-card:hover { transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .nav-links { gap: 0.8rem; }
  .nav-links a { flex-shrink: 0; }
  .domain { padding: 1.2rem; }
  .cap { grid-template-columns: 1fr; gap: 0.3rem; }
  .cap-index { padding-top: 0; }
  .hero { padding-top: 3.5rem; }
}
