/* ==========================================================================
   Anapistan Ghost Theme — Main Stylesheet
   Dark by default · Indigo accent · Docs-first layout
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;1,6..72,300;1,6..72,400&family=Geist:wght@300;400;500;600&display=swap');

/* --------------------------------------------------------------------------
   2. Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette */
  --bg-base:        #0d0e11;
  --bg-surface:     #13151a;
  --bg-elevated:    #1a1d24;
  --bg-hover:       #1f2330;
  --border:         #252932;
  --border-subtle:  #1c1f27;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b90a0;
  --text-muted:     #555a6a;
  --text-inverse:   #0d0e11;

  --accent:         #6366f1;   /* indigo-500 */
  --accent-bright:  #818cf8;   /* indigo-400 */
  --accent-dim:     #3730a3;   /* indigo-800 */
  --accent-glow:    rgba(99, 102, 241, 0.15);

  --green:          #34d399;
  --amber:          #fbbf24;
  --red:            #f87171;

  /* Ghost font setting overrides — required by theme validator */
  --gh-font-heading: 'Geist', 'Inter', system-ui, sans-serif;
  --gh-font-body:    'Geist', 'Inter', system-ui, sans-serif;

  /* Typography */
  --font-sans:  'Geist', 'Inter', system-ui, sans-serif;
  --font-serif: 'Newsreader', 'Georgia', serif;
  --font-mono:  'IBM Plex Mono', 'Fira Code', monospace;

  /* Spacing */
  --sidebar-width: 260px;
  --content-max:   720px;
  --toc-width:     220px;
  --gap:           1.5rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition: 150ms ease;
}

/* --------------------------------------------------------------------------
   3. Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-bright);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--text-primary); }

img, video { max-width: 100%; height: auto; display: block; }

/* --------------------------------------------------------------------------
   4. Layout — Sidebar + Content
   -------------------------------------------------------------------------- */
.site-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.site-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  margin-bottom: 0.5rem;
}

.sidebar-logo img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.sidebar-logo-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 0.25rem;
}

.sidebar-search {
  margin-top: 0.875rem;
}

.sidebar-search .gh-search-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  padding: 0.4375rem 0.75rem 0.4375rem 2rem;
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search .gh-search-input:focus {
  border-color: var(--accent);
}
.sidebar-search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search-wrap {
  position: relative;
}

/* --- Nav sections --- */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 1.25rem;
  margin-bottom: 0.375rem;
}

.nav-section ul {
  list-style: none;
}

.nav-section ul li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}

.nav-section ul li a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-left-color: var(--border);
}

.nav-section ul li a.active,
.nav-section ul li.nav-current a {
  color: var(--accent-bright);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

/* Top-level primary nav */
.primary-nav {
  padding: 0.5rem 0 1rem;
}
.primary-nav ul { list-style: none; }
.primary-nav ul li a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: all var(--transition);
}
.primary-nav ul li a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-left-color: var(--border);
}
.primary-nav ul li.nav-current a {
  color: var(--accent-bright);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Main content area --- */
.site-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   5. Page Header (top bar)
   -------------------------------------------------------------------------- */
.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 14, 17, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  overflow: hidden;
}
.page-header-breadcrumb span { color: var(--text-muted); }
.page-header-breadcrumb a {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-breadcrumb a:hover { color: var(--text-primary); }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Mobile menu toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
}

/* --------------------------------------------------------------------------
   6. Content Layout — Article + TOC
   -------------------------------------------------------------------------- */
.content-layout {
  display: grid;
  grid-template-columns: 1fr var(--toc-width);
  gap: 3rem;
  max-width: calc(var(--content-max) + var(--toc-width) + 3rem);
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
  align-items: start;
}

.content-layout.no-toc {
  grid-template-columns: 1fr;
  max-width: var(--content-max);
}

/* --------------------------------------------------------------------------
   7. Article Typography
   -------------------------------------------------------------------------- */
.gh-content {
  min-width: 0;
}

