/*
 * Quarto Blog Theme — Academic/Minimal
 * Inspired by jamiesimon.io
 * Drop this file next to _quarto.yml
 */

/* ── Fonts ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=Source+Code+Pro:wght@400;500&family=Inter:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --body-font:    'Lora', Georgia, serif;
  --ui-font:      'Inter', sans-serif;
  --code-font:    'Source Code Pro', monospace;

  --text-primary:   #1a1a1a;
  --text-secondary: #555;
  --text-muted:     #888;
  --accent:         #2a5db0;      /* a calm academic blue */
  --bg:             #FCF8F2;      /* slightly warm white */
  --border:         #e8e8e4;

  --content-width: 100%; /* let Quarto's grid control width */
  --side-pad: 1.5rem;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
  font-family:      var(--body-font);
  font-size:        1.05rem;
  line-height:      1.8;
  color:            var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout: constrain content width ───────────────────────── */
.quarto-container,
#quarto-content,
.page-columns .column-body {
  max-width: var(--content-width) !important;
  margin: 0 auto;
  padding: 0 var(--side-pad);
}

/* full-width for listing pages (post grid) */
.quarto-listing {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background: var(--bg) !important;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem var(--side-pad);
}

.navbar-brand {
  font-family: var(--ui-font);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-primary) !important;
  letter-spacing: 0.01em;
}

.navbar-nav .nav-link {
  font-family: var(--ui-font);
  font-size: 0.875rem;
  color: var(--text-secondary) !important;
  transition: color 0.15s;
}

.navbar-nav .nav-link:hover {
  color: var(--text-primary) !important;
}

