/* ctrl-exec.io — main stylesheet
   Dark technical reference site
   Typeface: Departure Mono (headings/code) + Mona Sans (body)
   Accent: #00c896 (teal-green — evokes terminal output, mTLS handshake)
   Background: #0d1117 (GitHub-dark approximate)
   ------------------------------------------------------------------ */

/* ── Fonts ─────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Mona+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* Departure Mono — served locally or via CDN fallback */
@font-face {
  font-family: 'Departure Mono';
  src: url('fonts/DepartureMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ── Design tokens ──────────────────────────────────────────────────── */

:root {
  /* Palette */
  --bg:           #0d1117;
  --bg-surface:   #161b22;
  --bg-raised:    #1c2128;
  --bg-border:    #21262d;
  --bg-hover:     #1f2937;

  --text:         #e2e8f0;
  --text-muted:   #7d8590;
  --text-faint:   #484f58;

  --accent:       #00c896;
  --accent-dim:   #00a37a;
  --accent-glow:  rgba(0, 200, 150, 0.12);

  --code-bg:      #161b22;
  --code-border:  #21262d;
  --code-text:    #adbac7;

  --link:         #00c896;
  --link-hover:   #33d9aa;
  --link-visited: #00a37a;

  --warn:         #e3b341;
  --danger:       #f85149;

  /* Layout */
  --sidebar-w:    240px;
  --header-h:     52px;
  --content-max:  68ch;
  --page-max:     1200px;

  /* Type scale */
  --font-body:    'Mona Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'Departure Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:      0.75rem;
  --text-sm:      0.875rem;
  --text-base:    1rem;
  --text-lg:      1.125rem;
  --text-xl:      1.375rem;
  --text-2xl:     1.75rem;
  --text-3xl:     2.25rem;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 3px;
  --radius:    5px;
  --radius-lg: 8px;
}

/* ── Reset ──────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Base ───────────────────────────────────────────────────────────── */

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── Page shell ─────────────────────────────────────────────────────── */

.page-shell {
  display: grid;
  grid-template-rows: var(--header-h) 1fr auto;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "header  header"
    "sidebar content"
    "footer  footer";
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────── */

.site-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-6);
}

.site-header__wordmark {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-header__wordmark span {
  color: var(--accent);
}

.site-header__version {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.site-header__spacer {
  flex: 1;
}

.site-header__links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  list-style: none;
}

.site-header__links a {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header__links a:hover {
  color: var(--text);
}

.site-header__links .header-cta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.site-header__links .header-cta:hover {
  background: var(--accent-glow);
  color: var(--link-hover);
}

/* ── Sidebar ────────────────────────────────────────────────────────── */

.site-nav {
  grid-area: sidebar;
  width: var(--sidebar-w);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--bg-border);
  padding: var(--space-6) 0 var(--space-16);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-border) transparent;
}

.site-nav::-webkit-scrollbar {
  width: 4px;
}

.site-nav::-webkit-scrollbar-track {
  background: transparent;
}

.site-nav::-webkit-scrollbar-thumb {
  background: var(--bg-border);
  border-radius: 2px;
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-section__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 var(--space-6);
  margin-bottom: var(--space-2);
}

.nav-section__items {
  list-style: none;
}

.nav-section__items li a {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-6);
  line-height: 1.5;
  border-left: 2px solid transparent;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.nav-section__items li a:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-section__items li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

.nav-section__items li a code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: inherit;
  background: none;
  padding: 0;
}

.nav-divider {
  height: 1px;
  background: var(--bg-border);
  margin: var(--space-4) var(--space-6);
}

/* ── Main content ───────────────────────────────────────────────────── */

.site-content {
  grid-area: content;
  min-width: 0;
  padding: var(--space-12) var(--space-12) var(--space-16);
}

.content-inner {
  max-width: var(--content-max);
}

/* Page header block (rendered from SSI include) */
.page-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--bg-border);
}

.page-header__title {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: var(--space-2);
  line-height: 1.2;
}

.page-header__summary {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

.page-header__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-header__raw-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-decoration: none;
  border: 1px solid var(--bg-border);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  transition: color 0.12s, border-color 0.12s;
}

.page-header__raw-link:hover {
  color: var(--text-muted);
  border-color: var(--text-faint);
}

.page-header__updated {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ── Prose typography ───────────────────────────────────────────────── */

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
  line-height: 1.25;
}

