/* ──────────────────────────────────────────────────────────────────────────
   TSQL.APP blog theme.
   Deliberately reuses the homepage's tokens (index.html :root) so the blog
   reads as the same site: Inter/Roboto Mono, #0066cc, the dark #1e2126 code
   panel with a primary left border. Bootstrap 5.3 supplies the grid/navbar;
   everything here is blog-specific on top of it.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --primary: #0066cc;
  --primary-dark: #004d99;
  --secondary: #6c757d;
  --dark: #212529;
  --light: #f8f9fa;
  --code-bg: #1e2126;
  --rule: #e9ecef;
  --ink: #333;
  --ink-soft: #5b6470;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  line-height: 1.6;
}

.navbar { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.navbar-brand { font-weight: 700; letter-spacing: -0.5px; }

/* ── Masthead ──────────────────────────────────────────────────────────── */
/* Shorter than the homepage hero: this is a signpost, not a pitch. */
.blog-hero {
  background: linear-gradient(135deg, #0066cc 0%, #004d99 100%);
  color: #fff;
  padding: 4rem 0 3.5rem;
}
.blog-hero h1 {
  font-weight: 700;
  font-size: 2.75rem;
  letter-spacing: -1px;
  margin-bottom: 1rem;
}
.blog-hero p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 640px;
  margin-bottom: 0;
}
.blog-hero a { color: #fff; }

/* ── Post cards (index / tag / archive listings) ───────────────────────── */
.post-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  transition: transform 0.3s, box-shadow 0.3s;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.post-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0,0,0,0.12);
}
.post-card .card-body { padding: 1.5rem; flex: 1 1 auto; display: flex; flex-direction: column; }
.post-card h2, .post-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}
.post-card h2 a, .post-card h3 a { color: var(--dark); text-decoration: none; }
.post-card h2 a:hover, .post-card h3 a:hover { color: var(--primary); }
.post-card .excerpt { color: var(--ink-soft); flex: 1 1 auto; margin-bottom: 1rem; }
.post-card .cover {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--light);
}

/* A listing card with the row to itself (one post under the featured one, or
   a tag with a single post). Without this it renders at third width and reads
   as a grid that lost its other two cards. */
.col-12 > .post-card:not(.post-featured) .card-body { padding: 1.75rem 2rem; }
.col-12 > .post-card:not(.post-featured) h2 { font-size: 1.5rem; }
.col-12 > .post-card:not(.post-featured) .excerpt { max-width: 68ch; }

/* From tablet up it reads better as a row — cover left, text right, matching
   the featured card above it. A full-bleed letterbox cover on a wide card
   dominates a post it is only illustrating. */
@media (min-width: 768px) {
  .col-12 > .post-card:not(.post-featured) { flex-direction: row; }
  .col-12 > .post-card:not(.post-featured) > a { flex: 0 0 320px; display: block; }
  .col-12 > .post-card:not(.post-featured) .cover { height: 100%; min-height: 210px; }
}

