/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-font-smoothing: antialiased; }
img, video { max-width: 100%; display: block; }
input, button, textarea, select { font: inherit; }

/* ── Tokens ─────────────────────────────────────── */
:root {
  --bg: #FFFFFF;
  --bg-subtle: #FAFAFA;
  --text: #1A1A1A;
  --text-muted: #6B6B6B;
  --border: #E6E6E6;
  --accent: #1A1A1A;
  --accent-hover: #000000;
  --selection-bg: rgba(26,26,26,0.12);

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-h3: 1.375rem;
  --fs-h2: 1.75rem;
  --fs-h1: 2.5rem;
  --fs-display: 3.25rem;

  --s-1: 4px;  --s-2: 8px;   --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px;  --s-7: 48px; --s-8: 64px; --s-9: 96px;

  --max-content: 680px;
  --max-site: 1200px;
  --header-height: 64px;
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-subtle: #1C1C1C;
  --text: #E8E8E8;
  --text-muted: #A0A0A0;
  --border: #2A2A2A;
  --accent: #E8E8E8;
  --accent-hover: #FFFFFF;
  --selection-bg: rgba(232,232,232,0.15);
}

/* ── Typography ─────────────────────────────────── */
@font-face {
  font-family: 'Newsreader';
  src: url('/assets/fonts/newsreader/files/newsreader-latin-300-normal.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/assets/fonts/newsreader/files/newsreader-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/assets/fonts/newsreader/files/newsreader-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/assets/fonts/newsreader/files/newsreader-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/inter/files/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900; font-style: normal; font-display: swap;
}

body {
  font-family: 'Newsreader', Georgia, serif;
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}

::selection { background: var(--selection-bg); }

h1, h2, h3, h4, h5, h6 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  color: var(--text);
}
h1 { font-size: var(--fs-h1); line-height: 1.2; }
h2 { font-size: var(--fs-h2); line-height: 1.3; margin-top: var(--s-7); margin-bottom: var(--s-4); }
h3 { font-size: var(--fs-h3); line-height: 1.4; margin-top: var(--s-6); margin-bottom: var(--s-3); }

p { margin-bottom: var(--s-5); }

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

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}
pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--s-5);
  overflow-x: auto;
  margin-bottom: var(--s-5);
}
:not(pre) > code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 5px;
}
blockquote {
  border-left: 3px solid var(--text-muted);
  padding-left: var(--s-5);
  color: var(--text-muted);
  font-style: italic;
  margin: var(--s-6) 0;
}
ul, ol { padding-left: var(--s-6); margin-bottom: var(--s-5); }
li { margin-bottom: var(--s-2); }
hr { border: none; border-top: 1px solid var(--border); margin: var(--s-7) 0; }
img { border-radius: 4px; }

/* ── Layout ─────────────────────────────────────── */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  background: var(--bg); color: var(--text);
  padding: var(--s-3) var(--s-4); z-index: 999;
}
.skip-link:focus { left: var(--s-4); top: var(--s-4); }

.site-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; }

.container {
  width: 100%;
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 var(--s-5);
}
.container--narrow { max-width: var(--max-content); margin: 0 auto; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  width: 100%;
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 var(--s-5);
}
.site-logo {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: var(--fs-lg);
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  list-style: none;
  padding: 0;
}
.site-nav a {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--text); }
.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-left: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--s-7) 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-5);
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 var(--s-5);
}
.site-footer__brand { font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: var(--fs-base); color: var(--text); }
.site-footer__tagline { font-size: var(--fs-xs); margin-top: var(--s-1); }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: var(--s-4); list-style: none; padding: 0; }
.site-footer__nav a { color: var(--text-muted); text-decoration: none; }
.site-footer__nav a:hover { color: var(--text); }

/* Page sections */
.page-hero { padding: var(--s-9) 0 var(--s-7); border-bottom: 1px solid var(--border); }
.page-hero__eyebrow {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-4);
}
.page-hero__title { font-size: var(--fs-display); font-weight: 300; line-height: 1.1; }
.page-section { padding: var(--s-7) 0; }