.post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.post-meta-tag {
  background: var(--accent-glow);
  color: var(--accent-bright);
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-family: var(--font-mono);
}

.post-meta-sep { color: var(--border); }

.gh-content > * + * { margin-top: 1.5em; }

.gh-content h1,
.gh-content h2,
.gh-content h3,
.gh-content h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  scroll-margin-top: 72px;
}

.gh-content h2 { font-size: 1.375rem; letter-spacing: -0.01em; }
.gh-content h3 { font-size: 1.125rem; }
.gh-content h4 { font-size: 1rem; color: var(--text-secondary); }

/* Numbered section headings via CSS counters */
.gh-content.numbered-headings { counter-reset: h2counter; }
.gh-content.numbered-headings h2::before {
  counter-increment: h2counter;
  counter-reset: h3counter;
  content: counter(h2counter) ". ";
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 0.875em;
}
.gh-content.numbered-headings h3::before {
  counter-increment: h3counter;
  counter-reset: h4counter;
  content: counter(h2counter) "." counter(h3counter) " ";
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.gh-content p {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-primary);
}

/* Narrative/prose sections — slightly more generous leading */
.post-template .gh-content > p:first-of-type {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.gh-content strong { font-weight: 600; color: var(--text-primary); }
.gh-content em { font-style: italic; }

.gh-content a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-decoration-color: rgba(129, 140, 248, 0.35);
  text-underline-offset: 2px;
  transition: all var(--transition);
}
.gh-content a:hover {
  text-decoration-color: var(--accent-bright);
  color: white;
}

/* Lists */
.gh-content ul,
.gh-content ol {
  padding-left: 1.5rem;
}
.gh-content ul { list-style: none; }
.gh-content ul li::before {
  content: "–";
  color: var(--text-muted);
  margin-left: -1.25rem;
  margin-right: 0.5rem;
}
.gh-content ol { list-style: decimal; }
.gh-content li { margin-bottom: 0.375rem; line-height: 1.7; }

/* Blockquote */
.gh-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-style: italic;
}
.gh-content blockquote p { color: inherit; font-size: inherit; }
.gh-content blockquote cite {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  font-style: normal;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Horizontal rule */
.gh-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* Tables */
.gh-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}
.gh-content th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.gh-content td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.gh-content tr:last-child td { border-bottom: none; }
.gh-content tr:hover td { background: var(--bg-surface); }

/* Images */
.gh-content figure { margin: 2rem 0; }
.gh-content figure img {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.gh-content figcaption {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.625rem;
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   8. Code Blocks
   -------------------------------------------------------------------------- */
.gh-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-elevated);
  color: var(--accent-bright);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.gh-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  padding: 1.25rem;
  position: relative;
  margin: 1.5rem 0;
}

.gh-content pre code {
  background: none;
  color: var(--text-primary);
  padding: 0;
  border: none;
  font-size: 0.875rem;
  line-height: 1.7;
}

/* Code block header with language label */
.code-block-wrap {
  position: relative;
}

.code-lang-label {
  position: absolute;
  top: 0.625rem;
  right: 0.75rem;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}

.copy-code-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.copy-code-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}
.copy-code-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

/* --------------------------------------------------------------------------
   9. Table of Contents (right rail)
   -------------------------------------------------------------------------- */
