/* ============================================
   Alexander Nikolov — Blog
   Typography-first, clean editorial design
   ============================================ */

:root {
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #888;
  --bg: #fafaf8;
  --bg-code: #f2f0eb;
  --border: #ddd;
  --accent: #2a5a3a;
  --accent-hover: #1d4029;
  --tag-bg: #eef2ef;
  --max-width: 600px;
  --font-body: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.7;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Layout — constrain the Archie .content wrapper itself so header, main,
   and footer all share the same column width automatically. */
.content {
  max-width: var(--max-width);
}
main {
  padding: 2rem 0 4rem;
}

/* Visual separator between full posts on the homepage */
.list-item + .list-item {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

/* ---- Header ---- */
/* Override Archie's flex-wrap:wrap so title and nav stay on one line */
header {
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}
header .main {
  flex-shrink: 0;
}
/* Compact gap slightly so everything fits in 600px without changing text size */
header nav {
  font-size: 0.95rem;
  gap: 0.75rem;
  flex-shrink: 1;
}
header nav a {
  white-space: nowrap;
}

/* ---- Homepage ---- */
.intro {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.intro p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ---- Post previews ---- */
.post-preview {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.post-preview:last-child { border-bottom: none; }
.post-preview h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}
.post-preview h2 a {
  color: var(--text);
  text-decoration: none;
}
.post-preview h2 a:hover { color: var(--accent); }
.post-preview time {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.post-preview .summary {
  color: var(--text-secondary);
  margin: 0.5rem 0 0;
  font-size: 1rem;
}

/* ---- Homepage post titles ---- */
/* .post-header wraps titles on the homepage list; keep them
   below the blog title (1.5rem) so the hierarchy is clear */
.post-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

/* ---- Single post ---- */
/* single.html uses <div class="title"><h1> — different from homepage */
.title h1 {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.75rem;   /* zero top margin — Archie's h1 margin-top:2em
                             creates the excessive whitespace gap */
  letter-spacing: -0.01em;
}
.post-header {
  margin-bottom: 2rem;
}
.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
}
.post-tags {
  margin-top: 0.75rem;
}

/* Post content */
.post-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
}
.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
}
.post-content p {
  margin: 0 0 1.6rem;
}
.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.post-content a:hover {
  color: var(--accent-hover);
}

/* Blockquote */
.post-content blockquote {
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--accent);
  background: var(--bg-code);
  border-radius: 0 4px 4px 0;
  color: var(--text-secondary);
  font-style: italic;
}
.post-content blockquote p {
  margin: 0 0 0.5rem;
}
.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}
.post-content pre {
  background: var(--bg-code);
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 1.5rem 0;
}
.post-content pre code {
  background: none;
  padding: 0;
}
.post-content ul, .post-content ol {
  padding-left: 1.5rem;
}
.post-content li {
  margin-bottom: 0.35rem;
}
.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ---- Footnotes ---- */
/* Goldmark already renders an <hr> before the footnotes section;
   don't add a second line via border-top */
.footnotes {
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.footnotes ol {
  padding-left: 1.25rem;
}
.footnotes li {
  margin-bottom: 0.5rem;
}
.footnotes p {
  margin: 0;
}
/* Footnote reference in body text */
sup a[href^="#fn"] {
  font-size: 0.75em;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0 0.1em;
}
sup a[href^="#fn"]:hover {
  text-decoration: underline;
}
/* Back-to-text arrow in footnote */
a[href^="#fnref"] {
  font-size: 0.8em;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 0.25em;
}
a[href^="#fnref"]:hover {
  color: var(--accent);
}

/* Post navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  gap: 1rem;
}
.post-nav a {
  color: var(--accent);
  text-decoration: none;
  max-width: 48%;
}
.post-nav a:hover { text-decoration: underline; }
.post-nav-next { margin-left: auto; text-align: right; }

/* ---- Tags ---- */
.tag {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--tag-bg);
  padding: 0.15em 0.55em;
  border-radius: 3px;
  text-decoration: none;
  margin-right: 0.25rem;
}
.tag:hover {
  background: var(--accent);
  color: #fff;
}
.tag-small {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}
.tag-small:hover { color: var(--accent); }
.tag-small::before { content: "#"; }
.tags-page .tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- Archive ---- */
.archive-year h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.archive-entry {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  flex-wrap: wrap;
}
.archive-entry time {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 4rem;
  font-variant-numeric: tabular-nums;
}
.archive-entry a {
  color: var(--text);
  text-decoration: none;
}
.archive-entry a:hover { color: var(--accent); }
.tags-inline { margin-left: auto; }
.back-link {
  margin-top: 2rem;
  font-size: 0.9rem;
}
.back-link a {
  color: var(--accent);
  text-decoration: none;
}

/* ---- Search ---- */
.search-page {
  min-height: 50vh;
}
/* Pagefind UI overrides */
.pagefind-ui .pagefind-ui__search-input {
  font-family: var(--font-body) !important;
  font-size: 1rem !important;
  border-radius: 4px !important;
}

/* ---- Subscribe ---- */
.subscribe-box {
  margin-top: 1rem;
}
.subscribe-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.footer-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}
.footer-meta a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer-meta a:hover { color: var(--accent); }

/* ---- Comments ---- */
.comments {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.comments h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .post-header h1 { font-size: 1.6rem; }
  .site-header nav { padding: 1rem; }
  main { padding: 1.5rem 1rem 3rem; }
  .archive-entry { gap: 0.5rem; }
}