/* ── Post header ─────────────────────────────────────────────── */
.quarto-title h1.title {
  font-family: var(--body-font);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.quarto-title .description {
  font-family: var(--ui-font);
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: normal;
}

.quarto-title-meta {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* Estimated reading time, injected into the post header after every render by
   update_reading_time.sh. Sits just beneath the title-meta / date. */
.reading-time {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1.75rem;
}

/* Series membership, injected into the post header by
   filters/series_banner.lua. Sits above the reading time: the reading time is
   written after rendering, and tools/reading_time/patch.py steps over this
   banner so it stays on top. The adjacent-sibling rule below depends on it. */
.series-banner {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 0.35rem;
}

.series-banner a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.series-banner a:hover {
  border-bottom-color: var(--accent);
}

/* The reading time keeps its negative top margin only when it is the first
   line under the title meta; the banner takes that role when present. */
.series-banner + .reading-time {
  margin-top: 0;
}

/* ── Body text ───────────────────────────────────────────────── */
p {
  margin-bottom: 1.3rem;
}

h1, h2, h3, h4 {
  font-family: var(--body-font);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; color: var(--text-secondary); }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

a:hover {
  border-bottom-color: var(--accent);
}

/* ── Math ────────────────────────────────────────────────────── */
/* Give display math room to breathe */
.math.display {
  overflow-x: auto;
  margin: 2rem 0;
  padding: 0.5rem 0;
}

/* ── Code ────────────────────────────────────────────────────── */
pre {
  font-family: var(--code-font);
  font-size: 0.85rem;
  line-height: 1.6;
  background: #f4f4f1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

code {
  font-family: var(--code-font);
  font-size: 0.85em;
  background: #f0f0ec;
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* code-fold button */
.code-fold-btn-row button {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Figures & images ────────────────────────────────────────── */
figure {
  margin: 2rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  border-radius: 3px;
}

figcaption {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── Blockquote ──────────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Literature quote block ─────────────────────────────────── */
/* Rendered from a [!moviequote]/[!bookquote]/[!poemquote]/[!songquote]
   Obsidian callout by tools/qmd_lint/rules/lit_quote_rules.py (Q1). One
   shared block for any quoted line worth remembering, whatever it came from
   — the kind badge is the only thing that varies. Deliberately not one of
   Quarto's five native callout types — a note/tip/warning is de-emphasized
   admonition chrome, and a remembered line is the opposite of that, so it
   gets its own card look instead. The kind badge reuses the same small
   bordered-uppercase-pill look as .listing-pinned-badge elsewhere on the
   site, rather than inventing a second badge style. */
.lit-quote {
  margin: 2rem 0;
  padding: 1.5rem 1.75rem;
  background: #f6f2ea;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.lit-quote-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--ui-font);
  margin-bottom: 0.75rem;
}

.lit-quote-kind {
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
}

.lit-quote-source {
  flex: 1;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.lit-quote-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.lit-quote blockquote {
  margin: 0;
  padding: 0;
  border-left: none;
  font-family: var(--body-font);
  font-size: 1.2rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--text-primary);
}

.lit-quote blockquote p:last-child {
  margin-bottom: 0;
}

/* ── Tables ──────────────────────────────────────────────────── */
#quarto-document-content table {
  border: 1px solid var(--bs-table-border-color, var(--border));
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 4px;
  overflow: hidden;
}

#quarto-document-content table > :last-child > tr:last-child > * {
  border-bottom-width: 0;
}

/* ── Table of Contents ───────────────────────────────────────── */
#TOC {
  font-family: var(--ui-font);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

#TOC a {
  color: var(--text-secondary);
  border-bottom: none;
}

#TOC a:hover {
  color: var(--accent);
}

/* ── Listing page (index) ────────────────────────────────────── */
.quarto-listing-default .quarto-post {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
}

.quarto-listing-default .quarto-post .thumbnail {
  display: none; /* clean text-only listing */
}

.quarto-listing-default .listing-title a {
  font-family: var(--body-font);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: none;
}

.quarto-listing-default .listing-title a:hover {
  color: var(--accent);
}

.quarto-listing-default .listing-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Pinned marker, injected by scripts/inject_pin_badges.py. Visible text rather
   than an icon, so it carries meaning without relying on colour or shape.
   Styled to match the muted, uncoloured look of .listing-category (the
   Quarto-default category tag) rather than standing out as an accent-coloured
   UI element. */
.quarto-listing-default .listing-pinned-badge {
  display: inline-block;
  font-family: var(--ui-font);
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
  margin-bottom: 0.4rem;
}

/* Series membership on a listing card, injected by
   scripts/inject_listing_badges.py. Deliberately quieter than the Pinned
   badge: it is context, not emphasis. A card carrying both stacks them, badge
   first. Never appears on a series landing page, where every card would
   repeat it. */
.quarto-listing-default .listing-series-label {
  font-family: var(--ui-font);
  font-size: 0.72rem;
  line-height: 1.4;
  margin-bottom: 0.35rem;
}

.quarto-listing-default .listing-series-label a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.quarto-listing-default .listing-series-label a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.quarto-listing-default .listing-pinned-badge + .listing-series-label {
  margin-top: 0.1rem;
}

/* Explicit empty state for a series landing page with no published members.
   The post-render injector adds this only to the `series-posts` listing. */
.series-empty-state {
  font-family: var(--ui-font);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.75rem 0 1.5rem;
}

.quarto-listing-default .listing-date {
  font-family: var(--ui-font);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.quarto-listing-default .listing-reading-time {
  font-family: var(--ui-font);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Categories filter sidebar, as a single thin-outlined box (not a per-item
   box — that would compete with the bordered-pill tags used by
   .listing-category / .listing-pinned-badge / .quarto-category elsewhere on
   the page). align-self: start keeps the box sized to its own content —
   without it, the grid's default `align-items: stretch` pads
   #quarto-margin-sidebar out to the height of the whole listing column, so
   the outline reads as a giant slab instead of hugging the category list
   (and growing/shrinking with it as categories are added or removed).
   Scoped with :has() rather than styling #quarto-margin-sidebar directly,
   since that same container id also holds #TOC on post pages, which should
   stay a plain list. */
#quarto-margin-sidebar:has(.quarto-listing-category-title) {
  align-self: start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
}

#quarto-margin-sidebar .quarto-listing-category-title {
  font-family: var(--ui-font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.5rem;
}

#quarto-margin-sidebar .quarto-listing-category .category {
  font-family: var(--ui-font);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

#quarto-margin-sidebar .quarto-listing-category .category:last-child {
  margin-bottom: 0;
}

#quarto-margin-sidebar .quarto-listing-category .category:hover {
  color: var(--accent);
}

#quarto-margin-sidebar .quarto-listing-category .category.active {
  color: var(--accent);
  font-weight: 600;
}

#quarto-margin-sidebar .quarto-category-count {
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Footer ──────────────────────────────────────────────────── */
.nav-footer {
  font-family: var(--ui-font);
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Bibliography / citations ────────────────────────────────── */
#refs {
  font-family: var(--ui-font);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Applied globally so the citation hover popup (rendered outside #refs) also picks this up. */
div.csl-entry {
  margin-bottom: 0.4rem;
}

div.csl-left-margin,
div.csl-right-inline {
  display: inline;
  float: none;
  min-width: 0;
  margin: 0;
  padding: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --content-width: 100%; }
  body  { font-size: 1rem; }
  .quarto-title h1.title { font-size: 1.6rem; }
}
