/* Rasepi Blog — Dark-first theme aligned with marketing design system */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --brand: #22C55E;
  --brand-light: #4ADE80;
  --brand-pale: rgba(34,197,94,0.10);
  --brand-glow: rgba(34,197,94,0.15);
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-display: "DM Serif Display", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --r: 12px;
  --r-lg: 20px;
  --r-pill: 999px;
}

/* Dark theme (default) */
[data-theme="dark"] {
  --bg: #0C0E14;
  --bg-warm: #12141C;
  --surface: #181B25;
  --surface-hover: #1F2230;
  --border: #2A2D3A;
  --border-light: #22252F;
  --text: #E8E9ED;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --navy: #F1F2F5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --nav-bg: rgba(12,14,20,0.92);
  --code-bg: #1a1d28;
}

/* Light theme */
[data-theme="light"] {
  --bg: #FAFAF8;
  --bg-warm: #F5F3EF;
  --surface: #FFFFFF;
  --surface-hover: #F7F7F5;
  --border: #E2E0DC;
  --border-light: #EEECE8;
  --text: #1A1A2E;
  --text-secondary: #4A5568;
  --text-muted: #94A3B8;
  --navy: #0F1B2D;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --nav-bg: rgba(255,255,255,0.92);
  --code-bg: #F5F3EF;
}

/* System preference fallback (no explicit theme chosen) */
:root:not([data-theme]) {
  --bg: #FAFAF8;
  --bg-warm: #F5F3EF;
  --surface: #FFFFFF;
  --surface-hover: #F7F7F5;
  --border: #E2E0DC;
  --border-light: #EEECE8;
  --text: #1A1A2E;
  --text-secondary: #4A5568;
  --text-muted: #94A3B8;
  --navy: #0F1B2D;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --nav-bg: rgba(255,255,255,0.92);
  --code-bg: #F5F3EF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0C0E14;
    --bg-warm: #12141C;
    --surface: #181B25;
    --surface-hover: #1F2230;
    --border: #2A2D3A;
    --border-light: #22252F;
    --text: #E8E9ED;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --navy: #F1F2F5;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --nav-bg: rgba(12,14,20,0.92);
    --code-bg: #1a1d28;
    color-scheme: dark;
  }
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-body); font-weight: 600; font-size: 15px; border-radius: var(--r); padding: 12px 24px; cursor: pointer; transition: all .2s ease; white-space: nowrap; border: none; text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); transform: translateY(-1px); box-shadow: 0 4px 20px var(--brand-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--brand); }

/* ── Nav ─────────────────────────────────────────────────────── */
.nav { position: fixed; top: 0; left: 0; z-index: 100; width: 100%; background: var(--nav-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid transparent; transition: border-color .3s ease, box-shadow .3s ease, background .3s ease; }
.nav--scrolled { border-bottom-color: var(--border); box-shadow: 0 1px 8px rgba(0,0,0,0.08); }
.nav-pill { display: flex; align-items: center; max-width: 1200px; margin: 0 auto; padding: 12px 24px; }
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-img { height: 28px; width: auto; display: block; }
[data-theme="dark"] .logo-img--light { display: none; }
[data-theme="dark"] .logo-img--dark { display: block; }
[data-theme="light"] .logo-img--light { display: block; }
[data-theme="light"] .logo-img--dark { display: none; }
/* No explicit theme: follow system preference */
:root:not([data-theme]) .logo-img--dark { display: none; }
:root:not([data-theme]) .logo-img--light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .logo-img--light { display: none; }
  :root:not([data-theme]) .logo-img--dark { display: block; }
}
.nav-links { display: flex; align-items: center; gap: 4px; margin-left: 32px; list-style: none; }
.nav-links a { font-size: 14px; font-weight: 500; color: var(--text-secondary); padding: 8px 14px; border-radius: var(--r-pill); transition: all .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--brand); background: var(--brand-pale); }
.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
.nav-actions .btn-primary { border-radius: var(--r-pill); padding: 9px 20px; font-size: 14px; }
.nav-hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-hamburger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: background .3s; }

/* ── Theme Toggle ────────────────────────────────────────────── */
.theme-toggle { background: var(--surface); border: 1px solid var(--border); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; transition: all .2s; color: var(--text-secondary); }
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
/* No explicit theme: follow system preference for toggle icon */
:root:not([data-theme]) .icon-sun { display: none; }
:root:not([data-theme]) .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: block; }
  :root:not([data-theme]) .icon-moon { display: none; }
}