.toc-aside {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.toc-list {
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc-list li a {
  display: block;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: all var(--transition);
  line-height: 1.4;
}

.toc-list li a:hover {
  color: var(--text-secondary);
  border-left-color: var(--border);
}

.toc-list li a.active {
  color: var(--accent-bright);
  border-left-color: var(--accent);
}

.toc-list li.toc-h3 a { padding-left: 1.5rem; font-size: 0.75rem; }

/* --------------------------------------------------------------------------
   10. Post Navigation (prev / next)
   -------------------------------------------------------------------------- */
.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
}

.post-nav-link:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.post-nav-link.next { text-align: right; }

.post-nav-direction {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.post-nav-link.next .post-nav-direction { justify-content: flex-end; }

.post-nav-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.post-nav-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   11. Index / Home Page
   -------------------------------------------------------------------------- */
.home-hero {
  padding: 4rem 2rem 3rem;
  max-width: var(--content-max);
  margin: 0 auto;
  border-bottom: 1px solid var(--border-subtle);
}

.home-hero-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.home-hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.home-hero-desc {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.7;
}

.home-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 0.625rem 1.25rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
}
.home-cta:hover {
  background: var(--accent-bright);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

/* Post cards grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 2.5rem 2rem;
  max-width: calc(var(--content-max) + var(--toc-width) + 3rem);
  margin: 0 auto;
}

.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  text-decoration: none;
  color: inherit;
}

.post-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.post-card-tag {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-bright);
}

.post-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.post-card-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   12. Chapter Intro Template
   -------------------------------------------------------------------------- */
.chapter-hero {
  padding: 5rem 2rem 4rem;
  max-width: var(--content-max);
  margin: 0 auto;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.chapter-hero::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -80px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.chapter-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-bright);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.chapter-intro {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 2.5rem;
}

.chapter-start-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-bright);
  font-weight: 500;
  font-size: 0.9375rem;
  border-bottom: 1px solid rgba(129, 140, 248, 0.35);
  padding-bottom: 1px;
  transition: all var(--transition);
}
.chapter-start-link:hover {
  color: white;
  border-bottom-color: white;
  gap: 0.75rem;
}

/* Posts in chapter */
.chapter-posts {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2rem 2rem 6rem;
}

.chapter-posts-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.chapter-post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chapter-post-item {
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-post-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0;
  text-decoration: none;
  color: var(--text-secondary);
  gap: 1rem;
  transition: all var(--transition);
}

.chapter-post-item a:hover {
  color: var(--text-primary);
  padding-left: 0.5rem;
}

.chapter-post-item a:hover .chapter-post-arrow {
  color: var(--accent-bright);
  transform: translateX(3px);
}

.chapter-post-title-wrap { flex: 1; min-width: 0; }
.chapter-post-item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-post-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.chapter-post-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}

/* --------------------------------------------------------------------------
   13. Tag / Section Index Page
   -------------------------------------------------------------------------- */
.tag-hero {
  padding: 3rem 2rem 2rem;
  max-width: var(--content-max);
  margin: 0 auto;
  border-bottom: 1px solid var(--border-subtle);
}

.tag-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.tag-hero-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.tag-hero-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.65;
}

/* --------------------------------------------------------------------------
   14. Callout / Aside Cards (Ghost bookmark / callout cards)
   -------------------------------------------------------------------------- */
.kg-callout-card {
  display: flex;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  margin: 1.5rem 0;
}

.kg-callout-card-blue  { border-left: 3px solid #60a5fa; }
.kg-callout-card-green { border-left: 3px solid var(--green); }
.kg-callout-card-yellow{ border-left: 3px solid var(--amber); }
.kg-callout-card-red   { border-left: 3px solid var(--red); }
.kg-callout-card-grey  { border-left: 3px solid var(--text-muted); }

.kg-callout-emoji { font-size: 1.125rem; flex-shrink: 0; line-height: 1.5; }
.kg-callout-text  { font-size: 0.9375rem; line-height: 1.65; color: var(--text-secondary); }
.kg-callout-text p { color: inherit; font-size: inherit; }

/* Bookmark card */
.kg-bookmark-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  background: var(--bg-surface);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition);
  margin: 1.5rem 0;
}
.kg-bookmark-card:hover { border-color: var(--accent); }
.kg-bookmark-content { padding: 1rem 1.25rem; flex: 1; min-width: 0; }
.kg-bookmark-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.kg-bookmark-description { font-size: 0.8125rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kg-bookmark-metadata { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.kg-bookmark-icon { width: 16px; height: 16px; }
.kg-bookmark-thumbnail { width: 120px; flex-shrink: 0; }
.kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

/* --------------------------------------------------------------------------
   15. Membership / Subscribe
   -------------------------------------------------------------------------- */
.subscribe-form-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  margin: 3rem 0;
}
.subscribe-form-wrap h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.subscribe-form-wrap p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}
.subscribe-form {
  display: flex;
  gap: 0.625rem;
  max-width: 400px;
  margin: 0 auto;
}
.subscribe-form input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.5625rem 0.875rem;
  outline: none;
  transition: border-color var(--transition);
  font-family: var(--font-sans);
}
.subscribe-form input:focus { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5625rem 1.125rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-bright); }

