@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400;1,9..144,600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');

/* ─── Design tokens — dark (default) ────────────────────── */
:root {
  --red:        #df0227;
  --red-dim:    #a8001c;
  --red-glow:   rgba(223,2,39,.12);
  --bg:         #0c0c0c;
  --bg-card:    #141414;
  --bg-code:    #181818;
  --text:       #d6d2ca;
  --text-muted: #6a6660;
  --text-dim:   #9a9690;
  --border:     #222222;
  --border-mid: #2c2c2c;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Newsreader', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
  --max-w:  800px;
  --wide-w: 980px;
}

/* ─── Light mode ─────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg:         #f7f4ef;
    --bg-card:    #ffffff;
    --bg-code:    #eeebe6;
    --text:       #1a1714;
    --text-muted: #6e6a64;
    --text-dim:   #4a4642;
    --border:     #dedad4;
    --border-mid: #ccc8c2;
    --red-glow:   rgba(223,2,39,.07);
  }
  code { color: #b30019; }
  pre code { color: #2d2420; }
  .tag { background: var(--bg); }
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-optical-sizing: auto;
  font-size: 1.12rem;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a   { color: var(--red); text-decoration: none; transition: color .2s; }
a:hover { color: #ff1a38; }

body::before {
  content: '';
  display: block;
  height: 3px;
  background: var(--red);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

/* ─── Editorial kicker (shared small-label style) ────────── */
.article-meta,
.video-embed-label,
.comments-heading,
.footer-links a,
nav.site-nav a,
.copy-btn,
.video-link,
.support-link {
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: .14em;
}

/* ─── Layout ─────────────────────────────────────────────── */
.container      { width: 100%; max-width: var(--max-w);  margin: 0 auto; padding: 0 1.5rem; }
.container-wide { width: 100%; max-width: var(--wide-w); margin: 0 auto; padding: 0 1.5rem; }
main { flex: 1; }

/* ─── Header ─────────────────────────────────────────────── */
header.site-header {
  padding: 2.5rem 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4rem;
}
.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
}
.site-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -.01em;
  color: var(--text);
  text-decoration: none;
  transition: color .2s;
}
.site-brand span { color: var(--red); }
.site-brand:hover { color: var(--red); }
nav.site-nav { display: flex; gap: 1.6rem; align-items: center; flex-wrap: wrap; }
nav.site-nav a {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .2s;
}
nav.site-nav a:hover { color: var(--red); }

/* ─── Home hero ──────────────────────────────────────────── */
.home-hero {
  padding: 3rem 0 4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4rem;
}
.home-hero .tagline {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 5.5vw, 4.2rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 1.25rem;
}
.home-hero .tagline em { font-style: italic; color: var(--red); }
.home-hero .lead {
  font-size: 1.2rem;
  color: var(--text-dim);
  line-height: 1.65;
}

/* ─── Post list ──────────────────────────────────────────── */
.post-list { list-style: none; }
.post-list-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0 2rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.post-list-item:first-child { border-top: 1px solid var(--border); }
.post-date {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding-top: .5rem;
}
.post-info h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: .4rem;
  line-height: 1.2;
}
.post-info h2 a { color: var(--text); text-decoration: none; transition: color .2s; }
.post-info h2 a:hover { color: var(--red); }
.post-summary { font-size: 1.02rem; color: var(--text-dim); line-height: 1.6; margin-bottom: .6rem; }
.post-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
  font-family: var(--font-body);
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .15rem .6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  border-radius: 2px;
  transition: border-color .2s, color .2s;
}
.tag:hover { border-color: var(--red); color: var(--red); }

/* ─── Single article ─────────────────────────────────────── */
.article-header {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.article-meta {
  font-size: .74rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem 1rem;
}
.article-meta .sep { color: var(--border-mid); }
.article-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.08;
  color: var(--text);
  margin-bottom: 1.25rem;
}
.article-description {
  font-family: var(--font-body);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.55;
  border-left: 3px solid var(--red);
  padding-left: 1.1rem;
}

/* ─── Article body ───────────────────────────────────────── */
.article-body h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.75rem; letter-spacing: -.01em; color: var(--text); margin-top: 2.75rem; margin-bottom: .8rem; line-height: 1.2; }
.article-body h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; letter-spacing: -.01em; color: var(--text); margin-top: 2rem; margin-bottom: .7rem; line-height: 1.3; }
.article-body h4 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--text-dim); margin-top: 1.5rem; margin-bottom: .5rem; }
.article-body p  { margin-bottom: 1.5rem; }
.article-body ul, .article-body ol { padding-left: 1.5rem; margin-bottom: 1.5rem; }
.article-body li { margin-bottom: .4rem; }
.article-body blockquote {
  border-left: 3px solid var(--red);
  padding: .8rem 1.2rem;
  margin: 2rem 0;
  background: var(--bg-card);
  color: var(--text-dim);
  font-style: italic;
  font-size: 1.15rem;
}
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 3rem 0; }
.article-body a { word-break: break-word; }