/* ── Blog Index ──────────────────────────────────────────────── */
.blog-hero { padding: 140px 0 60px; text-align: center; }
.blog-hero h1 { font-family: var(--font-display); font-size: clamp(36px,4.5vw,52px); color: var(--navy); margin-bottom: 12px; }
.blog-hero p { font-size: 18px; color: var(--text-secondary); max-width: 560px; margin: 0 auto; line-height: 1.7; }

.featured-post { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; align-items: end; background: linear-gradient(145deg, var(--surface) 0%, var(--bg-warm) 100%); border: 1px solid var(--border); border-radius: 28px; padding: 36px; margin-bottom: 36px; position: relative; overflow: hidden; transition: border-color .2s, box-shadow .2s, transform .2s; }
.featured-post--has-image { grid-template-columns: minmax(0, 1fr) minmax(280px, 42%); align-items: center; }
.featured-post::before { content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; background: radial-gradient(circle, var(--brand-glow) 0%, transparent 70%); pointer-events: none; }
.featured-post:hover { border-color: var(--brand); box-shadow: 0 16px 40px var(--brand-glow); transform: translateY(-2px); }
.featured-post-copy { position: relative; z-index: 1; }
.featured-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--brand); padding: 6px 12px; background: var(--brand-pale); border: 1px solid rgba(34,197,94,0.22); border-radius: var(--r-pill); margin-bottom: 14px; }
.featured-date { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.featured-post h2 { font-family: var(--font-display); font-size: clamp(28px, 3vw, 40px); line-height: 1.12; color: var(--navy); margin-bottom: 14px; max-width: 18ch; }
.featured-post p { font-size: 16px; color: var(--text-secondary); line-height: 1.75; max-width: 62ch; }
.featured-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.featured-post-aside { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; text-align: right; }
.featured-kicker { font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-muted); }
.featured-arrow { font-size: 16px; font-weight: 600; color: var(--brand); }

.blog-tags-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 48px; }
.tag { display: inline-block; font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary); transition: all .15s; }
.tag:hover, .tag--active { background: var(--brand-pale); border-color: rgba(34,197,94,0.3); color: var(--brand); }

.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 24px; margin-bottom: 80px; }

.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px; transition: border-color .2s, box-shadow .2s, transform .2s; text-decoration: none; }
.card:hover { border-color: var(--brand); box-shadow: 0 8px 32px var(--brand-glow); transform: translateY(-2px); }
.card-date { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.card h3 { font-family: var(--font-display); font-size: 20px; color: var(--navy); line-height: 1.25; margin-bottom: 10px; }
.card p { font-size: 14px; color: var(--text-secondary); line-height: 1.65; flex: 1; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card-tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); background: var(--brand-pale); color: var(--brand); }
.card-read { font-size: 13px; color: var(--text-muted); }

/* ── Post Page ───────────────────────────────────────────────── */
.blog-post { padding: 140px 0 80px; }
.post-container { max-width: 760px; }

.post-back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--brand); margin-bottom: 28px; transition: color .15s, gap .15s; }
.post-back:hover { color: var(--brand-light); gap: 10px; }

