/* Self-hosted, latin-subset variable fonts (no third-party origins; keeps CSP
   first-party only). One file per family covers weights 400-700. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/inter-var.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/source-serif-4-var.woff2") format("woff2");
}

/* Design System & Variables */
:root {
  color-scheme: dark;

  /* Surfaces — unified near-black base */
  --bg: #0a0b10;
  --bg-elevated: #12141d;
  --surface: #161922;
  --surface-2: #1d212d;
  --bg-offset: rgba(22, 25, 34, 0.6);
  --card-bg: rgba(22, 25, 34, 0.72);
  --button-hover: rgba(255, 255, 255, 0.05);
  --code-bg: #101826;
  --code-label-bg: #202b3d;

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-hover: rgba(110, 168, 255, 0.4);
  --code-border: rgba(255, 255, 255, 0.13);

  /* Text */
  --text-primary: #f3f5fa;
  --text-secondary: #c3c9d6;
  --text-muted: #7b8394;
  --code-text: #e6edf6;
  --code-label-text: #c7d1df;

  /* Accents — cool primary + warm signature (the two-tone identity) */
  --accent: #6ea8ff;
  --accent-strong: #3b82f6;
  --accent-soft: rgba(110, 168, 255, 0.12);
  --accent-muted: rgba(110, 168, 255, 0.1);
  --gold: #ffb454;
  --gold-soft: rgba(255, 180, 84, 0.14);
  --avatar-start: #3a250f;
  --avatar-end: #174a8b;
  --avatar-text: #f3f5fa;

  /* Shadows */
  --card-shadow: rgba(0, 0, 0, 0.6);
  --overlay-shadow: rgba(0, 0, 0, 0.5);

  /* Syntax colors sit on the same dark code surface in both themes. */
  --syntax-comment: #97a3b6;
  --syntax-string: #9ece6a;
  --syntax-key: #7dcfff;
  --syntax-var: #ffb454;
  --syntax-function: #7aa2f7;
  --syntax-flag: #bb9af7;
  --syntax-keyword: #f7768e;
  --syntax-value: #ff9e64;

  /* Layout & Spacing */
  --max-width: 1080px;
  --content-width: 720px;
  --measure: 68ch;
  --radius: 14px;
  --radius-sm: 7px;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  /* Transitions */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The paper palette keeps the same cool-blue / warm-gold editorial split.
   Text and both accents meet WCAG AA against the base and card surfaces. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f7f3ea;
    --bg-elevated: #fffdf8;
    --surface: #f0eadf;
    --surface-2: #e8e0d2;
    --bg-offset: rgba(224, 230, 238, 0.72);
    --card-bg: rgba(255, 253, 248, 0.86);
    --button-hover: rgba(23, 32, 51, 0.06);
    --border: rgba(23, 32, 51, 0.12);
    --border-strong: rgba(23, 32, 51, 0.24);
    --card-border: rgba(23, 32, 51, 0.14);
    --card-border-hover: rgba(31, 95, 174, 0.5);
    --text-primary: #172033;
    --text-secondary: #3f4b5f;
    --text-muted: #5f6a79;
    --accent: #1f5fae;
    --accent-strong: #174a8b;
    --accent-soft: rgba(31, 95, 174, 0.11);
    --accent-muted: rgba(31, 95, 174, 0.09);
    --gold: #8a4d0f;
    --gold-soft: rgba(138, 77, 15, 0.11);
    --avatar-start: #f0d6b6;
    --avatar-end: #d7e4f5;
    --avatar-text: #172033;
    --card-shadow: rgba(31, 39, 53, 0.16);
    --overlay-shadow: rgba(31, 39, 53, 0.22);
  }
}

