/* ════════════════════════════════════════════════════════════════════
   site-engine — style.css
   Mobile-first, system fonts, dark mode, no frameworks
   ════════════════════════════════════════════════════════════════════ */

/* ── Utilities ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Page scaffolding ───────────────────────────────────────────── */
.page-hero {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.page-title { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; line-height: 1.2; }
.page-subtitle { color: var(--muted); margin-top: .5rem; font-size: 1rem; }

.page-header { margin-bottom: 2rem; }
.page-header .page-title { font-size: clamp(1.4rem, 3vw, 2rem); }

.section-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .5rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; text-decoration: none; }

/* ── Category nav pills ─────────────────────────────────────────── */
.category-nav {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 2rem;
}
.cat-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.cat-pill:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none; }
.cat-count { color: var(--muted); font-size: .75rem; }
.cat-pill:hover .cat-count { color: rgba(255,255,255,.8); }

/* ── Tags ───────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: .15rem .55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .8rem;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s;
}
.tag:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none; }

/* ── Post grid (homepage, category, tag) ────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}
@media (min-width: 600px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .post-grid { grid-template-columns: repeat(3, 1fr); }
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.post-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.card-img-link { display: block; overflow: hidden; aspect-ratio: 16/9; }
.card-img-link img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.post-card:hover .card-img-link img { transform: scale(1.04); }

.card-body { padding: 1rem; display: flex; flex-direction: column; flex: 1; }
.card-category {
  font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--primary); margin-bottom: .35rem;
  text-decoration: none;
}
.card-category:hover { text-decoration: underline; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: .5rem; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--primary); }
.card-excerpt {
  font-size: .9rem; color: var(--muted); line-height: 1.5;
  flex: 1; margin-bottom: .75rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--muted);
  margin-top: auto;
}
.card-tags { display: flex; flex-wrap: wrap; gap: .25rem; }

/* ── Post list (search results) ─────────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 1.5rem; }
.post-row {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.post-row:last-child { border-bottom: none; }

/* ── Article page ───────────────────────────────────────────────── */
.article { max-width: 720px; }

.article-header { margin-bottom: 1.5rem; }
.article-category {
  font-size: .85rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--primary); text-decoration: none;
}
.article-category:hover { text-decoration: underline; }

.article-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700; line-height: 1.25;
  margin: .5rem 0 1rem;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: .75rem;
  font-size: .9rem; color: var(--muted);
  margin-bottom: .75rem;
}
.article-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.article-cover {
  margin: 1.5rem 0;
  border-radius: 8px; overflow: hidden;
}
.article-cover img { width: 100%; border-radius: 8px; }

/* Article body typography */
.article-body { color: var(--text); text-align: justify; hyphens: auto; }
.article-body h2 { font-size: 1.5rem; font-weight: 700; margin: 2rem 0 .75rem; line-height: 1.3; }
.article-body h3 { font-size: 1.2rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.article-body h4 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 .4rem; }
.article-body p { margin-bottom: 1.25rem; }
.article-body ul, .article-body ol { margin: 0 0 1.25rem 1.5rem; }
.article-body li { margin-bottom: .4rem; }
.article-body blockquote {
  border-left: 4px solid var(--primary);
  padding: .75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-style: italic;
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}
.article-body pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem 1.25rem;
  overflow-x: auto; margin-bottom: 1.25rem;
  font-size: .9rem; line-height: 1.5;
}
.article-body code {
  background: var(--surface); padding: .15em .4em;
  border-radius: 3px; font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.article-body pre code { background: none; padding: 0; font-size: inherit; }
.article-body img {
  border-radius: 6px; margin: 1.25rem 0;
}
.article-body table {
  width: 100%; border-collapse: collapse; margin-bottom: 1.25rem;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: .5rem .75rem; text-align: left;
}
.article-body th { background: var(--surface); font-weight: 600; }
.article-body a { text-decoration: underline; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.25rem; margin-bottom: .75rem; }
.footer-links a { color: var(--muted); font-size: .9rem; }
.footer-links a:hover { color: var(--primary); }
.footer-copy { color: var(--muted); font-size: .85rem; }
/* ── Article TOC ────────────────────────────────────────────────── */
.article-toc {
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  background: var(--surface); border-radius: 8px;
  border-left: 3px solid var(--primary); font-size: .9rem;
}
.toc-title {
  display: block; margin-bottom: .5rem;
  font-size: .85rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.article-toc ol { margin: 0; padding-left: 1.25rem; }
.article-toc li { margin-bottom: .25rem; }
.article-sections { display: none; }

.article-footer { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.article-tags-footer { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }

/* ── Breadcrumbs ────────────────────────────────────────────────── */
.breadcrumbs { margin-bottom: 1.25rem; }
.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap;
  gap: .25rem; align-items: center;
  font-size: .875rem; color: var(--muted);
}
.breadcrumbs li + li::before { content: "›"; margin-right: .25rem; color: var(--border); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 500; }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: .4rem;
  margin: 2.5rem 0;
}
.page-numbers { display: flex; gap: .3rem; align-items: center; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.2rem; height: 2.2rem; padding: 0 .6rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: .9rem; color: var(--text); text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.page-link:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none; }
.page-link.page-current {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600;
}
.page-link.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.page-ellipsis { color: var(--muted); padding: 0 .25rem; }

/* ── Search page ────────────────────────────────────────────────── */
.search-form-full {
  display: flex; gap: .5rem; margin: 1.5rem 0;
}
.search-form-full input {
  flex: 1; padding: .6rem 1rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 1rem; background: var(--surface); color: var(--text);
}
.search-form-full input:focus {
  outline: 2px solid var(--primary); border-color: transparent;
}
.search-summary { color: var(--muted); margin-bottom: 1.5rem; }
.search-snippet { font-size: .9rem; color: var(--muted); margin: .4rem 0 .6rem; }
.search-snippet mark { background: rgba(37,99,235,.15); color: var(--primary); border-radius: 2px; }

/* ── Related posts ──────────────────────────────────────────────── */
.related-posts { margin: 2.5rem 0 1.5rem; padding-top: 2rem; border-top: 2px solid var(--border); }
.related-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.related-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; text-decoration: none; color: inherit;
  transition: box-shadow .2s, transform .2s;
}
.related-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.related-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.related-card-body { padding: .75rem; flex: 1; }
.related-card-title { font-size: .95rem; font-weight: 600; line-height: 1.4; margin-bottom: .35rem; text-align: left; }
.related-card-excerpt { font-size: .8rem; color: var(--muted); line-height: 1.4; text-align: left; }

/* ── 404 & error page ───────────────────────────────────────────── */
.error-page {
  text-align: center; padding: 5rem 0 3rem;
}
.error-code {
  font-size: 8rem; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--primary, #2563eb), #60a5fa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.error-title { font-size: 2rem; font-weight: 700; margin: .75rem 0 1rem; }
.error-desc { color: var(--muted); margin-bottom: 2rem; max-width: 36rem; margin-left: auto; margin-right: auto; }
.error-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.recent-posts { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 2rem; }
.recent-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.recent-item {
  display: flex; align-items: center; gap: .75rem;
}
.recent-item img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 6px; flex-shrink: 0;
}
.recent-item a { font-weight: 500; display: block; }
.recent-date { font-size: .8rem; color: var(--muted); display: block; }

/* ── Empty state ────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 0; color: var(--muted);
}
.empty-state .btn { margin-top: 1rem; }
