/* =====================================================
   SAITEJA'S DEV BLOG — Clean Light Design
   Simple, readable, minimal. Good typography first.
   ===================================================== */

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

:root {
  /* Colors — warm off-white palette */
  --bg:            #fafaf8;
  --bg-subtle:     #f4f3f0;
  --bg-code:       #f0efe9;
  --surface:       #ffffff;

  --border:        #e5e3de;
  --border-light:  #efede8;

  --text:          #1a1916;
  --text-secondary:#6b6860;
  --text-muted:    #9e9b95;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;

  --tag-bg:        #eff6ff;
  --tag-text:      #2563eb;
  --tag-border:    #dbeafe;

  --cat-bg:        #f0fdf4;
  --cat-text:      #15803d;
  --cat-border:    #bbf7d0;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Layout */
  --max-width:     1344px;
  --content-width: 800px;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;

  /* Misc */
  --radius:     4px;
  --radius-md:  6px;
  --radius-lg:  10px;
    --transition: 0.15s ease;
    /* Height of .site-header. The sidebar sticks this far down, and heading
       anchors scroll to here, so keep the three in step. */
    --header-height: 76px;
  }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--selection); color: var(--text); }

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

img { max-width: 100%; display: block; }

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* =====================================================
   HEADER / NAVIGATION
   ===================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

/* Logo */
.site-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Navigation */
.site-nav { display: flex; align-items: center; }

.nav-list {
  display: flex;
  list-style: none;
  gap: var(--space-xs);
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav-link.active { color: var(--accent); }

/* Mobile hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: var(--space-sm);
  background: none;
  border: none;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
}

html, body {
  /* `clip` rather than `hidden`: `overflow-x: hidden` makes this element a
     scroll container, which silently disables `position: sticky` for
     everything inside it -- the sidebar and the site header both stopped
     sticking. `clip` does the same job without creating a scrollport.
     Browsers without `clip` fall back to the `hidden` line above it. */
  overflow-x: hidden;
  overflow-x: clip;
  width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 200;
  }
  .site-nav.open { display: flex !important; }
  .nav-list { flex-direction: column; width: 100%; gap: 4px; }
  .nav-link { display: block; width: 100%; padding: 0.6rem 0.8rem; font-size: 0.95rem; }
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content { flex: 1; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* =====================================================
   HOMEPAGE — INTRO
   ===================================================== */
.dev-intro {
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
  max-width: var(--max-width);
  margin: 0 auto;
  border-bottom: 1px solid var(--border-light);
}

.intro-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.intro-eyebrow::before {
  content: '';
  width: 5px;
  height: 5px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.intro-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.intro-title .accent { color: var(--accent); }

.intro-text {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 540px;
  line-height: 1.75;
  margin-bottom: var(--space-xl);
}

.intro-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: #c8c5be;
  color: var(--text);
}

/* Tech Stack Pills */
.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: var(--space-xl);
}

.tech-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* =====================================================
   HOME LAYOUT (articles + sidebar)
   ===================================================== */
.home-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

@media (min-width: 900px) {
  .home-layout {
    grid-template-columns: 1fr 220px;
    align-items: start;
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.section-link {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
}
.section-link:hover { color: var(--accent-hover); }

/* Home Sidebar */
.home-sidebar .sidebar-widget { margin-bottom: var(--space-lg); }

.sidebar-widget h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-light);
}

.sidebar-cats { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: var(--space-sm); }

/* =====================================================
   BLOG CARDS — Grid Card Style
   ===================================================== */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

@media (min-width: 640px) {
  .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.filterable-post {
  display: flex;
  height: 100%;
}

.blog-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.blog-card:hover {
  background: var(--surface);
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.blog-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.meta-divider { color: var(--border); font-size: 0.8rem; }

.blog-card-read-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.blog-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.blog-card-title a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-title a:hover { color: var(--accent); }

.blog-card-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-taxonomies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: var(--space-xs);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.category-badge {
  background: var(--cat-bg);
  color: var(--cat-text);
  border: 1px solid var(--cat-border);
}

.tag-badge {
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
}

/* =====================================================
   BLOG LIST PAGE
   ===================================================== */
.blog-hero {
  border-bottom: 1px solid var(--border);
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
}

.blog-hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.blog-hero h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.blog-hero p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 460px;
  line-height: 1.65;
}

/* Controls */
.blog-controls {
  max-width: var(--max-width);
  margin: var(--space-lg) auto var(--space-md);
  padding: 0 var(--space-lg);
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.search-box-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
}

#search-input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #dbeafe;
}

