/* ── CSS Variables (matching portfolio design system) ── */
:root {
  --bg: #262524;
  --bg2: #2e2d2b;
  --card: #323130;
  --border: #3d3b38;
  --accent: #cc6b40;
  --accent-glow: rgba(204, 107, 64, 0.18);
  --text: #e8e6e0;
  --text-dim: #b0aea8;
  --text-muted: #8a8880;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
  --container: 700px;
}

[data-theme="light"] {
  --bg: #f5ede3;
  --bg2: #ede4d8;
  --card: #e8ddd2;
  --border: #d4c8bb;
  --accent: #c96033;
  --accent-glow: rgba(201, 96, 51, 0.12);
  --text: #1a130a;
  --text-dim: #4a3f35;
  --text-muted: #7a6e65;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Nav ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(38, 37, 36, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .nav {
  background: rgba(245, 237, 227, 0.85);
}

.nav__inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav__logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.nav__links {
  display: flex;
  list-style: none;
  gap: 24px;
  margin-left: auto;
}

.nav__links a {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition);
}

.nav__links a:hover, .nav__links a.active {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: border-color var(--transition), color var(--transition);
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

[data-theme="dark"] .moon-icon,
[data-theme="light"] .sun-icon { display: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Blog hero ── */
.blog-hero {
  max-width: var(--container);
  margin: 0 auto;
  padding: 72px 24px 40px;
}

.blog-hero__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.blog-hero__title {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
}

.blog-hero__desc {
  font-size: 17px;
  color: var(--text-dim);
  max-width: 480px;
}

/* ── Blog container ── */
.blog-container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Category tabs ── */
.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.category-tab {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all var(--transition);
}

.category-tab:hover, .category-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Post cards ── */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 48px;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  margin-bottom: 16px;
}

.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-card__image-link { display: block; }

.post-card__image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post-card__body {
  padding: 24px;
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.post-card__category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 20px;
}

.post-card__date { color: var(--text-muted); }

.post-card__title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 10px;
}

.post-card__title a:hover { color: var(--accent); }

.post-card__excerpt {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-card__read {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  transition: gap var(--transition);
}

.post-card__read:hover { opacity: 0.8; }

/* ── Tags ── */
.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.pagination__info { font-size: 14px; color: var(--text-muted); }

/* ── Post article ── */
.post-article {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px 48px;
}

.post-article__back {
  padding: 32px 0 0;
}

.post-article__back--bottom {
  padding: 48px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.back-link {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }

/* ── Post header ── */
.post-header {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.post-header__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 13px;
  flex-wrap: wrap;
}

.post-header__category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 20px;
  transition: opacity var(--transition);
}

.post-header__category:hover { opacity: 0.8; }
.post-header__date, .post-header__readtime { color: var(--text-muted); }

.post-header__title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.post-header__excerpt {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.6;
}

.post-header__tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Cover image ── */
.post-cover {
  margin-bottom: 40px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-cover img {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
}

/* ── Prose (rendered markdown) ── */
.prose {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-dim);
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 2em 0 0.75em;
}

.prose h1 { font-size: 2em; }
.prose h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.4em; }
.prose h3 { font-size: 1.2em; }
.prose h4 { font-size: 1em; }

.prose p { margin: 0 0 1.4em; }

.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { opacity: 0.8; }

.prose strong { color: var(--text); font-weight: 700; }
.prose em { font-style: italic; }

.prose ul, .prose ol {
  padding-left: 1.5em;
  margin: 0 0 1.4em;
}

.prose li { margin-bottom: 0.4em; }

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
}

.prose code {
  font-size: 0.875em;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
}

.prose pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 0 0 1.4em;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.9em;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 1em 0;
  border: 1px solid var(--border);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: 15px;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 8px 14px;
  text-align: left;
}

.prose th { background: var(--bg2); font-weight: 600; color: var(--text); }

/* ── Subscribe section ── */
.subscribe-section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.subscribe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
}

.subscribe-card__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.subscribe-card__desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

.subscribe-form {
  display: flex;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.subscribe-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.subscribe-input:focus { border-color: var(--accent); }
.subscribe-input::placeholder { color: var(--text-muted); }

.subscribe-note {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Confirm / Unsubscribe pages ── */
.confirm-page {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.confirm-card {
  max-width: 420px;
  text-align: center;
}

.confirm-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 16px;
}

.confirm-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.confirm-card p {
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Empty state ── */
.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
}

.footer__inner {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.footer__links {
  display: flex;
  gap: 20px;
}

.footer__links a:hover { color: var(--accent); }

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

.text-muted { color: var(--text-muted); font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .nav__links { display: none; }
  .subscribe-form { flex-direction: column; }
  .post-header__title { font-size: 26px; }
  .blog-hero__title { font-size: 28px; }
  .footer__inner { flex-direction: column; gap: 12px; text-align: center; }
}