.prose h1 { font-size: var(--text-2xl); margin-top: 0; }
.prose h2 { font-size: var(--text-xl);  padding-bottom: var(--space-2); border-bottom: 1px solid var(--bg-border); }
.prose h3 { font-size: var(--text-lg);  color: var(--text); }
.prose h4 { font-size: var(--text-base); color: var(--text-muted); }

.prose p {
  margin-bottom: var(--space-4);
  max-width: var(--content-max);
}

.prose a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.12s, color 0.12s;
}

.prose a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

.prose a:visited {
  color: var(--link-visited);
}

.prose strong {
  font-weight: 600;
  color: var(--text);
}

.prose em {
  font-style: italic;
  color: var(--text-muted);
}

.prose ul,
.prose ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
}

.prose li {
  margin-bottom: var(--space-2);
}

.prose li::marker {
  color: var(--text-faint);
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-6) 0;
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.prose blockquote p {
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--bg-border);
  margin: var(--space-8) 0;
}

/* Definition lists */
.prose dl {
  margin: var(--space-6) 0;
}

.prose dt {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
}

.prose dd {
  color: var(--text-muted);
  padding-left: var(--space-4);
  border-left: 1px solid var(--bg-border);
  margin-left: 0;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin: var(--space-6) 0;
}

.prose thead {
  border-bottom: 1px solid var(--bg-border);
}

.prose th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: left;
  padding: var(--space-2) var(--space-4) var(--space-2) 0;
}

.prose td {
  padding: var(--space-2) var(--space-4) var(--space-2) 0;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-muted);
  vertical-align: top;
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose td:first-child,
.prose th:first-child {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--code-text);
}

/* ── Inline code ────────────────────────────────────────────────────── */

.prose code,
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--accent);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* ── Code blocks (Pandoc output classes) ────────────────────────────── */

/* Pandoc wraps code blocks: <div class="sourceCode"><pre class="sourceCode"><code class="sourceCode"> */

div.sourceCode,
.prose pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  margin: var(--space-6) 0;
  overflow: hidden;
}

div.sourceCode pre,
.prose pre {
  overflow-x: auto;
  padding: var(--space-4) var(--space-6);
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-border) transparent;
}