/* Filter Tabs */
.filter-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.filter-tab {
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.filter-tab:hover {
  background: var(--bg-subtle);
  border-color: #c8c5be;
  color: var(--text);
}

.filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Blog List Container */
.blog-list-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-2xl);
}

#posts-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  font-weight: 500;
}

.no-results {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
}

/* =====================================================
   POST / ARTICLE PAGE
   ===================================================== */
.post-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  width: 100%;
  box-sizing: border-box;
}

.post-main {
  grid-column: 1;
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1023px) {
  .post-sidebar {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
}

@media (min-width: 1024px) {
  .post-container {
    grid-template-columns: 2fr 4.8fr 2fr;
    gap: var(--space-xl);
    padding: var(--space-xl) var(--space-lg);
  }
  .post-main {
    grid-column: 2;
  }
  .post-sidebar {
    grid-column: 1;
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    width: auto !important;
    align-self: stretch !important;
    height: auto !important;
    min-height: 100%;
  }
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: var(--space-lg);
  transition: color var(--transition);
}

.back-link:hover { color: var(--text); }

/* Post Header */
.post-header { margin-bottom: var(--space-xl); }

.post-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.post-meta-row span { display: flex; align-items: center; gap: 0.3rem; }

.post-title {
  font-size: clamp(1.35rem, 2.5vw, 1.95rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.post-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
  border-left: 3px solid var(--border);
  padding-left: var(--space-md);
}

.post-taxonomies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: var(--space-md);
}

/* Post Divider */
.post-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--space-lg) 0;
}

/* =====================================================
   PROSE (Article Body)
   ===================================================== */
.prose {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
  max-width: var(--content-width);
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: var(--space-xl) 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.prose h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: var(--space-lg) 0 var(--space-sm);
}

.prose h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: var(--space-md) 0 var(--space-xs);
}

.prose p { margin-bottom: var(--space-md); }

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

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

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

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: #bfdbfe;
}
.prose a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent);
}

