/* =========================================================================
   Custom design layer — "Engineering Journal"
   Loaded after beautifuljekyll.css; overrides the vendored theme.
   Palette: warm paper / navy ink / copper accent.
   Type: Fraunces (display) · Source Serif 4 (prose) · JetBrains Mono (code, labels)
   ========================================================================= */

:root {
  --body-font: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --header-font: 'Fraunces', Georgia, serif;
  --mono-font: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  --paper: #FAF7F1;
  --paper-deep: #F3EFE6;
  --ink: #14213D;
  --ink-soft: #3D4763;
  --muted: #5C6478;
  --hairline: #E6E0D4;
  --accent: #B5502F;
  --accent-soft: #F5E7DF;
  --link: #0F5297;

  --code-bg: #101828;
  --code-edge: #1D2A44;
  --code-ink: #E8E4DA;

  --shadow-sm: 0 1px 2px rgba(20, 33, 61, 0.06), 0 1px 6px rgba(20, 33, 61, 0.05);
  --shadow-md: 0 2px 6px rgba(20, 33, 61, 0.08), 0 12px 32px rgba(20, 33, 61, 0.12);
  --radius: 10px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-size: 1.0625rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  color: var(--paper);
  background-color: var(--ink);
}
::-moz-selection {
  color: var(--paper);
  background-color: var(--ink);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

a {
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Meta label utility: small letterspaced mono, used across components --- */
.post-meta,
.post-heading .post-meta,
.post-preview .post-meta {
  font-family: var(--mono-font);
  font-style: normal;
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* =========================================================================
   Navbar
   ========================================================================= */

.navbar-custom {
  background-color: rgba(250, 247, 241, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.navbar-custom .navbar-brand {
  font-family: var(--header-font);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.navbar-custom .navbar-nav .nav-item {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.navbar-custom .navbar-brand,
.navbar-custom .navbar-nav .nav-link {
  font-weight: 600;
}

.navbar-custom .navbar-nav .nav-link {
  position: relative;
}

@media (min-width: 1200px) {
  .navbar-custom .navbar-nav .nav-link::after {
    content: "";
    position: absolute;
    left: 0.9375rem;
    right: 0.9375rem;
    bottom: 0.55rem;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
  }
  .navbar-custom .navbar-nav .nav-link:hover::after,
  .navbar-custom .navbar-nav .nav-link:focus::after {
    transform: scaleX(1);
  }
}

.navbar-custom .avatar-container .avatar-img-border {
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   Reading progress bar (injected by custom.js on posts)
   ========================================================================= */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  width: 100%;
  height: 3px;
  background: transparent;
  pointer-events: none;
}

.reading-progress__bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #D9825F);
}

/* =========================================================================
   Page / post headers
   ========================================================================= */

.intro-header .page-heading h1,
.intro-header .post-heading h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.intro-header .page-heading .page-subheading,
.intro-header .post-heading .post-subheading {
  font-family: var(--body-font);
  font-style: italic;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Cover-image headers: replace harsh text-shadow with a navy scrim */
.intro-header.big-img {
  isolation: isolate;
}

.intro-header.big-img::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg,
    rgba(16, 24, 40, 0.38) 0%,
    rgba(16, 24, 40, 0.45) 55%,
    rgba(16, 24, 40, 0.72) 100%);
}

.intro-header.big-img .container-md {
  position: relative;
  z-index: 1;
}

.intro-header.big-img .page-heading,
.intro-header.big-img .post-heading {
  text-shadow: 0 1px 2px rgba(16, 24, 40, 0.55);
}

.intro-header.big-img .page-heading h1,
.intro-header.big-img .post-heading h1 {
  color: var(--paper);
}

.intro-header.big-img .post-heading .post-subheading,
.intro-header.big-img .page-heading .page-subheading {
  color: rgba(250, 247, 241, 0.88);
}

.intro-header.big-img .post-heading .post-meta {
  color: rgba(250, 247, 241, 0.75);
}

.intro-header.big-img .big-img-transition {
  z-index: -1;
}

/* =========================================================================
   Article body
   ========================================================================= */

.blog-post {
  font-size: 1.125rem;
  line-height: 1.78;
  color: var(--ink-soft);
  max-width: 46rem; /* ~72ch reading measure */
}

.blog-post p {
  margin: 1.375rem 0;
}

.blog-post h1,
.blog-post h2,
.blog-post h3,
.blog-post h4 {
  margin-top: 2.75rem;
  margin-bottom: 1rem;
}

.blog-post h1 { font-size: 1.9rem; }
.blog-post h2 { font-size: 1.6rem; }
.blog-post h3 { font-size: 1.3rem; }
.blog-post h4 { font-size: 1.1rem; }

/* Kicker rule above major section headings */
.blog-post h1::after,
.blog-post h2::after {
  content: "";
  display: block;
  width: 2.25rem;
  height: 3px;
  margin-top: 0.6rem;
  border-radius: 2px;
  background: var(--accent);
}

.blog-post a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: rgba(15, 82, 151, 0.35);
  text-decoration-thickness: 1px;
}

.blog-post a:hover,
.blog-post a:focus {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.blog-post ul,
.blog-post ol {
  padding-left: 1.4rem;
  margin: 1.25rem 0;
}

.blog-post li {
  margin: 0.45rem 0;
}

.blog-post li::marker {
  color: var(--accent);
}

.blog-post strong {
  color: var(--ink);
  font-weight: 600;
}

.blog-post hr {
  max-width: none;
  border: 0;
  height: 1px;
  margin: 3rem auto;
  background: linear-gradient(90deg, transparent, var(--hairline) 20%, var(--hairline) 80%, transparent);
}

.blog-post blockquote {
  margin: 2rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
  font-size: 1.15rem;
}

.blog-post img {
  display: block;
  margin: 2rem auto;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
}

.blog-post img + em,
.blog-post .caption {
  display: block;
  text-align: center;
  font-family: var(--mono-font);
  font-style: normal;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: -1.25rem auto 2rem;
}

/* Heading anchor links (injected by custom.js) */
.heading-anchor {
  margin-left: 0.4rem;
  font-family: var(--mono-font);
  font-size: 0.85em;
  color: var(--accent) !important;
  text-decoration: none !important;
  opacity: 0;
  transition: opacity 0.15s ease;
}

h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

/* =========================================================================
   Table of contents (injected by custom.js)
   ========================================================================= */

.post-toc {
  margin: 0 0 2.5rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--paper-deep);
  overflow: hidden;
}

.post-toc summary {
  cursor: pointer;
  list-style: none;
  padding: 0.8rem 1.25rem;
  font-family: var(--mono-font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  user-select: none;
}

.post-toc summary::-webkit-details-marker {
  display: none;
}

.post-toc summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.6rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.post-toc[open] summary::before {
  transform: rotate(90deg);
}

.post-toc ol {
  margin: 0;
  padding: 0.25rem 1.5rem 1rem 2.6rem;
}

.post-toc li {
  margin: 0.3rem 0;
  font-family: var(--body-font);
  font-size: 0.95rem;
}

.post-toc li::marker {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  color: var(--accent);
}

.post-toc a {
  color: var(--ink-soft);
  text-decoration: none;
}

.post-toc a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.post-toc .toc-h3 {
  list-style: none;
  padding-left: 1rem;
  font-size: 0.88rem;
}

/* When the sidebar rail is available (xl screens), hide the inline box */
@media (min-width: 1200px) {
  .post-toc--rail-available {
    display: none;
  }
}

/* --- Sticky sidebar rail --- */

.toc-rail {
  position: sticky;
  top: 7rem;
  max-height: calc(100vh - 9rem);
  overflow-y: auto;
  padding-left: 1.1rem;
  border-left: 1px solid var(--hairline);
}

.toc-rail-label {
  display: block;
  margin-bottom: 0.75rem;
  font-family: var(--mono-font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.toc-rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-rail li {
  margin: 0.45rem 0;
}

.toc-rail li.toc-h3 {
  padding-left: 0.9rem;
}

.toc-rail a {
  display: block;
  font-family: var(--body-font);
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.toc-rail li.toc-h3 a {
  font-size: 0.8rem;
}

.toc-rail a:hover {
  color: var(--accent);
}

.toc-rail a.active {
  color: var(--accent);
  font-weight: 600;
}

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.table-wrapper table {
  margin: 0;
  width: 100%;
  border-collapse: collapse;
}

table tr {
  border-top: 0;
  background-color: var(--paper);
}

table tr:nth-child(2n) {
  background-color: var(--paper-deep);
}

table tr th,
table tr td {
  border: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}

table tr:last-child td {
  border-bottom: 0;
}

table tr th {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border-bottom: 2px solid var(--accent);
}

/* =========================================================================
   Code
   ========================================================================= */

code {
  font-family: var(--mono-font);
  font-size: 0.85em;
  color: var(--ink);
  background-color: rgba(20, 33, 61, 0.07);
  border: 1px solid rgba(20, 33, 61, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

pre,
pre code {
  color: var(--code-ink);
  background: transparent;
  border: 0;
}

.blog-post pre {
  font-family: var(--mono-font);
  font-size: 0.84rem;
  line-height: 1.65;
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin: 0;
  overflow-x: auto;
  tab-size: 4;
}

.blog-post div.highlighter-rouge,
.blog-post > pre,
.code-block {
  position: relative;
  margin: 2rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--code-edge);
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
}

.blog-post div.highlighter-rouge pre,
.code-block pre {
  border: 0;
  box-shadow: none;
  margin: 0;
}

/* kill the theme's ruled-paper texture + thick left border */
.highlight > pre {
  background-image: none;
  border: 0;
  border-left: 0;
  background: transparent;
}

.highlight pre.lineno {
  color: rgba(232, 228, 218, 0.28);
  border-right: 1px solid var(--code-edge);
}

/* Language badge + copy button (injected by custom.js) */
.code-lang {
  position: absolute;
  top: 0.55rem;
  left: 1rem;
  z-index: 2;
  font-family: var(--mono-font);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232, 228, 218, 0.45);
  pointer-events: none;
}

.code-block--labelled pre {
  padding-top: 2.4rem;
}

.code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono-font);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 228, 218, 0.6);
  background: rgba(250, 247, 241, 0.06);
  border: 1px solid rgba(232, 228, 218, 0.18);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-block:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}

.code-copy:hover {
  color: var(--paper);
  border-color: rgba(232, 228, 218, 0.5);
}

.code-copy.is-copied {
  color: #A8C69F;
  border-color: #A8C69F;
  opacity: 1;
}

/* --- Syntax palette: warm night (overrides pygment_highlights.css) --- */

.highlight .hll { background-color: rgba(250, 247, 241, 0.07); }
.highlight .c, .highlight .c1, .highlight .cm,
.highlight .cp, .highlight .cs, .highlight .ch,
.highlight .cd { color: #79839B; font-style: italic; font-weight: normal; }
.highlight .err { color: #E8A87C; background-color: transparent; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp,
.highlight .kr, .highlight .kv { color: #D98E73; font-weight: 600; }
.highlight .kc { color: #E5C07B; font-weight: 600; }
.highlight .kt { color: #E3C78A; font-weight: normal; }
.highlight .o, .highlight .ow { color: #C5CDDB; font-weight: normal; }
.highlight .p { color: #B8C0CE; }
.highlight .n, .highlight .nb, .highlight .ni, .highlight .nl,
.highlight .nn, .highlight .nx, .highlight .py, .highlight .w { color: #E8E4DA; }
.highlight .bp { color: #9DB2D5; }
.highlight .nc { color: #E3C78A; font-weight: 600; }
.highlight .nf, .highlight .fm { color: #8FBFE8; font-weight: normal; }
.highlight .nd { color: #D98E73; font-weight: normal; }
.highlight .nt { color: #D98E73; font-weight: normal; }
.highlight .na { color: #A8C69F; }
.highlight .ne { color: #E8A87C; font-weight: 600; }
.highlight .no { color: #E5C07B; }
.highlight .nv, .highlight .vc, .highlight .vg,
.highlight .vi { color: #9DB2D5; }
.highlight .s, .highlight .sb, .highlight .sc, .highlight .sd,
.highlight .s2, .highlight .sh, .highlight .s1, .highlight .sa,
.highlight .dl { color: #A8C69F; }
.highlight .se, .highlight .si, .highlight .sx { color: #E5C07B; }
.highlight .sr { color: #A8C69F; }
.highlight .ss { color: #9DB2D5; }
.highlight .m, .highlight .mf, .highlight .mh, .highlight .mi,
.highlight .il, .highlight .mo, .highlight .mb,
.highlight .mx { color: #E5C07B; }
.highlight .gd { color: #E8A87C; background-color: rgba(232, 168, 124, 0.12); }
.highlight .gi { color: #A8C69F; background-color: rgba(168, 198, 159, 0.12); }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 600; }
.highlight .gh, .highlight .gu { color: #9DB2D5; font-weight: 600; }
.highlight .gp { color: #79839B; }
.highlight .gt { color: #E8A87C; }

/* =========================================================================
   Mermaid diagram figures (built by custom.js)
   ========================================================================= */

.mermaid-figure {
  position: relative;
  margin: 2.25rem 0;
  padding: 1.75rem 1.25rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background-color: #FDFBF7;
  /* subtle blueprint dot grid */
  background-image: radial-gradient(rgba(20, 33, 61, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  overflow-x: auto;
}

.mermaid-figure .mermaid {
  display: flex;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

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

.mermaid-figure figcaption {
  margin-top: 1rem;
  font-family: var(--mono-font);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Diagram toolbar (zoom + download, injected by custom.js) */

.mermaid-figure svg.mermaid-zoomable {
  cursor: zoom-in;
}

.mermaid-tools {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.mermaid-figure:hover .mermaid-tools,
.mermaid-tools:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .mermaid-tools {
    opacity: 1;
  }
}

.mermaid-btn {
  font-family: var(--mono-font);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(20, 33, 61, 0.55);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(20, 33, 61, 0.18);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mermaid-btn:hover {
  color: #14213D;
  border-color: rgba(20, 33, 61, 0.45);
}

/* Diagram lightbox: full-screen pan + zoom viewer */

.mermaid-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000000; /* above the navbar (999999) and reading progress (2000) */
  background: rgba(13, 22, 41, 0.96);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mermaid-lightbox__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.mermaid-lightbox__stage.is-panning {
  cursor: grabbing;
}

.mermaid-lightbox__canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  box-sizing: border-box;
  background: #FDFBF7;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.mermaid-lightbox__bar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: flex;
  gap: 0.4rem;
}

.mermaid-lightbox__btn {
  min-width: 2.2rem;
  font-family: var(--mono-font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 228, 218, 0.75);
  background: rgba(250, 247, 241, 0.08);
  border: 1px solid rgba(232, 228, 218, 0.25);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mermaid-lightbox__btn:hover {
  color: #FAF7F1;
  border-color: rgba(232, 228, 218, 0.6);
}

.mermaid-lightbox__hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono-font);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(232, 228, 218, 0.5);
  pointer-events: none;
}

@media (hover: none) {
  .mermaid-lightbox__hint {
    display: none;
  }
}

/* =========================================================================
   Notification boxes
   ========================================================================= */

.box-note, .box-warning, .box-error, .box-success {
  border: 1px solid var(--hairline);
  border-left-width: 4px;
  border-radius: 8px;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  font-size: 1rem;
}

.box-note { background-color: #EEF3F9; border-left-color: #0F5297; }
.box-warning { background-color: #FAF3DC; border-left-color: #C99A2E; }
.box-error { background-color: #F9E9E4; border-left-color: var(--accent); }
.box-success { background-color: #EBF2E8; border-left-color: #5F8D4E; }

/* =========================================================================
   Post footer: tags, share, pager
   ========================================================================= */

.blog-tags {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.blog-tags span {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 1;
}

.blog-tags a {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  margin: 0.2rem 0.15rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  opacity: 1;
  transition: all 0.15s ease;
}

.blog-tags a:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.pagination .page-item .page-link {
  font-family: var(--mono-font);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.pagination .page-item .page-link:hover,
.pagination .page-item .page-link:focus {
  background-color: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* =========================================================================
   Home feed: editorial post cards
   (markup in _layouts/home.html; featured card + 2-col grid)
   ========================================================================= */

.posts-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  margin: 0;
}

@media (min-width: 992px) {
  .posts-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .post-preview.featured {
    grid-column: 1 / -1;
  }
}

.post-preview {
  padding: 0;
  border-bottom: 0;
  overflow: visible;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 21rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--paper-deep);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-preview.featured .post-card {
  min-height: 26rem;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.post-card .post-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.6s ease;
}

.post-card:hover .post-bg {
  transform: scale(1.04);
}

/* scrim over image cards */
.post-card.has-img::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg,
    rgba(16, 24, 40, 0.12) 0%,
    rgba(16, 24, 40, 0.5) 48%,
    rgba(16, 24, 40, 0.9) 100%);
  transition: opacity 0.3s ease;
}

.post-card .post-content {
  position: relative;
  z-index: 2;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.post-card .post-meta {
  order: -1;
  margin: 0 0 0.35rem;
}

.post-card.has-img .post-meta {
  color: rgba(250, 247, 241, 0.72);
}

.post-card h2.post-title {
  font-family: var(--header-font);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
}

.post-preview.featured .post-card h2.post-title {
  font-size: 2.1rem;
}

.post-card.has-img h2.post-title {
  color: #FDFBF7;
}

.post-card h3.post-subtitle {
  font-family: var(--body-font);
  font-style: italic;
  font-weight: 400;
  font-size: 1.02rem;
  line-height: 1.5;
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.post-card.has-img h3.post-subtitle {
  color: rgba(250, 247, 241, 0.82);
}

.post-card a.post-link {
  text-decoration: none;
  color: inherit;
}

/* stretched-link: whole card clickable */
.post-card a.post-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
}

.post-card .post-author {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  color: var(--muted);
}

.post-card.has-img .post-author {
  color: rgba(250, 247, 241, 0.72);
}

.post-card .blog-tags {
  margin: 0.75rem 0 0;
  position: relative;
  z-index: 4;
}

.post-card .blog-tags a {
  background: var(--paper);
  margin: 0.15rem 0.3rem 0.15rem 0;
}

.post-card.has-img .blog-tags a {
  background: rgba(250, 247, 241, 0.12);
  border-color: rgba(250, 247, 241, 0.3);
  color: rgba(250, 247, 241, 0.9);
}

.post-card.has-img .blog-tags a:hover {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

/* staggered entrance */
@media (prefers-reduced-motion: no-preference) {
  .post-preview {
    opacity: 0;
    transform: translateY(14px);
    animation: card-in 0.55s ease forwards;
  }
  .post-preview:nth-child(1) { animation-delay: 0.05s; }
  .post-preview:nth-child(2) { animation-delay: 0.14s; }
  .post-preview:nth-child(3) { animation-delay: 0.23s; }
  .post-preview:nth-child(4) { animation-delay: 0.32s; }
  .post-preview:nth-child(5) { animation-delay: 0.41s; }
  .post-preview:nth-child(n+6) { animation-delay: 0.5s; }
}

@keyframes card-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 767px) {
  .post-card {
    min-height: 15rem;
  }
  .post-preview.featured .post-card {
    min-height: 17rem;
  }
  /* text-only cards: no artificial height on phones */
  .post-card:not(.has-img),
  .post-preview.featured .post-card:not(.has-img) {
    min-height: 0;
  }
  .post-card .post-content {
    padding: 1.25rem 1.4rem;
  }
  .post-card h2.post-title,
  .post-preview.featured .post-card h2.post-title {
    font-size: 1.35rem;
  }
  .post-card h3.post-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .post-card .blog-tags,
  .post-card .post-author {
    display: none;
  }
}

/* =========================================================================
   Footer
   ========================================================================= */

footer {
  border-top: 1px solid var(--hairline);
  font-size: 0.85rem;
}

footer .copyright,
footer .footer-custom-content,
footer .theme-by {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

footer .footer-links .fa-inverse {
  color: var(--paper);
}

/* =========================================================================
   Motion & print
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .navbar-custom,
  footer,
  .reading-progress,
  .code-copy,
  .mermaid-tools,
  .pagination,
  #social-share-section {
    display: none !important;
  }
  .blog-post {
    max-width: 100%;
    font-size: 11pt;
  }
  .blog-post pre {
    white-space: pre-wrap;
    background: #fff;
    color: #000;
    border: 1px solid #999;
  }
}