div.sourceCode pre code,
.prose pre code {
  font-family: inherit;
  font-size: inherit;
  color: var(--code-text);
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* Language tag on code blocks */
div.sourceCode::before {
  content: attr(data-lang);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: var(--space-2) var(--space-6);
  border-bottom: 1px solid var(--code-border);
  background: var(--bg);
}

/* Pandoc syntax highlighting token colours */
code span.al { color: #f85149; }                /* Alert */
code span.an { color: var(--text-faint); font-style: italic; } /* Annotation */
code span.at { color: #79c0ff; }                /* Attribute */
code span.bn { color: #79c0ff; }                /* Base-N number */
code span.bu { color: #d2a8ff; }                /* Built-in */
code span.cf { color: #f97583; }                /* Control flow */
code span.ch { color: #96d0ff; }                /* Char */
code span.cn { color: #79c0ff; }                /* Constant */
code span.co { color: var(--text-faint); font-style: italic; } /* Comment */
code span.cv { color: var(--text-faint); }      /* Comment var */
code span.do { color: var(--text-faint); font-style: italic; } /* Documentation */
code span.dt { color: #ffa657; }                /* Data type */
code span.dv { color: #79c0ff; }                /* Decimal value */
code span.er { color: #f85149; }                /* Error */
code span.ex { color: var(--accent); }          /* Extension */
code span.fl { color: #79c0ff; }                /* Float */
code span.fu { color: #d2a8ff; }                /* Function */
code span.im { color: var(--accent); }          /* Import */
code span.in { color: var(--text-faint); font-style: italic; } /* Info */
code span.kw { color: #f97583; }                /* Keyword */
code span.op { color: #adbac7; }                /* Operator */
code span.ot { color: #79c0ff; }                /* Other token */
code span.pp { color: #d2a8ff; }                /* Pre-processor */
code span.re { color: var(--accent); }          /* Regex */
code span.sc { color: #96d0ff; }                /* Char special */
code span.ss { color: #96d0ff; }                /* String special */
code span.st { color: #96d0ff; }                /* String */
code span.va { color: #e3b341; }                /* Variable */
code span.vs { color: #96d0ff; }                /* String verbatim */
code span.wa { color: #e3b341; font-style: italic; } /* Warning */

/* ── Admonition / callout boxes ─────────────────────────────────────── */
/* Mapped from Pandoc div classes: .note, .warning, .important         */

.note, .warning, .important, .tip {
  border-left: 2px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
}

.note {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.warning {
  border-color: var(--warn);
  background: rgba(227, 179, 65, 0.08);
}

.important {
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.08);
}

.tip {
  border-color: #79c0ff;
  background: rgba(121, 192, 255, 0.08);
}

.note::before    { content: "note";      font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);  display: block; margin-bottom: var(--space-2); }
.warning::before { content: "warning";   font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--warn);    display: block; margin-bottom: var(--space-2); }
.important::before { content: "important"; font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--danger); display: block; margin-bottom: var(--space-2); }
.tip::before     { content: "tip";       font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: #79c0ff;        display: block; margin-bottom: var(--space-2); }

/* ── Pandoc fenced div styles ───────────────────────────────────────── */
/* Source: ::: marginbox, ::: examplebox, ::: widebox, ::: textbox      */

/* Shared base for all four */
.marginbox,
.examplebox,
.widebox,
.textbox {
  margin: var(--space-8) 0;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.marginbox p,
.examplebox p,
.widebox p,
.textbox p {
  margin-bottom: var(--space-2);
}

.marginbox p:last-child,
.examplebox p:last-child,
.widebox p:last-child,
.textbox p:last-child {
  margin-bottom: 0;
}

/* marginbox — pull quote / key point in a restrained side treatment */
.marginbox {
  border-left: 2px solid var(--accent-dim);
  padding: var(--space-4) var(--space-6);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-style: italic;
}

.marginbox strong {
  display: block;
  margin-top: var(--space-3);
  font-style: normal;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 400;
}

/* examplebox — evidence, case studies, concrete examples */
.examplebox {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-top: 2px solid #79c0ff;
  padding: var(--space-4) var(--space-6);
  color: var(--text-muted);
}

.examplebox::before {
  content: "example";
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #79c0ff;
  margin-bottom: var(--space-3);
}

.examplebox strong {
  color: var(--text);
  font-style: normal;
}

/* widebox — full content-column width, critical point */
.widebox {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--bg-border);
  border-left: 3px solid var(--accent);
  padding: var(--space-6);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
}

/* textbox — 60% width, brief emphasis */
.textbox {
  width: 60%;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-left: 2px solid var(--accent-dim);
  padding: var(--space-4) var(--space-6);
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .textbox {
    width: 100%;
  }
}

/* ── Homepage layout ────────────────────────────────────────────────── */

.home-hero {
  padding: var(--space-12) 0 var(--space-8);
  border-bottom: 1px solid var(--bg-border);
  margin-bottom: var(--space-8);
}

.home-hero__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.home-hero__headline {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: var(--space-4);
}

.home-hero__headline span {
  color: var(--accent);
}

.home-hero__desc {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 58ch;
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.home-hero__install {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--code-text);
  cursor: text;
  user-select: all;
}

.home-hero__install .prompt {
  color: var(--accent);
  user-select: none;
}

.home-quickstart {
  margin-bottom: var(--space-12);
}

.home-quickstart h2 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-6);
}

/* Document index grid */
.doc-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.doc-index__card {
  display: block;
  padding: var(--space-4) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.12s, background 0.12s;
}

.doc-index__card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-raised);
}

.doc-index__card-label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
  margin-bottom: var(--space-1);
}

.doc-index__card-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.doc-index__card-section {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: var(--space-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Footer ─────────────────────────────────────────────────────────── */

.site-footer {
  grid-area: footer;
  border-top: 1px solid var(--bg-border);
  padding: var(--space-6) var(--space-12);
  display: flex;
  align-items: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.site-footer__wordmark {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-faint);
  text-decoration: none;
}

.site-footer__wordmark span {
  color: var(--accent-dim);
}

.site-footer__links {
  display: flex;
  gap: var(--space-6);
  list-style: none;
  flex: 1;
}

.site-footer__links a {
  font-size: var(--text-sm);
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.12s;
}

.site-footer__links a:hover {
  color: var(--text-muted);
}

.site-footer__copy {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
}

/* ── Utility classes ────────────────────────────────────────────────── */

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.accent { color: var(--accent); }

/* Binary name pill */
.bin {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(0, 200, 150, 0.2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
}

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .page-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "content"
      "footer";
  }

  .site-nav {
    display: none;
  }

  .site-content {
    padding: var(--space-8) var(--space-6) var(--space-12);
  }

  .site-footer {
    padding: var(--space-6);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
}

@media (max-width: 600px) {
  .home-hero__headline {
    font-size: var(--text-2xl);
  }

  .doc-index {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding: 0 var(--space-4);
  }
}