/* Article */
.article-header { padding: var(--s-8) 0 var(--s-6); }
.article-title { font-size: var(--fs-h1); font-weight: 500; line-height: 1.2; margin-bottom: var(--s-5); }
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.article-meta__sep { color: var(--border); }
.article-body { padding-bottom: var(--s-8); }
.article-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; margin-bottom: var(--s-7); border-radius: 4px; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-7) 0;
  border-top: 1px solid var(--border);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.pagination a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  padding: var(--s-2) var(--s-4);
  border-radius: 2px;
  transition: border-color 0.15s;
}
.pagination a:hover { border-color: var(--text); }

/* ── Components ─────────────────────────────────── */

/* Buttons */
.btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-5);
  border: 1px solid var(--text);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--text); color: var(--bg); }
.btn--icon {
  border: none;
  padding: var(--s-2);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.btn--icon:hover { color: var(--text); }

/* Post list */
.post-list { display: flex; flex-direction: column; }

/* Post card */
.post-card { padding: var(--s-6) 0; border-bottom: 1px solid var(--border); }
.post-card__title {
  display: block;
  font-family: 'Newsreader', Georgia, serif;
  font-size: var(--fs-h3);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
  margin-bottom: var(--s-2);
}
.post-card__title:hover { color: var(--accent-hover); }
.post-card__excerpt {
  font-size: var(--fs-base);
  color: var(--text-muted);
  margin-bottom: var(--s-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Tags */
.tag {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-xs);
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px var(--s-3);
  border-radius: 100px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.tag:hover { color: var(--text); border-color: var(--text-muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; padding: 0; }

/* Share row */
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-5) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: var(--s-6) 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-sm);
}
.share-row__label { color: var(--text-muted); }

/* Related posts */
.related-posts { margin-top: var(--s-7); }
.related-posts__heading {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--s-5);
}
.related-posts__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-5); }
.related-card { padding: var(--s-4); border: 1px solid var(--border); border-radius: 4px; }
.related-card__title {
  display: block;
  font-family: 'Newsreader', Georgia, serif;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  margin-bottom: var(--s-2);
  line-height: 1.4;
}
.related-card__title:hover { color: var(--accent-hover); }
.related-card__meta { font-family: 'Inter', system-ui, sans-serif; font-size: var(--fs-xs); color: var(--text-muted); }

/* Search modal */
.search-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: var(--s-8);
}
.search-modal.is-open { display: flex; }
.search-modal__inner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  max-width: 600px;
  padding: var(--s-5);
  margin: 0 var(--s-5);
}
.search-modal__close {
  display: block;
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0 var(--s-3);
  line-height: 1;
}
.search-modal__close:hover { color: var(--text); }

/* Pagefind overrides */
:root {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--text);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-border-radius: 2px;
  --pagefind-ui-font: Inter, system-ui, sans-serif;
}

/* Theme toggle */
.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: var(--s-2);
  display: flex; align-items: center; border-radius: 2px;
  transition: color 0.15s;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Hamburger */
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: var(--s-2);
  align-items: center;
}

/* Comments */
.comments-section { margin-top: var(--s-8); padding-top: var(--s-6); border-top: 1px solid var(--border); }
.comments-section__heading {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--s-6);
}

/* Tags page */
.tags-grid { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-5); }

/* Page prose */
.prose h1 { margin-bottom: var(--s-6); }
.prose p + h2, .prose p + h3 { margin-top: var(--s-7); }

/* 404 */
.not-found { padding: var(--s-9) 0; text-align: center; }
.not-found__code {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 6rem;
  font-weight: 600;
  color: var(--border);
  line-height: 1;
  margin-bottom: var(--s-5);
}
.not-found__title { font-size: var(--fs-h2); margin-bottom: var(--s-4); }
.not-found__text { color: var(--text-muted); margin-bottom: var(--s-6); }

/* Responsive */
@media (max-width: 768px) {
  .site-nav {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    flex-direction: column;
    padding: var(--s-8) var(--s-5);
    gap: var(--s-6);
    align-items: flex-start;
  }
  .site-nav.is-open { display: flex; }
  .hamburger { display: flex; }
  .page-hero__title { font-size: var(--fs-h1); }
  .article-title { font-size: var(--fs-h2); }
  .related-posts__grid { grid-template-columns: 1fr; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}