/* --------------------------------------------------------------------------
   16. Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--text-primary); }
.pagination .current { background: var(--accent); color: white; border-color: var(--accent); }

/* --------------------------------------------------------------------------
   17. Error pages
   -------------------------------------------------------------------------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}
.error-code {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 600;
  color: var(--border);
  line-height: 1;
  margin-bottom: 1rem;
}
.error-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.error-desc  { color: var(--text-secondary); margin-bottom: 2rem; }

/* --------------------------------------------------------------------------
   18. Utilities
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   19. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .toc-aside { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }

  .site-sidebar {
    transform: translateX(-260px);
    width: 260px;
    transition: transform 200ms ease;
    box-shadow: none;
  }

  .site-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .site-main { margin-left: 0; }

  .content-layout { padding: 2rem 1.25rem 4rem; }
  .home-hero, .chapter-hero { padding: 2.5rem 1.25rem 2rem; }
  .post-grid { padding: 1.5rem 1.25rem; grid-template-columns: 1fr; }
  .chapter-posts { padding: 1.5rem 1.25rem 4rem; }
}

@media (max-width: 600px) {
  .post-navigation { grid-template-columns: 1fr; }
  .post-meta { gap: 0.5rem; }
  .subscribe-form { flex-direction: column; }
}

/* --------------------------------------------------------------------------
   20. Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --------------------------------------------------------------------------
   21. Selection & Focus
   -------------------------------------------------------------------------- */
::selection { background: rgba(99, 102, 241, 0.25); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --------------------------------------------------------------------------
   22. Ghost Card Width Classes (required by Ghost theme validator)
   -------------------------------------------------------------------------- */

/* Wide cards — break out of content column */
.kg-width-wide {
  position: relative;
  width: 85vw;
  min-width: 100%;
  margin: 1.5rem calc(50% - 42.5vw);
}

/* Full-width cards — edge to edge */
.kg-width-full {
  position: relative;
  width: 100vw;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

/* Constrain within main content area when sidebar is present */
@media (min-width: 900px) {
  .kg-width-wide {
    width: min(85vw, calc(var(--content-max) + 12rem));
    margin-left: calc(50% - min(42.5vw, calc((var(--content-max) + 12rem) / 2)));
    margin-right: calc(50% - min(42.5vw, calc((var(--content-max) + 12rem) / 2)));
  }
}

.kg-width-wide img,
.kg-width-full img {
  width: 100%;
  border-radius: var(--radius-md);
}

/* Gallery card */
.kg-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.kg-gallery-row {
  display: flex;
  gap: 0.5rem;
}
.kg-gallery-image { flex: 1; }
.kg-gallery-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* Video card */
.kg-video-card { margin: 1.5rem 0; }
.kg-video-card video { width: 100%; border-radius: var(--radius-md); }

/* Audio card */
.kg-audio-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
}
.kg-audio-card audio { flex: 1; }

/* Button card */
.kg-button-card { margin: 1.5rem 0; text-align: center; }
.kg-button-card a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition);
  text-decoration: none;
}
.kg-button-card a:hover { background: var(--accent-bright); color: white; }

/* Toggle / accordion card */
.kg-toggle-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 1.5rem 0;
}
.kg-toggle-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  background: var(--bg-surface);
  cursor: pointer;
  font-weight: 500;
}
.kg-toggle-card-content {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
