/* ──────────────────────────────────────────────────────────────────────────────
   Scroll Blog CMS — Public Frontend Styles
   Dark theme, standalone
────────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --border:   #30363d;
  --text:     #c9d1d9;
  --heading:  #e6edf3;
  --muted:    #8b949e;
  --accent:   #f0a500;
  --link:     #58a6ff;
  --success:  #3fb950;
  --danger:   #f85149;
  --max-w:    720px;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.75;
}

/* ── Site header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.site-brand {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex-shrink: 0;
}
.brand-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
}
.brand-tagline {
  font-size: 0.68rem;
  color: var(--muted);
  font-style: italic;
  font-family: inherit;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.site-nav a {
  padding: 5px 12px;
  color: var(--text);
  text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.88rem;
  border-radius: 5px;
  transition: background .12s, color .12s;
}
.site-nav a:hover { background: var(--surface); color: var(--heading); }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  margin-left: auto;
}

/* ── Main ────────────────────────────────────────────────────────────────────── */
.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

/* ── Post card grid ──────────────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.post-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-thumb { display: block; aspect-ratio: 16/9; overflow: hidden; }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.post-card:hover .post-thumb img { transform: scale(1.03); }
.post-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.post-meta {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.sep { color: var(--border); }
.cat-link { color: var(--accent) !important; text-decoration: none; }
.cat-link:hover { text-decoration: underline; }
.post-title { font-family: inherit; font-size: 1.1rem; line-height: 1.4; margin-top: 4px; }
.post-title a { color: var(--heading); text-decoration: none; }
.post-title a:hover { color: var(--accent); }
.post-excerpt {
  font-size: 0.9rem;
  color: var(--muted);
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.read-more {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.83rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  align-self: flex-start;
}
.read-more:hover { text-decoration: underline; }

/* ── Single post ─────────────────────────────────────────────────────────────── */
.single-post { max-width: var(--max-w); margin: 0 auto; }
.post-header { margin-bottom: 32px; }
.post-heading {
  font-size: 2rem;
  line-height: 1.3;
  color: var(--heading);
  margin: 12px 0 8px;
}
.post-lead {
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 12px;
}
.post-featured-img { margin-top: 20px; border-radius: 8px; overflow: hidden; }
.post-featured-img img { width: 100%; display: block; }
.post-body {
  font-size: 1.05rem;
  line-height: 1.85;
}
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  color: var(--heading);
  margin: 1.6em 0 .6em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.post-body p { margin: 1em 0; }
.post-body a { color: var(--link); }
.post-body a:hover { color: var(--accent); }
.post-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 8px 16px;
  margin: 1.2em 0;
  color: var(--muted);
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}
.post-body code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
.post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 1.2em 0;
}
.post-body img { max-width: 100%; border-radius: 6px; }
.post-body ul, .post-body ol { padding-left: 1.6em; margin: 1em 0; }
.post-body li { margin: .3em 0; }

/* Tags */
.post-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.tag-chip {
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--muted);
  text-decoration: none;
  transition: border-color .12s, color .12s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Prev / Next */
.post-prevnext {
  display: flex;
  gap: 16px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.prevnext-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.prevnext-item.right { text-align: right; align-items: flex-end; }
.prevnext-item .label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.prevnext-item a { font-size: 0.9rem; color: var(--link); text-decoration: none; }
.prevnext-item a:hover { color: var(--accent); }

/* Related posts */
.related-posts { margin-top: 48px; max-width: var(--max-w); margin-left: auto; margin-right: auto; }
.related-posts h3 {
  color: var(--heading);
  font-size: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.posts-grid--small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.post-card--small .post-thumb { aspect-ratio: 16/9; }
.post-card--small .post-card-body h4 { font-size: 0.9rem; }
.post-card--small .post-card-body h4 a { color: var(--text); text-decoration: none; }
.post-card--small .post-card-body h4 a:hover { color: var(--accent); }
.post-card--small time { font-size: 0.75rem; color: var(--muted); font-family: -apple-system, sans-serif; }

/* ── Archive header ───────────────────────────────────────────────────────────── */
.archive-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.archive-label {
  font-family: -apple-system, sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}
.archive-header h1 { color: var(--heading); font-size: 1.8rem; }
.archive-desc { color: var(--muted); margin-top: 8px; }

/* ── Search ──────────────────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.search-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-family: -apple-system, sans-serif;
  outline: none;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
  padding: 10px 20px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.search-form button:hover { background: #d4940b; }
.search-info { font-size: 0.88rem; color: var(--muted); margin-top: 8px; font-family: -apple-system, sans-serif; }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 32px;
  flex-wrap: wrap;
}
.page-link {
  display: inline-block;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: -apple-system, sans-serif;
  text-decoration: none;
  transition: all .12s;
}
.page-link:hover, .page-link.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* ── 404 / error page ────────────────────────────────────────────────────────── */
.error-page {
  text-align: center;
  padding: 80px 20px;
}
.error-code { font-size: 6rem; font-weight: 900; color: var(--border); line-height: 1; }
.error-msg { color: var(--muted); margin: 16px 0 24px; font-size: 1.1rem; }
.btn-accent {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  font-family: -apple-system, sans-serif;
}
.btn-accent:hover { background: #d4940b; }

/* ── Empty message ───────────────────────────────────────────────────────────── */
.empty-msg { color: var(--muted); font-style: italic; padding: 40px 0; text-align: center; font-family: -apple-system, sans-serif; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-inner p { color: var(--muted); font-size: 0.82rem; }
.footer-links { display: flex; gap: 12px; }
.footer-links a { color: var(--muted); font-size: 0.82rem; text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner { gap: 12px; }
  .site-nav { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 0; }
  .site-nav.open { display: flex; }
  .nav-toggle { display: block; }
  .post-heading { font-size: 1.5rem; }
  .post-prevnext { flex-direction: column; }
}
