/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, video { display: block; max-width: 100%; height: auto; }
ul[class], ol[class] { list-style: none; }

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --c-bg:         #f8f8f6;
  --c-surface:    #ffffff;
  --c-border:     #e2e2de;
  --c-text:       #141414;
  --c-muted:      #6b6b6b;
  --c-faint:      #71716f;
  --c-accent:     #2880d9;
  --c-accent-dim: #ede9fe;
  --c-code-bg:    #f0efe9;

  --font: system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;

  --max-w:  680px;
  --pad-x:  clamp(1rem, 5vw, 2rem);
  --pad-y:  clamp(1.5rem, 6vw, 3rem);
}

/* ─── Base ───────────────────────────────────────────────── */
html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.7;
  padding: 0;
}

/* ─── Skip Link (a11y) ───────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--c-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 6px 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  z-index: 100;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ─── Layout ─────────────────────────────────────────────── */
.container { max-width: var(--max-w); margin-inline: auto; padding-inline: var(--pad-x); padding-bottom: var(--pad-y); margin-top: 2.5rem; }

/* ─── Site Header ────────────────────────────────────────── */
.site-header {
  background: #efeae7;
  display: block;
  padding: 0;
  margin: 0;
}

.site-header-inner {
  max-width: calc(var(--max-w) + 2 * var(--pad-x));
  margin-inline: auto;
  padding: 0.9375rem var(--pad-x);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.site-identity a {
  text-decoration: none;
  display: inline-block;
}
.site-identity a:hover .site-name { color: var(--c-accent); }

.site-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-text);
  transition: color 0.15s;
}

.site-tagline {
  font-size: 0.8125rem;
  color: #746666;
  margin-top: 0.2rem;
}

/* ─── Nav ────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.site-nav a {
  font-size: 0.8125rem;
  color: #7a6b6b;
  text-decoration: none;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--c-accent); }

.nav-icon-link { display: flex; align-items: center; padding: 1px; }
.nav-icon-link svg { display: block; }

/* ─── Section Label ──────────────────────────────────────── */
.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-faint);
  margin-bottom: 1.5rem;
}

/* ─── Post List ──────────────────────────────────────────── */
.post-list {
  list-style: none;
  border-top: 1px solid var(--c-border);
}
.post-list li { border-bottom: 1px solid var(--c-border); }

.post-list article a {
  display: block;
  padding: 1.375rem 2rem 1.375rem 0;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.post-meta time {
  display: block;
  font-family: var(--mono);
  font-size: 0.7875rem;
  color: var(--c-faint);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.post-title {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--c-text);
  transition: color 0.15s;
  margin-bottom: 0.4rem;
}
.post-list article a:hover .post-title { color: var(--c-accent); }

.post-desc {
  font-size: 1rem;
  color: var(--c-muted);
  line-height: 1.55;
}

.post-list article a::after {
  content: '\2192';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(0);
  color: var(--c-accent);
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.post-list article a:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(4px);
}

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
  font-size: 0.8rem;
  color: var(--c-faint);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.site-footer a { color: var(--c-muted); text-decoration: none; }
.site-footer a:hover { color: var(--c-accent); }

/* ─── Article Header ─────────────────────────────────────── */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--c-border);
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8rem;
  color: var(--c-muted);
  text-decoration: none;
  margin-bottom: 1.75rem;
  transition: color 0.15s;
}
.article-back:hover { color: var(--c-accent); }

.article-date {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--c-faint);
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.75rem;
}

.article-title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--c-text);
}

.article-lede {
  margin-top: 1rem;
  font-size: 1.0625rem;
  color: var(--c-muted);
  line-height: 1.65;
}

/* ─── Prose ──────────────────────────────────────────────── */
.prose { font-size: 1rem; line-height: 1.78; }
.prose > * + * { margin-top: 1.25rem; }

.prose h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0;
}
.prose h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0;
}
.prose h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  margin-top: 1.75rem;
  margin-bottom: 0;
}

.prose a {
  color: var(--c-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.prose a:hover { opacity: 0.75; }

.prose strong { font-weight: 600; }
.prose em { font-style: italic; }

.prose ul, .prose ol {
  padding-left: 1.5rem;
  list-style: revert;
}
.prose li + li { margin-top: 0.35rem; }

.prose blockquote {
  border-left: 3px solid var(--c-accent);
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--c-muted);
  font-style: italic;
}

/* Inline code */
.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--c-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--c-border);
}

/* Code blocks */
.prose pre {
  background: #17172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.65;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 1.5rem;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Images */
.prose img {
  border-radius: 6px;
  border: 1px solid var(--c-border);
}
.prose figure { margin: 0; }
.prose figcaption {
  font-size: 0.8rem;
  color: var(--c-faint);
  text-align: center;
  margin-top: 0.5rem;
}

/* ─── Callout blocks ─────────────────────────────────────── */
.callout {
  background: var(--c-accent-dim);
  border-left: 3px solid var(--c-accent);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  font-size: 0.9375rem;
}
.callout--warning {
  background: #fef9c3;
  border-color: #ca8a04;
}
.callout--tip {
  background: #f0fdf4;
  border-color: #16a34a;
}

.callout-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-accent);
  display: block;
  margin-bottom: 0.4rem;
}
.callout--warning .callout-label { color: #92400e; }
.callout--tip .callout-label { color: #15803d; }

/* ─── Focus ──────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }

  .site-header-inner { padding: 0.6875rem var(--pad-x); }

  .post-list article a { padding-right: 0; }
  .post-list article a::after { display: none; }

  .site-footer { flex-direction: column; }

  .prose pre {
    border-radius: 0;
    margin-inline: calc(-1 * var(--pad-x));
    padding-inline: var(--pad-x);
  }
}

/* ─── Print ──────────────────────────────────────────────── */
@media print {
  body { background: #fff; padding: 0; }
  .site-nav, .article-back, .site-footer, .skip-link { display: none; }
  .prose pre { background: #f5f5f5; color: #222; border: 1px solid #ccc; }
}
