/* ============================================================
   kpmartin.com — hand-rolled CSS, no framework.
   Warm “paper” theme with an automatic dark scheme; the red
   accent is a nod to the old Number One sign in Saint Paul.
   ============================================================ */

:root {
  --paper: #faf7f2;
  --ink: #25211c;
  --muted: #6f6a62;
  --faint: #a49d92;
  --line: #e7e1d6;
  --accent: #b3231b;
  --link: #9c2b1f;
  --code-bg: #f0ebe2;
  --wrap: 44rem;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Charter", "Iowan Old Style", "Bitstream Charter", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1815;
    --ink: #e8e3d9;
    --muted: #a09a8f;
    --faint: #6c675f;
    --line: #34302a;
    --accent: #ff5147;
    --link: #ff8873;
    --code-bg: #242220;
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.65;
}

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 1.25rem; }

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

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

::selection { background: rgba(179, 35, 27, 0.18); }

/* Skip link */
.skip-link { position: absolute; left: -100vw; }
.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  background: var(--paper);
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--accent);
  z-index: 10;
}

/* Masthead */
.masthead { padding-block: 2.6rem 1.1rem; border-bottom: 1px solid var(--line); }
.masthead-title { font-size: 1.85rem; line-height: 1.15; margin: 0; font-weight: 700; }
.masthead-title a { color: var(--ink); text-decoration: none; }
.tagline {
  font-style: italic;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 38rem;
  margin: 0.4rem 0 1.1rem;
}
.primary { display: flex; flex-wrap: wrap; gap: 1.1rem; font-family: var(--sans); }
.primary a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.primary a:hover { color: var(--ink); }
.primary a[aria-current="page"] { color: var(--accent); }

main { padding-block: 2.2rem 1rem; }

h1 { font-size: 1.7rem; line-height: 1.22; margin: 0 0 0.5rem; }
h2 { font-size: 1.28rem; line-height: 1.3; margin: 2.2rem 0 0.7rem; }

.meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.2rem;
}
.meta a { color: var(--muted); }
.meta a:hover { color: var(--accent); }

/* Home post list */
.post-item { margin-block-end: 3rem; }
.post-item h2 { margin: 0 0 0.25rem; font-size: 1.32rem; }
.post-item h2 a { text-decoration: none; }
.post-item h2 a:hover { text-decoration: underline; }
.more { font-family: var(--sans); font-size: 0.85rem; margin: 0.4rem 0 0; }

.post-header { margin-bottom: 1.2rem; }

/* Post body */
.content img { max-width: 100%; height: auto; }
.content li { margin-block: 0.25rem; }
.content blockquote {
  margin: 1.2rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.content pre {
  background: var(--code-bg);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.5;
}
code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}
.content pre code { background: none; padding: 0; }

.tags { margin-top: 2rem; }

/* Comments (frozen) */
.comments { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.comments h2 { margin-top: 0; font-size: 1.05rem; font-family: var(--sans); }
.comments-note {
  font-size: 0.8rem;
  color: var(--faint);
  font-style: italic;
  font-family: var(--sans);
}
.comments ol { list-style: none; padding: 0; margin: 0; }
.comments li { border-top: 1px dashed var(--line); padding: 0.9rem 0; }
.comments li:first-child { border-top: 0; }
.comments cite { font-style: normal; font-weight: 600; font-family: var(--sans); color: var(--ink); }
.comment-body { font-size: 0.98rem; }

/* Post + pagination navigation */
.post-nav,
.pagination-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.pagination-nav { border-top: 0; margin-top: 1rem; padding-top: 0; }
.post-nav a,
.pagination-nav a { text-decoration: none; }
.post-nav a:hover,
.pagination-nav a:hover { text-decoration: underline; }

/* Archive & term pages */
.count { color: var(--faint); font-size: 0.8em; font-weight: 400; font-family: var(--sans); }
/* Archive: title filter, topic chips, year accordions */
.filter-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  margin: 0.6rem 0 1.8rem;
}
.filter-input:focus { border-color: var(--accent); outline: none; }

.topics h2 {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin: 0 0 0.6rem;
}
.topic-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.topic-list li {
  font-family: var(--sans);
  font-size: 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.75rem;
}
.topic-list a { color: var(--ink); text-decoration: none; }
.topic-list a:hover { color: var(--accent); }
.topic-list .count { color: var(--faint); font-size: 0.75rem; margin-left: 0.35rem; }
.tags-row { margin: 0.2rem 0 2rem; }

.year-block { border-top: 1px solid var(--line); }
.year-block summary {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 0.15rem;
  font-family: var(--sans);
  user-select: none;
}
.year-block summary::-webkit-details-marker { display: none; }
.year-block summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}
.year-block[open] summary::before { transform: rotate(90deg); }
.year-num { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em; }
.filter-empty { font-family: var(--sans); color: var(--muted); font-style: italic; }
.archive-list { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.archive-list li { padding: 0.28rem 0; }
.archive-list time {
  display: inline-block;
  min-width: 5.2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: 2.2rem 0 3rem;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 1.6rem;
}
.site-footer h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin: 0 0 0.5rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0.32rem 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.colophon { margin-top: 2rem; color: var(--faint); font-size: 0.78rem; }

/* Utilities */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Search (Pagefind UI), tinted to match */
#search .pagefind-ui {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--ink);
  --pagefind-ui-background: var(--paper);
  --pagefind-ui-border: var(--line);
  --pagefind-ui-tag: var(--muted);
}

/* WordPress-era embeds, captions, and galleries */
.content figure.wp-caption { margin: 1.4rem 0; }
.content figure.wp-caption img { display: block; margin-inline: auto; }
.content figure.wp-caption.alignright { float: right; margin-left: 1.2rem; max-width: 45%; }
.content figure.wp-caption.alignleft { float: left; margin-right: 1.2rem; max-width: 45%; }
.content figure.wp-caption figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.4rem;
  font-family: var(--sans);
}
.content ul.wp-gallery {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.8rem;
}
.content ul.wp-gallery img { width: 100%; height: auto; display: block; }
.content audio, .content video { width: 100%; }

/* ---- Pagefind Component UI theming (style-isolated; --pf-* is the only entry) ---- */
:root {
  --pf-font: var(--sans);
  --pf-text: var(--ink);
  --pf-text-secondary: var(--muted);
  --pf-text-muted: var(--faint);
  --pf-background: var(--paper);
  --pf-border: var(--line);
  --pf-border-focus: var(--faint);
  --pf-mark: var(--accent);
  --pf-outline-focus: var(--accent);
  --pf-hover: color-mix(in srgb, var(--ink) 7%, var(--paper));
  --pf-heading-chip-border: var(--line);
  --pf-link: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --pf-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --pf-hover: #252220;
  }
}