/* A saved preference wins over the operating-system preference. */
:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f3ea;
  --bg-elevated: #fffdf8;
  --surface: #f0eadf;
  --surface-2: #e8e0d2;
  --bg-offset: rgba(224, 230, 238, 0.72);
  --card-bg: rgba(255, 253, 248, 0.86);
  --button-hover: rgba(23, 32, 51, 0.06);
  --border: rgba(23, 32, 51, 0.12);
  --border-strong: rgba(23, 32, 51, 0.24);
  --card-border: rgba(23, 32, 51, 0.14);
  --card-border-hover: rgba(31, 95, 174, 0.5);
  --text-primary: #172033;
  --text-secondary: #3f4b5f;
  --text-muted: #5f6a79;
  --accent: #1f5fae;
  --accent-strong: #174a8b;
  --accent-soft: rgba(31, 95, 174, 0.11);
  --accent-muted: rgba(31, 95, 174, 0.09);
  --gold: #8a4d0f;
  --gold-soft: rgba(138, 77, 15, 0.11);
  --avatar-start: #f0d6b6;
  --avatar-end: #d7e4f5;
  --avatar-text: #172033;
  --card-shadow: rgba(31, 39, 53, 0.16);
  --overlay-shadow: rgba(31, 39, 53, 0.22);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(720px circle at 50% -12%, var(--accent-soft), transparent 60%),
    radial-gradient(560px circle at 100% 4%, var(--gold-soft), transparent 55%);
  background-repeat: no-repeat;
  color: var(--text-secondary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Accessibility: a consistent high-contrast keyboard focus ring. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .post-card:hover,
  .prevnext-link:hover {
    transform: none;
  }
}

/* Typography */
h1, h2, h3, h4 {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin-bottom: 0.5em;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  margin-bottom: 0.6em;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5em;
}

p {
  margin-bottom: 1.25rem;
}

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

/* Layout Shell */
.site-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main {
  flex: 1;
  padding: 48px 0 64px;
}

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav a {
  color: var(--text-muted);
}

.nav a:hover {
  color: var(--text-primary);
}

/* Progressive enhancement: the control is only shown after theme.js has
   initialized it, so a no-JavaScript page never exposes an inert button. */
.theme-toggle {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--bg-offset);
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

html[data-theme-ready] .theme-toggle {
  display: inline-flex;
}

.theme-toggle:hover,
.theme-toggle[aria-pressed="true"] {
  border-color: var(--card-border-hover);
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* Footer */
.site-footer {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a:hover {
  color: var(--text-primary);
}

/* Hero & Page Intro */
.home-hero,
.page-intro {
  max-width: var(--content-width);
  margin: 24px 0 64px;
}

.home-hero h1,
.page-intro h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  line-height: 1.15;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.home-hero .lede,
.page-intro .lede {
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
  display: block;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background-color: var(--bg-offset);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.button:hover {
  border-color: var(--text-muted);
  background-color: var(--button-hover);
}

.button-primary {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg);
}

.button-primary:hover {
  background-color: var(--text-secondary);
  border-color: var(--text-secondary);
}

/* Blog Listing Section */
.listing-section {
  margin-bottom: 48px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
}

.section-heading a:hover {
  border-color: var(--accent);
}

/* Grid of "Boxes" (Cards) */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.post-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-border-hover);
  box-shadow: 0 12px 30px -10px var(--card-shadow);
}

.post-card time {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: block;
}

.post-card h3 {
  font-size: 1.2rem;
  line-height: 1.35;
  margin-bottom: 12px;
}

.post-card h3 a {
  color: var(--text-primary);
}

.post-card p {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Post Detail View */
.post-panel {
  max-width: var(--content-width);
  margin: 0 auto;
}

.post-panel .eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 16px;
  display: block;
}

.post-panel time {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 8px;
  display: block;
}

.post-content {
  margin-top: 40px;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.post-content p {
  margin-bottom: 1.5rem;
}

.post-content h2, 
.post-content h3 {
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.post-content h2 {
  font-size: 1.5rem;
}

.post-content h3 {
  font-size: 1.25rem;
}

.post-content ul, 
.post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 24px;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content a {
  color: var(--accent);
  border-bottom: 1px solid var(--card-border-hover);
}

.post-content a:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.post-content blockquote {
  border-left: 4px solid var(--accent);
  background-color: var(--bg-offset);
  padding: 16px 24px;
  margin: 24px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  background-color: var(--bg-offset);
  border: 1px solid var(--card-border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.post-content pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.post-content pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--code-text);
}

.post-content figure {
  margin: 32px 0;
}

.post-content figure img {
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}

.post-content figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: center;
}

/* About Page Custom Layout */
.about-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 64px;
  margin-top: 16px;
}

.about-sidebar {
  position: sticky;
  top: 40px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.about-profile-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.about-avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--avatar-start), var(--avatar-end));
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--avatar-text);
  font-family: var(--font-serif);
  font-weight: bold;
}