.post-header { margin-bottom: 48px; }
.post-meta { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); margin-bottom: 16px; flex-wrap: wrap; }
.meta-sep { color: var(--border); }
.post-title { font-family: var(--font-display); font-size: clamp(32px,4vw,48px); color: var(--navy); line-height: 1.15; margin-bottom: 16px; }
.post-description { font-size: 18px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 20px; }
.post-tags { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Prose (article body) ────────────────────────────────────── */
.prose { font-size: 17px; line-height: 1.8; color: var(--text-secondary); }
.prose h2 { font-family: var(--font-display); font-size: 28px; color: var(--navy); margin: 48px 0 16px; line-height: 1.2; }
.prose h3 { font-size: 20px; font-weight: 700; color: var(--navy); margin: 36px 0 12px; }
.prose p { margin-bottom: 20px; }
.prose a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { color: var(--brand-light); }
.prose strong { color: var(--navy); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { line-height: 1.7; }
.prose blockquote { border-left: 3px solid var(--brand); background: var(--brand-pale); border-radius: 0 var(--r) var(--r) 0; padding: 16px 20px; margin: 24px 0; font-size: 16px; color: var(--text-secondary); }
.prose blockquote strong { color: var(--navy); }
.prose code { font-family: var(--font-mono); font-size: 0.88em; background: var(--code-bg); padding: 2px 6px; border-radius: 4px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; overflow-x: auto; margin: 24px 0; }
.prose pre code { background: none; padding: 0; font-size: 14px; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }
.prose img { max-width: 100%; border-radius: var(--r); margin: 24px 0; }

/* ── Related Posts ───────────────────────────────────────────── */
.related-posts { margin-top: 64px; padding-top: 48px; border-top: 1px solid var(--border); }
.related-posts h2 { font-family: var(--font-display); font-size: 24px; color: var(--navy); margin-bottom: 24px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.related-grid .card { padding: 24px; }
.related-grid .card h3 { font-size: 16px; }

/* ── Post CTA ────────────────────────────────────────────────── */
.post-cta { margin-top: 64px; }
.cta-inner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px; text-align: center; }
.cta-inner h3 { font-family: var(--font-display); font-size: 24px; color: var(--navy); margin-bottom: 10px; }
.cta-inner p { font-size: 16px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.7; }

/* ── Subscribe ────────────────────────────────────────────────── */
.blog-subscribe, .post-subscribe { margin-top: 64px; }
.subscribe-inner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px; text-align: center; }
.subscribe-inner h3 { font-family: var(--font-display); font-size: 24px; color: var(--navy); margin-bottom: 8px; }
.subscribe-inner > p { font-size: 15px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.65; }
.subscribe-form { display: flex; gap: 10px; max-width: 440px; margin: 0 auto; }
.subscribe-input { flex: 1; font-family: var(--font-body); font-size: 15px; padding: 12px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); transition: border-color .2s; outline: none; }
.subscribe-input::placeholder { color: var(--text-muted); }
.subscribe-input:focus { border-color: var(--brand); }
.subscribe-btn { flex-shrink: 0; border-radius: var(--r); }
.subscribe-success { font-size: 14px; font-weight: 600; color: var(--brand); margin-top: 16px; }
.subscribe-error { font-size: 14px; font-weight: 500; color: #EF4444; margin-top: 16px; }
.subscribe-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Tag Page ────────────────────────────────────────────────── */
.tag-hero { padding: 140px 0 40px; text-align: center; }
.tag-hero h1 { font-family: var(--font-display); font-size: clamp(28px,3.5vw,40px); color: var(--navy); }
.tag-hero h1 span { color: var(--brand); }
.tag-hero p { font-size: 16px; color: var(--text-muted); margin-top: 8px; }
.tag-back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--brand); margin-bottom: 20px; }
.tag-back:hover { text-decoration: underline; }

/* ── Footer ──────────────────────────────────────────────────── */
.footer { padding: 64px 0 0; border-top: 1px solid var(--border); transition: border-color .3s; }
.footer-inner { display: flex; gap: 80px; flex-wrap: wrap; padding-bottom: 48px; }
.footer-brand { max-width: 260px; }
.footer-brand p { font-size: 14px; color: var(--text-muted); line-height: 1.65; margin-top: 14px; }
.footer-links { display: flex; gap: 48px; flex-wrap: wrap; margin-left: auto; }
.footer-col h4 { font-size: 13px; font-weight: 700; color: var(--navy); letter-spacing: 0.5px; margin-bottom: 16px; text-transform: uppercase; transition: color .3s; }
.footer-col ul { display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 14px; color: var(--text-muted); transition: color .15s; }
.footer-col a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--border); padding: 18px 0; font-size: 13px; color: var(--text-muted); transition: border-color .3s; }
.footer-bottom .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ── Featured Post Image ──────────────────────────────────────── */
.featured-post-image { position: relative; z-index: 1; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-warm); border: 1px solid var(--border-light); }
.featured-post-image img { display: block; width: 100%; height: auto; border-radius: var(--r-lg); }

/* ── Card Images ─────────────────────────────────────────────── */
.card-image { margin: -32px -32px 20px; overflow: hidden; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--bg-warm); border-bottom: 1px solid var(--border-light); }
.card-image img { display: block; width: 100%; height: auto; }

/* ── Post Hero Image ─────────────────────────────────────────── */
.post-hero-image { margin-top: 28px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); background: var(--bg-warm); }
.post-hero-image img { display: block; width: 100%; height: auto; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .featured-post, .featured-post--has-image { grid-template-columns: 1fr; padding: 28px; }
  .featured-post h2 { max-width: none; }
  .featured-post-aside { align-items: flex-start; text-align: left; }
  .featured-footer { flex-direction: column; align-items: flex-start; }
  .featured-post-image { order: -1; }
  .posts-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .nav-actions .btn-ghost { display: none; }
}
@media (max-width: 700px) {
  .blog-hero { padding: 120px 0 40px; }
  .blog-post { padding: 120px 0 60px; }
  .post-title { font-size: 28px; }
  .prose { font-size: 16px; }
  .footer-inner { flex-direction: column; gap: 40px; }
  .footer-links { margin-left: 0; }
  .nav-pill { padding: 10px 16px; }
  .related-grid { grid-template-columns: 1fr; }
  .subscribe-form { flex-direction: column; }
  .subscribe-inner { padding: 28px 20px; }
}
