/* === COLOR SYSTEM === */
:root {
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-sidebar: #f3f4f6;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-subtle: #f3f4f6;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --code-bg: #f3f4f6;
  --code-border: #e5e7eb;
  --link: #4f46e5;
}

[data-theme="dark"] {
  --bg: #18181b;
  --bg-secondary: #27272a;
  --bg-sidebar: #1f1f23;
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border: #3f3f46;
  --border-subtle: #27272a;
  --accent: #818cf8;
  --accent-light: #1e1b4b;
  --code-bg: #27272a;
  --code-border: #3f3f46;
  --link: #818cf8;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

/* === HEADER === */
.site-header {
  background: #4f46e5;
  border-bottom: 1px solid #4338ca;
  height: 56px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.wordmark {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.wordmark-clef {
  display: inline-block;
  position: relative;
  font-size: 1.75rem;
  line-height: 1;
  vertical-align: middle;
  padding: 0 3px;
}

.wordmark-clef::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 3px;
  height: 1px;
  background: currentColor;
  opacity: 0.22;
  box-shadow:
    0 5px 0 currentColor,
    0 10px 0 currentColor,
    0 15px 0 currentColor,
    0 20px 0 currentColor;
  pointer-events: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-right a {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
}

.header-right a:hover { color: #ffffff; }

#theme-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  line-height: 1;
}

#theme-toggle:hover {
  border-color: rgba(255, 255, 255, 0.7);
  color: #ffffff;
}

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* === LAYOUT === */
.site-body {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* === SIDEBAR === */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 1.5rem;
  padding: 0 1.25rem;
}

.sidebar-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

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

.sidebar-nav li a {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 1px;
}

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

.sidebar-nav li a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* === COLLAPSIBLE SIDEBAR GROUP === */
.sidebar-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  padding: 0 0.6rem;
}

.sidebar-expand {
  display: block;
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--accent);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  margin-top: 0.25rem;
}

.sidebar-expand:hover {
  text-decoration: underline;
}

.sidebar-collapsible-list {
  display: none;
}

.sidebar-collapsible.is-expanded .sidebar-summary {
  display: none;
}

.sidebar-collapsible.is-expanded .sidebar-expand {
  display: none;
}

.sidebar-collapsible.is-expanded .sidebar-collapsible-list {
  display: block;
}

/* === MAIN CONTENT === */
main {
  flex: 1;
  min-width: 0;
  padding: 3rem 4rem;
  max-width: 820px;
}

/* === EYEBROW === */
.page-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* === TYPOGRAPHY === */
h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  border: none;
  padding: 0;
}

/* Indigo accent rule after h1 */
main > h1::after,
.page-eyebrow + h1::after {
  content: '';
  display: block;
  width: 2.5rem;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

/* No accent rule on landing page h1 */
.landing-hero h1::after { display: none; }

h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.75rem 0 0.5rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.4rem;
}

p { margin: 0.75rem 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === CODE === */
code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--text);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.875rem;
}

th {
  background: var(--bg-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.6rem 0.875rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
}

td {
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

tr:hover td { background: var(--bg-secondary); }

/* === LISTS === */
ul, ol { padding-left: 1.5rem; margin: 0.75rem 0; }
li { margin: 0.3rem 0; }

/* === MERMAID === */
.mermaid-wrap {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.mermaid-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.875rem;
}

.mermaid-body {
  padding: 1.5rem;
  background: var(--bg);
  text-align: center;
}

.mermaid-body svg { max-width: 100%; height: auto; }

/* Standalone SVGs (backward compat) */
svg { max-width: 100%; height: auto; margin: 1rem 0; }

/* === VIEW AS MARKDOWN === */
.view-markdown {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === FOOTER === */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* === LANDING PAGE === */
.landing-hero {
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.landing-hero h1 {
  font-size: 2.75rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
  max-width: 520px;
  margin-bottom: 1rem;
}

.landing-tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.landing-cta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover { opacity: 0.9; text-decoration: none; }

.btn-secondary {
  color: var(--text-secondary);
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  display: inline-block;
}

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

.landing-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.spec-list { list-style: none; padding: 0; }

.spec-list li {
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 0;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.spec-list li:first-child { border-top: 1px solid var(--border); }

.spec-list li a {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  min-width: 160px;
}

.spec-list li a:hover { color: var(--accent); }

.spec-list li span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* === LANDING PROSE === */
.landing-prose {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 580px;
  margin-bottom: 1.25rem;
}

/* === BLOG === */
.blog-post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.blog-post-meta time {
  font-variant-numeric: tabular-nums;
}

.blog-post-list {
  list-style: none;
  padding: 0;
}

.blog-post-list li {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.blog-post-list li:first-child {
  border-top: 1px solid var(--border);
}

.blog-post-list li a {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

.blog-post-list li a:hover {
  color: var(--accent);
}

.blog-post-list li .blog-entry-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.blog-post-list li .blog-entry-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .site-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
  }
  main { padding: 1.5rem 1rem; }
  h1 { font-size: 1.75rem; }
  .landing-hero h1 { font-size: 2rem; }
  .site-header { padding: 0 1rem; }
  .spec-list li { flex-direction: column; gap: 0.25rem; }
  .spec-list li a { min-width: auto; }
}
