/* ============================================================
   BlogForge — public/css/style.css
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --accent:    #ff9900;
  --accent-d:  #cc7a00;
  --bg:        #0d0d0d;
  --bg-card:   #161616;
  --bg-input:  #1f1f1f;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --text-muted:#888;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --font-head: 'DM Serif Display', serif;
  --font-body: 'DM Sans', sans-serif;
  --max-w:     1100px;
  --transition: .25s ease;
}
[data-theme="light"] {
  --bg:        #f7f5f0;
  --bg-card:   #ffffff;
  --bg-input:  #f0ede8;
  --border:    #e0dcd6;
  --text:      #1a1a1a;
  --text-muted:#666;
  --shadow:    0 4px 24px rgba(0,0,0,.1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 1rem;
  transition: background var(--transition), color var(--transition);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-d); }
button { cursor: pointer; font-family: inherit; }

/* ── Utility ───────────────────────────────────────────────── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.25rem; }
.sr-only { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

/* ── Flash ─────────────────────────────────────────────────── */
.flash {
  padding: .85rem 1.25rem;
  margin: 1rem auto;
  max-width: var(--max-w);
  border-radius: var(--radius);
  font-weight: 500;
  animation: fadeIn .3s ease;
}
.flash--success { background: #0d3320; color: #4ade80; border-left: 4px solid #4ade80; }
.flash--error   { background: #3a0d0d; color: #f87171; border-left: 4px solid #f87171; }
.flash--warning { background: #3a2800; color: #fbbf24; border-left: 4px solid #fbbf24; }
@keyframes fadeIn { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:none } }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,13,13,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .85rem 0;
  transition: background var(--transition);
}
[data-theme="light"] .site-header { background: rgba(247,245,240,.92); }

.header-inner {
  display: flex; align-items: center; gap: 1.5rem;
}
.logo {
  font-family: var(--font-head);
  font-size: 1.45rem;
  color: var(--text);
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.logo:hover { color: var(--accent); }

.site-nav {
  display: flex; align-items: center; gap: 1.5rem; margin-left: auto;
}
.site-nav a {
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  transition: color var(--transition);
}
.site-nav a:hover { color: var(--text); }

.nav-search {
  display: flex; align-items: center;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden; padding: 0 .5rem 0 .85rem;
}
.nav-search input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: .85rem; width: 140px;
  padding: .35rem 0;
}
.nav-search button {
  background: none; border: none; color: var(--accent);
  font-size: 1rem; padding: 0 .3rem;
}

.theme-toggle {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 50%; width: 36px; height: 36px;
  font-size: 1rem; color: var(--text); flex-shrink: 0;
  transition: background var(--transition);
}
.theme-toggle:hover { background: var(--border); }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; padding: .25rem;
}
.nav-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--transition); }

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  padding: 5rem 0 3.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: .75rem;
}
.hero h1 span { color: var(--accent); }
.hero p { color: var(--text-muted); font-size: 1.1rem; }