/* ── Meta line (date · reading time) ───────────────────────────────────── */
.post-meta {
  font-size: 0.875rem;
  color: var(--secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.post-meta .sep { opacity: 0.45; }

/* ── Tag chips ─────────────────────────────────────────────────────────── */
.tag-chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(0,102,204,0.08);
  color: var(--primary);
  border: 1px solid rgba(0,102,204,0.18);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.tag-chip:hover { background: var(--primary); color: #fff; }
.tag-chip.is-active { background: var(--primary); color: #fff; }
.tag-chip .count { opacity: 0.65; margin-left: 0.3rem; }

/* ── Article body ──────────────────────────────────────────────────────── */
/* ~68 characters per line is the readable measure; the container is wider
   than the prose on purpose so figures and code can breathe. */
.article { max-width: 760px; }
.article-header { border-bottom: 1px solid var(--rule); padding-bottom: 1.5rem; margin-bottom: 2rem; }
.article-header h1 {
  font-weight: 700;
  font-size: 2.4rem;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.article-header .lead { font-size: 1.2rem; color: var(--ink-soft); }
.article-cover {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.prose { font-size: 1.075rem; line-height: 1.75; }
.prose > *:first-child { margin-top: 0; }
.prose h2 {
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}
.prose h3 {
  font-weight: 700;
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.prose h4 { font-weight: 600; font-size: 1.1rem; margin-top: 1.75rem; margin-bottom: 0.5rem; }
.prose p { margin-bottom: 1.25rem; }
.prose ul, .prose ol { margin-bottom: 1.25rem; padding-left: 1.4rem; }
.prose li { margin-bottom: 0.4rem; }
.prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { color: var(--primary-dark); }
.prose img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5rem 0; }
.prose hr { margin: 2.5rem 0; border-color: var(--rule); }

/* Anchor links on headings: invisible until hover, never in the tab order. */
.prose .heading-anchor {
  opacity: 0;
  margin-left: 0.4rem;
  font-weight: 400;
  text-decoration: none;
  color: var(--secondary);
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor { opacity: 1; }

.prose blockquote {
  border-left: 4px solid var(--primary);
  background: var(--light);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  color: var(--ink-soft);
}
.prose blockquote > *:last-child { margin-bottom: 0; }

.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.prose th, .prose td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--rule); text-align: left; }
.prose thead th { background: var(--light); font-weight: 600; border-bottom: 2px solid var(--rule); }

/* Inline code — distinct from a code block, never the dark panel. */
.prose :not(pre) > code {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.875em;
  background: #f5f7f9;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.12em 0.4em;
  color: #c7254e;
}

/* ── Code blocks — the homepage .code-sample, made copyable ────────────── */
.code-block { position: relative; margin: 1.5rem 0; }
.code-block pre {
  font-family: 'Roboto Mono', monospace;
  background-color: var(--code-bg);
  color: #e6e6e6;
  border-radius: 6px;
  border-left: 4px solid var(--primary);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
}
.code-block pre code { font-family: inherit; background: none; border: 0; padding: 0; color: inherit; }
.code-lang {
  position: absolute;
  top: 0.6rem;
  right: 4.5rem;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6f7783;
  pointer-events: none;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: #c9cdd3;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 4px;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.code-block:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.copy-btn.copied { background: #198754; border-color: #198754; color: #fff; opacity: 1; }

/* Pygments token colours, matched to the homepage's .code-sample palette. */
.code-block .c, .code-block .c1, .code-block .cm, .code-block .cs, .code-block .cp { color: #75715E; font-style: italic; }
.code-block .k, .code-block .kd, .code-block .kn, .code-block .kr, .code-block .kt, .code-block .kc { color: #66D9EF; }
.code-block .s, .code-block .s1, .code-block .s2, .code-block .sb, .code-block .sc, .code-block .sd,
.code-block .se, .code-block .sh, .code-block .si, .code-block .sx, .code-block .sr, .code-block .ss { color: #E6DB74; }
.code-block .nf, .code-block .nb, .code-block .fm { color: #A6E22E; }
.code-block .nv, .code-block .vg, .code-block .vi, .code-block .vc { color: #FD971F; }
.code-block .o, .code-block .ow, .code-block .p { color: #F92672; }
.code-block .m, .code-block .mi, .code-block .mf, .code-block .mh, .code-block .mo { color: #AE81FF; }
.code-block .nc, .code-block .nn, .code-block .no { color: #A6E22E; }
.code-block .na, .code-block .nt { color: #66D9EF; }
.code-block .err { color: #e6e6e6; }

/* ── Footers / navigation between posts ────────────────────────────────── */
.article-footer { border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1.5rem; }
.post-nav a {
  display: block;
  text-decoration: none;
  color: var(--dark);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  height: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.post-nav a:hover { border-color: var(--primary); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.post-nav .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--secondary); }
.post-nav .title { font-weight: 600; }

.site-footer { background: var(--dark); color: #fff; padding: 3rem 0 2rem; margin-top: 4rem; }
.site-footer a { color: rgba(255,255,255,0.75); text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer h4 { color: var(--primary); }

/* ── Archive list ──────────────────────────────────────────────────────── */
.archive-year {
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.archive-item { display: flex; gap: 1rem; padding: 0.6rem 0; align-items: baseline; }
.archive-item .date {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.82rem;
  color: var(--secondary);
  flex: 0 0 5.5rem;
}
.archive-item a { color: var(--dark); text-decoration: none; font-weight: 500; }
.archive-item a:hover { color: var(--primary); }

/* ── Small screens ─────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .blog-hero { padding: 3rem 0 2.5rem; }
  .blog-hero h1 { font-size: 2rem; }
  .article-header h1 { font-size: 1.85rem; }
  .prose { font-size: 1.02rem; }
  .code-lang { display: none; }
  .copy-btn { opacity: 1; }        /* no hover on touch — always show it */
  .archive-item { flex-direction: column; gap: 0.15rem; }
}

/* ── Featured post (newest, on the index) ──────────────────────────────── */
.post-featured { box-shadow: 0 10px 28px rgba(0,0,0,0.10); }
.post-featured:hover { transform: none; box-shadow: 0 14px 32px rgba(0,0,0,0.13); }
.post-featured .card-body { padding: 2rem; }
.post-featured h2 { font-size: 1.9rem; letter-spacing: -0.6px; margin-bottom: 0.75rem; }
.post-featured .lead-excerpt { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 1rem; }
.featured-flag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: rgba(0,102,204,0.08);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  margin-bottom: 0.75rem;
}
.featured-cover {
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: 320px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--light);
}

/* ── Topics strip ──────────────────────────────────────────────────────── */
.topics-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.topics-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--secondary);
}

@media (max-width: 575.98px) {
  .post-featured .card-body { padding: 1.5rem; }
  .post-featured h2 { font-size: 1.45rem; }
  .post-featured .lead-excerpt { font-size: 1rem; }
}

/* Copy failed (clipboard permission denied and execCommand unavailable): tell
   the reader to copy by hand rather than leaving the button silent. */
.copy-btn.failed { background: #b02a37; border-color: #b02a37; color: #fff; opacity: 1; }
