:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #6b655d;
  --line: #e7e2d9;
  --accent: #c8372d;
  --accent-ink: #a52a21;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 42rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --surface: #1f1d1b; --ink: #ece8e1; --muted: #a39c92;
    --line: #34302b; --accent: #ef6a5e; --accent-ink: #f48a80;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1.0625rem/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
.wrap { width: min(100% - 2rem, 76rem); margin-inline: auto; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 4rem; }
/* Logo band (scrolls away); the menu bar below it stays pinned */
.masthead { background: var(--surface); }
.masthead .wrap { padding-block: 1.5rem .75rem; }
.logo { display: block; width: min(100%, 60rem); margin-inline: auto; }
.logo-svg { display: block; width: 100%; height: auto; }
@media (prefers-color-scheme: dark) {
  .logo-svg .lg-nm { fill: #e8edf5; }
  .logo-svg .lg-ic { stroke: #9fb2c8; }
}
/* Social links, right-hand end of the menu bar */
.social { list-style: none; margin: 0 0 0 auto; padding: 0; display: flex; gap: .2rem; }
.social a { display: block; padding: .5rem .7rem; color: var(--ink); text-decoration: none; border-radius: 6px; text-transform: uppercase; font-size: .82rem; font-weight: 600; letter-spacing: .04em; }
.social a:hover { background: var(--line); }
.nav { margin-left: -.7rem; }
.nav a, .nav summary { text-transform: uppercase; font-size: .82rem; font-weight: 600; letter-spacing: .04em; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.nav a, .nav summary { display: block; padding: .5rem .7rem; color: var(--ink); text-decoration: none; font-size: .95rem; border-radius: 6px; cursor: pointer; }
.nav a:hover, .nav summary:hover, .nav a[aria-current] { background: var(--line); }
.nav summary { list-style: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: " ▾"; font-size: .75em; color: var(--muted); }
.has-sub { position: relative; }
.has-sub ul { position: absolute; top: 100%; left: 0; flex-direction: column; min-width: 15rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .35rem; box-shadow: 0 8px 24px rgb(0 0 0 / .08); }
.menu-toggle { display: none; margin-left: auto; font: inherit; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: .35rem .8rem; }

@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .masthead .wrap { padding-block: 1rem .5rem; }
  .social { margin-left: -.4rem; order: 1; }
  .menu-toggle { order: 2; }
  .social a { padding-inline: .4rem; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: .5rem 1rem 1rem; }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; }
  .has-sub ul { position: static; box-shadow: none; border: 0; padding-left: 1rem; background: none; }
}

/* Main */
main { padding-block: 2rem 4rem; }
.intro { max-width: var(--measure); margin-bottom: 2.5rem; }
.intro h1, .page-title, .post-head h1 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.intro h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 .5rem; }
.intro p { color: var(--muted); font-size: 1.15rem; margin: 0; }
.page-title { font-size: 2rem; margin: 0 0 2rem; }
.page-title span { font-family: var(--sans); font-size: .9rem; font-weight: 400; color: var(--muted); margin-left: .5rem; }

.cats { margin: 0 0 .35rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.cats a { color: var(--accent-ink); text-decoration: none; }
.meta { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }

/* Post cards: 3 across on wide screens, 2 on tablets, 1 on phones */
.cards { display: grid; gap: 1.5rem; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .cards { grid-template-columns: 1fr; } }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card .thumb img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; }
.card-body { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; flex: 1; }
.card h2 { font-family: var(--serif); font-size: 1.3rem; line-height: 1.25; margin: 0 0 .5rem; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { color: var(--accent-ink); }
.excerpt { margin: 0; color: var(--muted); font-size: .97rem; }
.card .meta { margin-top: auto; padding-top: .75rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
.pager span a { padding: .25rem .55rem; border-radius: 6px; text-decoration: none; }
.pager span a[aria-current] { background: var(--ink); color: var(--bg); }

.topics { margin-top: 3.5rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.topics h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 .75rem; }
.topics p { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; }
.topics a { border: 1px solid var(--line); border-radius: 99px; padding: .25rem .8rem; text-decoration: none; color: var(--ink); font-size: .92rem; background: var(--surface); }
.topics small { color: var(--muted); margin-left: .2rem; }

/* Article */
.post { max-width: var(--measure); margin-inline: auto; }
.post-head { margin-bottom: 2rem; }
.post-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); margin: 0; }
.hero { margin: 0 0 2rem; }
.hero img { border-radius: 10px; display: block; margin-inline: auto; max-height: 34rem; width: auto; }
.prose { font-size: 1.1rem; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); line-height: 1.25; margin: 2.2rem 0 .6rem; }
.prose h2 { font-size: 1.6rem; } .prose h3 { font-size: 1.3rem; }
.prose img { border-radius: 8px; display: block; margin: 1.5rem auto; }
.prose figure { margin: 1.75rem 0; }
.prose figcaption { color: var(--muted); font-size: .9rem; text-align: center; margin-top: -.75rem; }
.prose blockquote { margin: 1.5rem 0; padding: .25rem 1.25rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; }
.prose pre { background: var(--surface); border: 1px solid var(--line); padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: .9rem; }
.prose code { font-size: .92em; }
.prose iframe { max-width: 100%; border: 0; border-radius: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose .wp-block-image, .prose .wp-block-embed { margin: 1.75rem 0; }
.prose .wp-block-gallery, .prose .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; list-style: none; padding: 0; }
.prose .wp-block-gallery img, .prose .gallery img { margin: 0; width: 100%; height: 100%; object-fit: cover; }
.aligncenter { margin-inline: auto; text-align: center; }

/* Series contents box (e.g. the AF articles) */
.series { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 1rem 1.25rem; margin: 1.75rem 0; font-size: 1rem; }
.series h4 { margin: 0 0 .5rem; font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.series ol { margin: 0; padding-left: 1.3rem; }
.series li { margin: .2rem 0; }
.series strong { font-weight: 600; color: var(--ink); }

.post-nav { max-width: var(--measure); margin: 3.5rem auto 0; display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.post-nav a { text-decoration: none; color: var(--ink); max-width: 48%; font-family: var(--serif); font-size: 1.05rem; line-height: 1.3; }
.post-nav small { display: block; font-family: var(--sans); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .2rem; }
.post-nav .newer { text-align: right; margin-left: auto; }

/* Contact form */
.contact { display: grid; gap: 1rem; margin-top: 1.5rem; }
.contact label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.contact input, .contact textarea { font: inherit; font-weight: 400; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
.contact input:focus, .contact textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.contact button { justify-self: start; font: inherit; font-weight: 600; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: .7rem 1.4rem; cursor: pointer; }
.contact button:disabled { opacity: .6; }
.hp { position: absolute !important; left: -9999px !important; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding-block: 1.5rem; }
.footer-inner p { margin: 0; }
.footer-inner a { color: var(--muted); }

/* Search (Pagefind) */
#search { --pagefind-ui-primary: var(--accent); --pagefind-ui-text: var(--ink); --pagefind-ui-background: var(--surface); --pagefind-ui-border: var(--line); --pagefind-ui-tag: var(--line); --pagefind-ui-font: var(--sans); max-width: var(--measure); }