.about-profile-card h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.about-profile-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.about-details-list {
  list-style: none;
  text-align: left;
  font-size: 0.85rem;
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-details-list li {
  display: flex;
  justify-content: space-between;
}

.about-details-list span:first-child {
  color: var(--text-muted);
}

.about-details-list span:last-child {
  color: var(--text-secondary);
  font-weight: 500;
}

.about-narrative {
  font-size: 1.05rem;
  line-height: 1.8;
}

.about-narrative h1 {
  margin-bottom: 24px;
}

.about-narrative h2 {
  margin-top: 40px;
  font-size: 1.4rem;
}

.about-narrative ul {
  margin-bottom: 24px;
  padding-left: 20px;
}

.about-narrative li {
  margin-bottom: 12px;
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 420px;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 40px var(--overlay-shadow);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(12px);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.cookie-banner p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.cookie-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Responsive Styling */
@media (max-width: 920px) {
  .post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .about-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  
  .about-sidebar {
    position: static;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .site-shell {
    padding: 24px 16px;
  }
  
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .nav {
    width: 100%;
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
  }

  .theme-toggle {
    margin-left: auto;
  }
  
  .post-grid {
    grid-template-columns: 1fr;
  }
  
  .site-footer {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .button-row {
    flex-direction: column;
    width: 100%;
  }
  
  .button {
    width: 100%;
  }
  
  .cookie-banner {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* =====================================================================
   Editorial components (hero, cards, post layout, tags, search, code)
   Added in the bolder-identity redesign. All CSP-safe (no inline styles).
   ===================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.accent-text {
  color: var(--gold);
}

.text-link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}
.text-link:hover {
  border-color: var(--accent);
}

/* Hero */
.home-hero .eyebrow {
  color: var(--gold);
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

/* Active nav state */
.nav a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 2px;
}

/* Listing cards */
.post-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-card {
  position: relative;
  gap: 0;
}
.post-card[hidden] {
  display: none;
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}
.post-card-meta .dot {
  opacity: 0.5;
}
.post-card-title {
  font-size: 1.22rem;
  line-height: 1.3;
  margin-bottom: 10px;
}
.post-card-title a {
  color: var(--text-primary);
}
.post-card-title a:hover {
  color: var(--accent);
}
/* Stretched link: whole card is clickable, tag chips stay independent */
.post-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.post-card-excerpt {
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-featured {
  grid-column: 1 / -1;
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 55%),
    var(--card-bg);
}
.post-card-featured .post-card-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
}
.post-card-featured .post-card-excerpt {
  font-size: 1.02rem;
  max-width: 60ch;
}

/* Tags */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}
.tag-chip {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-offset);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  transition: var(--transition);
}
.tag-chip:hover {
  color: var(--text-primary);
  border-color: var(--gold);
  background: var(--gold-soft);
}
.tag-count {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.tag-filter-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

/* Search */
.search {
  margin-bottom: 28px;
}
.search-input {
  width: 100%;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-empty {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Post layout: optional TOC rail + article */
.post-panel {
  max-width: var(--content-width);
  margin: 0 auto;
}
.post-panel.has-toc {
  max-width: 1060px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 60px;
  align-items: start;
}
.post-article {
  min-width: 0;
}

.post-masthead {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--card-border);
}
.post-masthead .eyebrow {
  color: var(--gold);
}
.post-masthead h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.12;
  margin-bottom: 20px;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.post-meta .dot {
  opacity: 0.5;
}

/* Table of contents */
.post-toc {
  position: sticky;
  top: 32px;
  align-self: start;
  font-size: 0.85rem;
}
.post-toc-title {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.post-toc ul {
  list-style: none;
  border-left: 1px solid var(--card-border);
}
.post-toc li {
  margin: 0;
}
.post-toc a {
  display: block;
  padding: 6px 0 6px 16px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  line-height: 1.4;
  transition: color 0.2s, border-color 0.2s;
}
.post-toc a:hover {
  color: var(--text-primary);
  border-color: var(--gold);
}
.post-toc .toc-h3 a {
  padding-left: 28px;
  font-size: 0.82rem;
}

/* Heading anchors */
.post-content :is(h2, h3) {
  position: relative;
}
.heading-anchor {
  position: absolute;
  left: -1.1em;
  color: var(--text-muted);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
  transition: opacity 0.2s;
}
.post-content :is(h2, h3):hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
  color: var(--gold);
}

/* Post footer: tags + prev/next */
.post-footer {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--card-border);
}
.tag-row-footer {
  margin-bottom: 32px;
}
.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
.prevnext-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: var(--transition);
}
.prevnext-link:hover {
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
}
.prevnext-next {
  text-align: right;
}
.prevnext-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.prevnext-title {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.35;
}

/* Code blocks with language label */
.code-block {
  position: relative;
  margin-bottom: 1.5rem;
}
.code-lang {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--code-label-text);
  background: var(--code-label-bg);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  border-top: none;
  border-right: none;
}
.code-block pre {
  margin-bottom: 0;
}

/* Syntax token colors (class-based theme; no inline styles) */
.post-content pre code .tok-comment { color: var(--syntax-comment); font-style: italic; }
.post-content pre code .tok-string  { color: var(--syntax-string); }
.post-content pre code .tok-key     { color: var(--syntax-key); }
.post-content pre code .tok-var     { color: var(--syntax-var); }
.post-content pre code .tok-fn      { color: var(--syntax-function); }
.post-content pre code .tok-flag    { color: var(--syntax-flag); }
.post-content pre code .tok-keyword { color: var(--syntax-keyword); }
.post-content pre code .tok-bool    { color: var(--syntax-value); }
.post-content pre code .tok-num     { color: var(--syntax-value); }

/* Post-layout responsive */
@media (max-width: 900px) {
  .post-panel.has-toc {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .post-toc {
    position: static;
    margin-bottom: 36px;
    padding: 18px 20px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card-bg);
  }
  .post-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .prevnext {
    grid-template-columns: 1fr;
  }
  .prevnext-next {
    text-align: left;
  }
}

/* Print keeps articles compact, legible, and useful away from the screen. */
@media print {
  @page {
    margin: 0.7in;
  }

  :root,
  :root[data-theme="dark"],
  :root[data-theme="light"] {
    color-scheme: light;
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f2f2;
    --bg-offset: #f2f2f2;
    --card-bg: #ffffff;
    --button-hover: #ffffff;
    --code-bg: #f2f2f2;
    --code-label-bg: #e5e5e5;
    --border: #777777;
    --border-strong: #555555;
    --card-border: #777777;
    --card-border-hover: #000000;
    --code-border: #777777;
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-muted: #333333;
    --code-text: #000000;
    --code-label-text: #000000;
    --accent: #000000;
    --accent-strong: #000000;
    --accent-soft: transparent;
    --accent-muted: transparent;
    --gold: #000000;
    --gold-soft: transparent;
    --avatar-start: #ffffff;
    --avatar-end: #ffffff;
    --avatar-text: #000000;
    --card-shadow: transparent;
    --overlay-shadow: transparent;
    --syntax-comment: #000000;
    --syntax-string: #000000;
    --syntax-key: #000000;
    --syntax-var: #000000;
    --syntax-function: #000000;
    --syntax-flag: #000000;
    --syntax-keyword: #000000;
    --syntax-value: #000000;
  }

  html,
  body {
    background: var(--bg) !important;
    color: var(--text-secondary);
  }

  body {
    background-image: none;
    font-size: 11pt;
    line-height: 1.5;
  }

  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .site-shell {
    max-width: none;
    min-height: 0;
    padding: 0;
  }

  .site-main {
    padding: 24pt 0 0;
  }

  .site-header {
    padding-bottom: 12pt;
  }

  .nav,
  .theme-toggle,
  .search,
  .tag-filter,
  .post-toc,
  .heading-anchor,
  .prevnext,
  .cookie-banner {
    display: none !important;
  }

  .post-panel,
  .post-panel.has-toc {
    display: block;
    max-width: none;
  }

  .post-masthead {
    margin-bottom: 24pt;
    padding-bottom: 16pt;
  }

  .post-content {
    margin-top: 0;
  }

  .post-content a[href] {
    color: var(--text-primary);
    border: 0;
    text-decoration: underline;
  }

  .post-content a[href]::after {
    content: " (" attr(href) ")";
    font-family: var(--font-sans);
    font-size: 0.82em;
    font-weight: 400;
    overflow-wrap: anywhere;
    text-decoration: none;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  blockquote,
  figure,
  pre,
  .post-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .post-content pre {
    overflow: visible;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .post-content figure img {
    max-width: 100%;
  }

  .about-avatar-placeholder {
    border: 1px solid var(--border-strong);
  }

  .site-footer {
    margin-top: 24pt;
    padding-top: 12pt;
  }
}