/* ─── Code ───────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: .82em;
  background: var(--bg-code);
  color: #e06c75;
  padding: .1em .4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.code-block-wrapper { position: relative; margin: 1.8rem 0; }

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red-dim);
  padding: 1.4rem 3.5rem 1.4rem 1.6rem;
  overflow-x: auto;
  border-radius: 4px;
  margin: 0;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: #abb2bf;
  font-size: .88rem;
  line-height: 1.65;
}
@media (prefers-color-scheme: light) { pre code { color: #2d2420; } }

.copy-btn {
  position: absolute;
  top: .6rem;
  right: .6rem;
  font-size: .62rem;
  font-weight: 500;
  padding: .3rem .7rem;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  line-height: 1;
  white-space: nowrap;
}
.copy-btn:hover { border-color: var(--red); color: var(--red); }
.copy-btn.copied { border-color: #2ecc71; color: #2ecc71; }

/* ─── Video ──────────────────────────────────────────────── */
.video-embed { margin: 2.5rem 0; }
.video-embed-label {
  font-size: .68rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.video-embed-label::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
}
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: #000;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

.video-links { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 2.5rem; }
.video-link {
  font-size: .72rem;
  font-weight: 500;
  padding: .45rem 1rem;
  border: 1px solid var(--border-mid);
  border-radius: 2px;
  color: var(--text-muted);
  text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
}
.video-link:hover { border-color: var(--red); color: var(--red); background: var(--red-glow); }

/* ─── Support / Ko-fi ────────────────────────────────────── */
.support-section {
  margin-top: 3.5rem;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.support-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.2rem;
  color: var(--text);
}
.support-link {
  font-size: .72rem;
  font-weight: 500;
  padding: .55rem 1.1rem;
  border: 1px solid var(--border-mid);
  border-radius: 2px;
  color: var(--text-muted);
  text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
}
.support-link:hover { border-color: var(--red); color: var(--red); background: var(--red-glow); }

/* Gentle, periodic attention cue — soft red glow + tiny cup wiggle.
   ~60% of each cycle is at rest, so it nudges rather than nags. */
.support-link {
  animation: kofi-attract 4.5s ease-in-out 2s infinite;
}
.kofi-cup {
  display: inline-block;
  animation: kofi-bob 4.5s ease-in-out 2s infinite;
}
@keyframes kofi-attract {
  0%, 60%, 100% { box-shadow: 0 0 0 0 rgba(223,2,39,0); }
  80%           { box-shadow: 0 0 14px 1px var(--red-glow); }
}
@keyframes kofi-bob {
  0%, 60%, 100% { transform: translateY(0) rotate(0); }
  70%           { transform: translateY(-2px) rotate(-7deg); }
  82%           { transform: translateY(-2px) rotate(6deg); }
  92%           { transform: translateY(0) rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  .support-link, .kofi-cup { animation: none; }
}

/* ─── Discourse ──────────────────────────────────────────── */
.comments-section { margin-top: 4rem; padding-top: 2.5rem; border-top: 1px solid var(--border); }
.comments-heading {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.comments-heading::after { content: ''; flex: 1; height: 1px; background: var(--border); }
#discourse-comments {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 100px;
  overflow: hidden;
}
#discourse-comments iframe { width: 100% !important; border: none !important; display: block; }

/* ─── Back link ──────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 2.5rem;
  transition: color .2s;
}
.back-link::before { content: '←'; font-style: normal; }
.back-link:hover { color: var(--red); }

/* ─── List pages ─────────────────────────────────────────── */
.list-header { margin-bottom: 3rem; }
.list-title { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.list-title span { color: var(--red); }

/* ─── Footer ─────────────────────────────────────────────── */
footer.site-footer { margin-top: 6rem; padding: 2.5rem 0; border-top: 1px solid var(--border); }
.footer-inner { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 1rem; }
.footer-copy { font-family: var(--font-body); font-size: .9rem; font-style: italic; color: var(--text-muted); }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { font-size: .72rem; font-weight: 500; color: var(--text-muted); text-decoration: none; transition: color .2s; }
.footer-links a:hover { color: var(--red); }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.post-list-item { animation: fadeUp .45s ease both; }
.post-list-item:nth-child(1) { animation-delay: .04s; }
.post-list-item:nth-child(2) { animation-delay: .09s; }
.post-list-item:nth-child(3) { animation-delay: .14s; }
.post-list-item:nth-child(4) { animation-delay: .19s; }
.post-list-item:nth-child(n+5){ animation-delay: .24s; }
.article-header { animation: fadeUp .45s ease both; }
.article-body   { animation: fadeUp .45s .08s ease both; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .post-list-item { grid-template-columns: 1fr; gap: .25rem; }
  .post-date { padding-top: 0; font-size: .68rem; }
  .header-inner { flex-direction: column; gap: .75rem; }
  .footer-inner { flex-direction: column; align-items: center; }
  nav.site-nav { gap: 1rem; }
  .copy-btn { display: none; }
  pre { padding-right: 1.6rem; }
}