/* ── Grid ──────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem;
  padding: 3rem 0;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.card-img {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
}
.card-img-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--bg-input) 0%, var(--border) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text-muted);
}
.card-body { padding: 1.4rem; flex: 1; display: flex; flex-direction: column; }
.card-meta {
  display: flex; align-items: center; gap: .75rem;
  font-size: .78rem; color: var(--text-muted); margin-bottom: .6rem;
}
.card-cat {
  background: var(--accent); color: #000;
  border-radius: 4px; padding: .15rem .55rem;
  font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em;
}
.card h2 {
  font-family: var(--font-head);
  font-size: 1.25rem; line-height: 1.3;
  letter-spacing: -.02em; margin-bottom: .6rem;
}
.card h2 a { color: var(--text); }
.card h2 a:hover { color: var(--accent); }
.card p { color: var(--text-muted); font-size: .9rem; flex: 1; }
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--text-muted);
}
.read-more {
  color: var(--accent); font-weight: 600; font-size: .85rem;
  display: inline-flex; align-items: center; gap: .3rem;
}
.read-more:hover { color: var(--accent-d); }

/* ── Single post ───────────────────────────────────────────── */
.post-wrap { max-width: 740px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.post-hero-img {
  width: 100%; max-height: 460px; object-fit: cover;
  border-radius: var(--radius); margin-bottom: 2rem;
}
.post-header { margin-bottom: 2rem; }
.post-header h1 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.2; letter-spacing: -.03em; margin-bottom: .75rem;
}
.post-meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--text-muted); font-size: .85rem; align-items: center; }
.post-content { font-size: 1.05rem; line-height: 1.9; }
.post-content h2,.post-content h3 { font-family: var(--font-head); margin: 2rem 0 .75rem; }
.post-content p  { margin-bottom: 1.25rem; }
.post-content a  { color: var(--accent); text-decoration: underline; }
.post-content ul,.post-content ol { margin: 1rem 0 1.25rem 1.5rem; }
.post-content li { margin-bottom: .4rem; }
.post-content blockquote {
  border-left: 4px solid var(--accent); padding: .75rem 1.25rem;
  color: var(--text-muted); font-style: italic;
  background: var(--bg-card); border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
}
.post-content code {
  background: var(--bg-input); padding: .15rem .4rem;
  border-radius: 4px; font-size: .9em; font-family: monospace;
}
.post-content pre {
  background: var(--bg-input); padding: 1.25rem;
  border-radius: var(--radius); overflow-x: auto;
  margin: 1.5rem 0; border: 1px solid var(--border);
}
.post-content pre code { background: none; padding: 0; }
.post-content img { border-radius: var(--radius); margin: 1.5rem 0; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex; gap: .5rem; justify-content: center;
  padding: 1.5rem 0 3rem; flex-wrap: wrap;
}
.pagination a, .pagination span {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: .9rem; font-weight: 500;
  transition: var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); border-color: var(--accent); color: #000; }
.pagination .dots { border: none; pointer-events: none; }

/* ── Forms (public) ────────────────────────────────────────── */
.form-wrap {
  max-width: 640px; margin: 3rem auto 4rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem;
}
.form-wrap h1 { font-family: var(--font-head); margin-bottom: 1.75rem; font-size: 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .45rem; color: var(--text-muted); }
.form-group input,.form-group textarea,.form-group select {
  width: 100%;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: .7rem 1rem; font-size: .95rem; font-family: inherit;
  transition: border-color var(--transition);
}
.form-group input:focus,.form-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 140px; }
.form-error { color: #f87171; font-size: .8rem; margin-top: .3rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.75rem; border-radius: var(--radius);
  font-weight: 600; font-size: .9rem; border: none;
  cursor: pointer; transition: var(--transition);
}
.btn-primary {
  background: var(--accent); color: #000;
}
.btn-primary:hover { background: var(--accent-d); }
.btn-outline {
  background: none; border: 1px solid var(--border); color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── About ─────────────────────────────────────────────────── */
.about-wrap { max-width: 720px; margin: 3rem auto 4rem; padding: 0 1.25rem; }
.about-wrap h1 { font-family: var(--font-head); font-size: 2.5rem; margin-bottom: 1.5rem; }
.about-wrap p { color: var(--text-muted); margin-bottom: 1.25rem; font-size: 1.05rem; }

/* ── Search results ────────────────────────────────────────── */
.search-header { padding: 2.5rem 0 0; }
.search-header h2 { font-family: var(--font-head); font-size: 1.75rem; }
.search-header p { color: var(--text-muted); margin-top: .4rem; }

/* ── 404 ───────────────────────────────────────────────────── */
.error-page {
  text-align: center; padding: 6rem 1.25rem;
}
.error-page h1 { font-family: var(--font-head); font-size: 6rem; color: var(--accent); line-height: 1; }
.error-page p  { color: var(--text-muted); margin: 1rem 0 2rem; font-size: 1.1rem; }

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: .85rem;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.footer-inner p { color: var(--text-muted); }
.footer-nav { display: flex; gap: 1.25rem; }
.footer-nav a { color: var(--text-muted); }
.footer-nav a:hover { color: var(--accent); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle { display: flex; margin-left: auto; }
  .theme-toggle { order: 99; }

  .site-nav {
    display: none; flex-direction: column; gap: 1rem;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 1.25rem; z-index: 200;
  }
  .site-nav.open { display: flex; }
  .nav-search input { width: 100%; }
  .posts-grid { grid-template-columns: 1fr; }
  .form-wrap { padding: 1.75rem 1.25rem; }
  .footer-inner { flex-direction: column; text-align: center; }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.card { animation: slideUp .4s ease both; }
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:nth-child(5) { animation-delay: .24s; }
.card:nth-child(6) { animation-delay: .30s; }