/* Blockquotes */
.prose blockquote {
  border-left: 3px solid var(--border);
  padding: var(--space-sm) var(--space-lg);
  margin: var(--space-lg) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.prose blockquote p { margin-bottom: 0; }

/* Inline code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  color: #b45309;
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
}

/* Code blocks */
.prose .highlight, .highlight {
  background: #181825;
  border: 1px solid #313244;
  border-radius: var(--radius-md);
  margin: var(--space-lg) 0;
  overflow-x: auto;
}

.prose .highlight pre, .prose pre {
  background: #181825;
  border: 1px solid #313244;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  overflow-x: auto;
  line-height: 1.65;
  color: #cdd6f4;
}

.prose .highlight pre {
  margin: 0;
  border: none;
  background: transparent;
}

.prose pre code, .highlight code {
  background: none;
  border: none;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  padding: 0;
  border-radius: 0;
}

/* Syntax Highlighting Tokens (One Dark Pro) */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kc, .highlight .kp, .highlight .ow {
  color: #c678dd !important;
  font-weight: 600;
}
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, 
.highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr {
  color: #98c379 !important;
}
.highlight .nf, .highlight .nd, .highlight .ne {
  color: #61afef !important;
  font-weight: 500;
}
.highlight .nc, .highlight .nn, .highlight .kt, .highlight .no {
  color: #e5c07b !important;
  font-weight: 600;
}
.highlight .nb, .highlight .bp {
  color: #56b6c2 !important;
}
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il {
  color: #d19a66 !important;
}
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .na, .highlight .nt, .highlight .nx {
  color: #e06c75 !important;
}
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cp, .highlight .cs {
  color: #7f848e !important;
  font-style: italic;
}
.highlight .o, .highlight .p, .highlight .x, .highlight .g {
  color: #abb2bf !important;
}

/* Highlight.js / codehilite overrides */
.codehilite {
  background: #181825;
  border: 1px solid #313244;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
  margin: var(--space-lg) 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.codehilite pre { background: none; border: none; padding: 0; margin: 0; color: #cdd6f4; }

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

.prose th, .prose td {
  padding: 0.55rem var(--space-md);
  border: 1px solid var(--border);
  text-align: left;
}

.prose th {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

.prose td { color: var(--text-secondary); }

/* Horizontal rule */
.prose hr { border: none; border-top: 1px solid var(--border-light); margin: var(--space-xl) 0; }

/* Post images */
.prose img {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  margin: var(--space-lg) auto;
}

/* =====================================================
   POST SIDEBAR (TOC)
   ===================================================== */
.post-sidebar { display: none; }

@media (min-width: 1024px) { .post-sidebar { display: block; } }

/* Left rail. Sticks below the site header for the whole length of the article
   and scrolls internally once the list outgrows the viewport, so a long post
   never pushes the contents out of reach. */
.toc-widget {
  position: sticky;
  top: var(--header-height, 76px);
  max-height: calc(100vh - var(--header-height, 76px) - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-widget::-webkit-scrollbar {
  width: 4px;
}

.toc-widget::-webkit-scrollbar-track {
  background: transparent;
}

.toc-widget::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.toc-widget::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.toc-widget h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.toc-widget ul { list-style: none; padding: 0; }

.toc-widget li { margin-bottom: 0.25rem; }

.toc-widget a {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: block;
  padding: 0.2rem 0.5rem;
  border-left: 2px solid var(--border-light);
  transition: all var(--transition);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.toc-widget a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--tag-bg);
}

.toc-widget a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* =====================================================
   RESPONSIVE & TOUCH OPTIMIZATIONS FOR CODE, DIAGRAMS & TABLES
   ===================================================== */
.post-container, .post-main, .prose {
  min-width: 0 !important;
  max-width: 100% !important;
}

.prose .highlight, .highlight, .codehilite {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  background: #181825;
  border: 1px solid #313244;
  border-radius: var(--radius-md);
  margin: var(--space-lg) 0;
  box-sizing: border-box;
}

.prose .highlight pre, .prose pre, .codehilite pre {
  margin: 0 !important;
  padding: var(--space-lg);
  background: transparent !important;
  border: none !important;
  overflow-x: visible !important;
  line-height: 1.65;
  color: #cdd6f4;
  display: block;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
  tab-size: 2;
  -moz-tab-size: 2;
}

.mermaid {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background: var(--bg-subtle, #f4f3f0);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-sizing: border-box;
}

.mermaid svg {
  min-width: 550px;
  max-width: none !important;
  height: auto !important;
}

.prose table {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.prose code {
  word-break: break-word;
}

.prose pre code {
  word-break: normal;
  white-space: pre;
}

@media (max-width: 768px) {
  .post-container {
    padding: var(--space-md) var(--space-sm);
  }
  
  .prose {
    font-size: 0.95rem;
    line-height: 1.7;
  }
  
  .prose pre, .prose .highlight pre, .codehilite pre {
    padding: 0.85rem;
    font-size: 0.8rem;
  }
  
  .prose pre code, .highlight code {
    font-size: 0.8rem;
  }
  
  .post-title {
    font-size: 1.6rem;
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-lg);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.footer-brand .logo-text { font-size: 0.9rem; }

.footer-tagline {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  align-items: center;
}

.footer-link {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.footer-link:hover { color: var(--text); }

.footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 100%;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-sm);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary   { color: var(--text); }
.font-mono      { font-family: var(--font-mono); }

/* Animations */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-fade { animation: fade-in-up 0.4s ease both; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }

/* =============================================================================
   COMPONENTS ADDED BY _data/blog_style.yml
   -----------------------------------------------------------------------------
   Every value below resolves to a token emitted by _includes/tokens.html.
   Change the colour or metric in _data/blog_style.yml, not here.
   ========================================================================== */

/* ---- Reading progress bar (post pages only) ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--progress-height, 2px);
  z-index: 300;
  pointer-events: none;
}

.reading-progress__bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.08s linear;
}

/* ---- Cover tile ----
   No image files are committed. The tile is a deterministic 16:9 gradient
   built from the post's primary category accent plus one of six geometric
   patterns chosen from the post slug. Same post, same cover, forever. */
.cover-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(135deg, var(--cover-accent, var(--accent)) 0%, #1a1916 100%);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.cover-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  pointer-events: none;
}

.cover-tile[data-variant="0"]::after {
  background-image: repeating-linear-gradient(45deg, #fff 0 2px, transparent 2px 12px);
}
.cover-tile[data-variant="1"]::after {
  background-image: repeating-radial-gradient(circle at 30% 40%, #fff 0 1.5px, transparent 1.5px 16px);
}
.cover-tile[data-variant="2"]::after {
  background-image: radial-gradient(#fff 1.5px, transparent 1.5px);
  background-size: 18px 18px;
}
.cover-tile[data-variant="3"]::after {
  background-image:
    radial-gradient(circle at 78% 28%, #fff 0 22%, transparent 22%),
    radial-gradient(circle at 20% 76%, #fff 0 13%, transparent 13%);
}
.cover-tile[data-variant="4"]::after {
  background-image:
    linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size: 7% 34%, 13% 62%, 9% 46%;
  background-position: 14% 66%, 48% 38%, 79% 54%;
  background-repeat: no-repeat;
}
.cover-tile[data-variant="5"]::after {
  opacity: 0.1;
  background-image:
    linear-gradient(45deg, #fff 25%, transparent 25% 75%, #fff 75%),
    linear-gradient(45deg, #fff 25%, transparent 25% 75%, #fff 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}

/* On a card the tile sits flush at the top of the card. */
.blog-card .cover-tile {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-sm);
  width: calc(100% + 2 * var(--space-lg));
}

.blog-card.has-cover {
  padding: 0 0 var(--space-lg);
  overflow: hidden;
}
.blog-card.has-cover .blog-card-meta,
.blog-card.has-cover .blog-card-title,
.blog-card.has-cover .blog-card-description,
.blog-card.has-cover .blog-card-taxonomies {
  margin-left: var(--space-lg);
  margin-right: var(--space-lg);
}

/* ---- Code box ----
   Frames the existing dark code surface with a header bar carrying the
   language on the left and a copy button on the right. The horizontal
   scroll that main.css gave the bare <pre> now happens on .code-box-body. */
.code-box {
  margin: var(--space-lg) 0;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  overflow: hidden;
}

.code-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: 2.15rem;
  padding: 0.35rem 0.4rem 0.35rem 0.85rem;
  background: var(--code-head-bg);
  border-bottom: 1px solid var(--code-border);
  box-sizing: border-box;
}

.code-box-lang {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7f8ca3;
  user-select: none;
  -webkit-user-select: none;
}

.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #7f8ca3;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.copy-code-btn:hover {
  color: #cdd6f4;
  border-color: var(--code-border);
}

.copy-code-btn.copied {
  color: #98c379;
  border-color: rgba(152, 195, 121, 0.4);
}

.code-box-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-box-body > .highlight,
.code-box-body > .codehilite,
.code-box-body > pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

/* ---- Callouts (GitHub Alerts syntax) ---- */
.callout {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--callout-border);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  background: var(--callout-bg);
  color: var(--callout-text);
  font-style: normal;
}

.callout::before {
  content: attr(data-callout);
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--callout-border);
}

.callout p { margin-bottom: var(--space-sm); }
.callout p:last-child { margin-bottom: 0; }
.callout code {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--callout-border);
  color: var(--callout-text);
}

.callout[data-callout="note"] {
  --callout-border: var(--callout-note-border);
  --callout-bg: var(--callout-note-bg);
  --callout-text: var(--callout-note-text);
}
.callout[data-callout="tip"] {
  --callout-border: var(--callout-tip-border);
  --callout-bg: var(--callout-tip-bg);
  --callout-text: var(--callout-tip-text);
}
.callout[data-callout="warning"] {
  --callout-border: var(--callout-warning-border);
  --callout-bg: var(--callout-warning-bg);
  --callout-text: var(--callout-warning-text);
}
.callout[data-callout="important"] {
  --callout-border: var(--callout-important-border);
  --callout-bg: var(--callout-important-bg);
  --callout-text: var(--callout-important-text);
}
.callout[data-callout="caution"] {
  --callout-border: var(--callout-caution-border);
  --callout-bg: var(--callout-caution-bg);
  --callout-text: var(--callout-caution-text);
}

/* A plain blockquote with no alert marker keeps the neutral legacy look. */
.prose blockquote:not(.callout) {
  font-style: italic;
}

/* ---- Share buttons ---- */
.share {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-subtle);
}

/* ---- Post hero cover ---- */
.post-hero {
  margin-bottom: var(--space-lg);
}

/* Taxonomies now sit above the title, so they need space below, not above. */
.post-header .post-taxonomies { margin-top: 0; margin-bottom: var(--space-md); }
.post-meta-share { margin-left: auto; }

@media (max-width: 640px) {
  .post-meta-share { margin-left: 0; }
}

/* Anchor targets must clear the sticky site header. */
.prose h2, .prose h3, .prose h4 { scroll-margin-top: calc(var(--header-height, 76px) + 14px); }

/* ---- Table of contents on narrow screens ----
   The left rail is display:none below 1024px, so the same list is offered as
   a disclosure above the article instead of being dropped entirely. */
.toc-mobile {
  display: none;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-sm) var(--space-md);
}

.toc-mobile summary {
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  list-style: none;
}

.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::before { content: "\25B8\00a0"; }
.toc-mobile[open] summary::before { content: "\25BE\00a0"; }

.toc-mobile ul {
  list-style: none;
  padding: var(--space-sm) 0 0;
  margin: 0;
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-sm);
}

.toc-mobile li { margin: 0.2rem 0; }
.toc-mobile a {
  display: block;
  padding: 0.2rem 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.toc-mobile a:hover { color: var(--accent); }
.toc-mobile .toc-h3 a { padding-left: 0.85rem; font-size: 0.76rem; }

.toc-widget .toc-h3 a { padding-left: 0.75rem; font-size: 0.78rem; }

@media (max-width: 1023px) {
  .toc-mobile { display: block; }
  .toc-mobile:empty { display: none; }
}

/* ---- Author card ---- */
.author-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding: var(--space-lg);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.author-avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.author-meta { min-width: 0; }

.author-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.author-role {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 0.15rem;
}

.author-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.author-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.author-link:hover { color: var(--accent); }

/* ---- Previous / Next ---- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-light);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition);
}

.post-nav-link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.post-nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.post-nav-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.post-nav-spacer { visibility: hidden; }

/* ---- Series note (only when front matter sets `series`) ---- */
.series-note {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.series-note p { margin-bottom: 0; }
.series-note a { color: var(--accent); }

/* ---- Related posts (matched on shared categories) ----
   Rendered by _layouts/post.html. The heading is an h2 that lives outside
   .prose, so it needs the same scale as .post-title's siblings rather than the
   in-prose heading ladder. */
.related-posts {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--space-md);
}

.related-posts__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.related-posts__item a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition);
}

.related-posts__item a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Figures inside the prose ---- */
.prose figure { margin: var(--space-lg) 0; }

.prose figure img,
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.prose figcaption {
  margin-top: var(--space-sm);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Badge restyle ----
   Categories stay accent-tinted because they are the navigational taxonomy;
   tags drop to a neutral chip. This removes the old green/blue split. */
.category-badge {
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
}

.tag-badge {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  font-weight: 500;
}

@media (max-width: 640px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link--next { text-align: left; align-items: flex-start; }
  .author-card { flex-direction: column; }
}

