:root {
  --blog-body-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.blog-post {
  /* Base typography tweaks */
  font-family: var(--blog-body-font);
  color: var(--dark);
  line-height: 1.4;
  text-align: left;
  background-color: rgba(244, 243, 242, 1);
}

/* Container for readable width */
.blog-post .container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding-left: var(--page-padding-x);
  padding-right: var(--page-padding-x);
} 
.article-metadata {
  font-size: 0.8rem;
  color: rgba(0,0,0,0.5);
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* Hero banner */
.hero {
  position: relative;
  height: 40vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center; 
  padding-left:0 !important;
  padding-right:0 !important;
  width: 100%;
}

.blog-post .blog-hero {
  min-height: 180px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding-top: clamp(80px, 10vw, 100px);
  padding-bottom: 0;
}

.blog-post .blog-hero .titles-only {
  padding-bottom: 0;
}

.blog-post h1 {
  font-size: 3rem;
  margin: 0;
}

/* Content elements */
.blog-post h1,
.blog-post h2,
.blog-post h3,
.blog-post h4 {
  margin: 2rem 0 1rem 0;
  font-weight: 700;
  text-align: left;
}

/* Anchor icon styling - appears on hover */
.blog-post .anchor-icon {
  visibility: hidden;
  margin-left: 0.5rem;
  text-decoration: none;
  color: #999;
  font-size: 0.8em;
  font-weight: normal;
  transition: color 0.2s ease;
}

.blog-post h1:hover .anchor-icon,
.blog-post h2:hover .anchor-icon,
.blog-post h3:hover .anchor-icon,
.blog-post h4:hover .anchor-icon,
.blog-post h5:hover .anchor-icon,
.blog-post h6:hover .anchor-icon {
  visibility: visible;
}

.blog-post .anchor-icon:hover {
  color: #666;
}

.blog-post p {
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
}

.blog-post ul {
  list-style: disc outside;
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.blog-post ol {
  list-style: decimal outside;
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.blog-post ol li {
  padding-left: 1rem;
}

.blog-post hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 3rem auto;
  width: 60%;
}

.blog-post img {
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* Links */
.blog-post a {
  color: var(--brand-color);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.blog-post a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.blog-post a:visited {
  color: var(--brand-color);
}

/* Blockquotes */
.blog-post blockquote {
  border-left: 4px solid var(--brand-color);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--secondary);
  font-style: italic;
}

/* Inline code styling */
.blog-post code:not(pre code) {
  background-color: #e5e7eb;
  color: #1e3a8a;
  padding-top: calc(0.2em - 1px);
  padding-bottom: calc(0.2em - 1px);
  padding-left: calc(0.4em + 2px);
  padding-right: calc(0.4em + 2px);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.85em;
  font-weight: bold;
  letter-spacing: -0.01em;
}

/* Code blocks (pre) */
.blog-post pre {
  background-color: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.blog-post pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
}

/* KaTeX math formulas */
/* Block math ($$...$$) - centered display formulas */

/* Ensure paragraphs containing math center their content (modern browsers) */
.blog-post p:has(.katex-display),
.blog-post p:has(.katex:only-child) {
  text-align: center !important;
}

/* Universal rule for all katex-display elements - use block display with centered content */
.blog-post .katex-display,
.blog-post * .katex-display {
  display: block !important;
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: 1.5rem !important;
  margin-bottom: 1.5rem !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Handle inline katex that appears as the only child in a paragraph (should be block math) */
/* This catches cases where $$...$$ formulas are rendered as .katex instead of .katex-display */
/* Only apply to paragraphs where katex is the only or first/last child (block math scenario) */
.blog-post p > .katex:only-child,
.blog-post p:has(> .katex:only-child),
.blog-post p:has(> .katex:first-child:last-child) {
  display: block !important;
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: 1.5rem !important;
  margin-bottom: 1.5rem !important;
  width: 100% !important;
}

/* Center paragraphs that contain only a katex element (block math in paragraph) */
.blog-post p:has(> .katex:only-child) {
  text-align: center !important;
}

/* Special handling when inside paragraphs - ensure it breaks out of text-align context */
.blog-post p .katex-display {
  text-align: center !important;
  /* Force the paragraph's text-align to not affect this */
  direction: ltr !important;
}

/* Center the actual KaTeX content inside */
.blog-post .katex-display > .katex {
  display: inline-block !important;
  text-align: initial !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Inline math ($...$) - keep inline with text */
.blog-post .katex:not(.katex-display > .katex):not(p > .katex:only-child) {
  font-size: 1.05em;
}

/* Center the actual KaTeX content */
.blog-post .katex-display > .katex {
  display: inline-block !important;
  text-align: initial;
  margin: 0 !important;
  flex-shrink: 0;
}

/* Inline math ($...$) - keep inline with text */
.blog-post .katex:not(.katex-display > .katex) {
  font-size: 1.05em;
}

/* Table wrapper for horizontal scroll when needed */
.blog-post .table-scroll {
  width: 100%; /* default: respect container width */
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

/* Full-bleed variant: allow wrapper to grow to viewport and center */
.blog-post .table-scroll.is-fullbleed {
  /* Full-bleed container aligned to viewport with equal gutters */
  width: 100vw;
  max-width: none;
  left: auto;
  transform: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
  padding-right: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
}

/* Table styles */
.blog-post table {
  width: max-content; /* let table grow based on content, potentially wider than container */
  border-collapse: collapse; /* ensures borders share edges */
  margin: 0; /* wrapper handles layout */
}

.blog-post table th {
  text-align: left; /* column headers left-aligned */
  vertical-align: top;
}

.blog-post table th,
.blog-post table td {
  width: 200px;
  min-width: 200px;
  max-width: 220px;
  vertical-align: top; /* top-align content in all cells */
  padding: 0.5rem;
}

/* Dotted vertical dividers between columns */
.blog-post table th:not(:last-child),
.blog-post table td:not(:last-child) {
  border-right: 1px dotted #ccc;
}

@media (max-width: 768px) {
  .blog-post .hero-content h1 {
    font-size: 2.25rem;
  }
  .blog-post .container {
    padding-left: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
    padding-right: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
  }
  .blog-post .table-scroll.is-fullbleed {
    padding-left: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
    padding-right: var(--page-padding-x, clamp(1.5rem, 5vw, 6rem));
  }
}