@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=JetBrains+Mono:wght@300;400;500;700&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg: #0d0d0d;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e0d4;
  --muted: #7a7060;
  --accent: #f4610a;
  --accent2: #c94e08;
  --accent-glow: rgba(244, 97, 10, 0.15);
  --code-bg: #111111;
  --code-border: #252525;
  --link: #f4ab6e;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-body: 'Lora', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  min-height: 100vh;
  position: relative;
}

/* Grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ── HEADER ─────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,13,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo span.accent { color: var(--accent); }
.logo .bracket { color: var(--muted); font-weight: 300; }

nav { display: flex; align-items: center; gap: 2rem; }

nav a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); }

.nav-cta {
  background: var(--accent);
  color: #fff !important;
  padding: 0.4rem 1rem;
  border-radius: 3px;
  font-size: 0.75rem !important;
  transition: background 0.2s !important;
}
.nav-cta:hover { background: var(--accent2) !important; color: #fff !important; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: all 0.3s;
}

/* ── HERO ─────────────────────────────────────────── */
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 2rem 4rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4rem;
  align-items: end;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 900;
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.75;
  font-family: var(--font-mono);
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 0.5rem;
}

.stat-item {
  text-align: right;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── MAIN LAYOUT ─────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 4rem;
  align-items: start;
}

/* ── POST LIST ───────────────────────────────────── */
.posts-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.posts-header hr {
  flex: 1;
  border: none;
  border-top: 1px solid var(--border);
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.25s ease;
  transform-origin: bottom;
}

.post-card:hover {
  border-color: #3a3a3a;
  background: var(--surface2);
  transform: translateX(4px);
}

.post-card:hover::before { transform: scaleY(1); }

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.post-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(244,97,10,0.3);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
}

.post-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.6rem;
  transition: color 0.2s;
}

.post-card:hover .post-title { color: var(--accent); }

.post-excerpt {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.7;
  font-family: var(--font-mono);
}

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.read-more {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.read-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar { position: sticky; top: 88px; }

.sidebar-block {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
}

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s;
  text-transform: uppercase;
}
.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.recent-list { list-style: none; }

.recent-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.recent-list li:last-child { border-bottom: none; padding-bottom: 0; }

.recent-list a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  text-decoration: none;
  line-height: 1.5;
  transition: color 0.2s;
  display: block;
}
.recent-list a:hover { color: var(--accent); }

.recent-list .r-date {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ── ABOUT BOX ───────────────────────────────────── */
.about-box p {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ── ARTICLE PAGE ────────────────────────────────── */
.article-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 5rem;
  align-items: start;
}

.article-header { margin-bottom: 3rem; }

.article-eyebrow {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.article-eyebrow a {
  color: var(--accent);
  text-decoration: none;
}
.article-eyebrow a:hover { text-decoration: underline; }
.article-eyebrow .sep { color: var(--muted); }
.article-eyebrow .date { color: var(--muted); }

.article-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.article-hero-img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-bottom: 3rem;
  display: block;
}

/* article body */
.article-body { max-width: 700px; }

.article-body p {
  margin-bottom: 1.5rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.85;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-body h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}

.article-body h4 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.75rem 0 0.75rem;
}

.article-body a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-radius: 0 4px 4px 0;
  margin: 2rem 0;
  font-style: italic;
  color: var(--muted);
}

.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}
.article-body li { margin-bottom: 0.4rem; }

.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  position: relative;
}

.article-body pre code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #c9c4bc;
  line-height: 1.7;
  background: none;
  border: none;
  padding: 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--link);
}

/* code block language label */
.code-block {
  position: relative;
  margin: 1.75rem 0;
}

.code-lang {
  position: absolute;
  top: 0; right: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--code-border);
  padding: 0.25rem 0.75rem;
  border-radius: 0 4px 0 3px;
  border-left: 1px solid var(--code-border);
  border-bottom: 1px solid var(--code-border);
}

/* ── TOC ─────────────────────────────────────────── */
.toc { position: sticky; top: 88px; }

.toc-inner {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  background: var(--surface);
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.toc-list { list-style: none; }

.toc-list li { padding: 0; }

.toc-list a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 0.4rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: all 0.2s;
  line-height: 1.4;
}

.toc-list a:hover, .toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-list .toc-sub a {
  padding-left: 1.5rem;
  font-size: 0.72rem;
}

/* ── FOOTER ─────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 2rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.footer-links { display: flex; gap: 1.5rem; }

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

/* ── MOBILE NAV ─────────────────────────────────── */
.mobile-nav {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  gap: 1rem;
}

.mobile-nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s;
}
.mobile-nav a:hover { color: var(--text); }

/* ── BREADCRUMB ─────────────────────────────────── */
.breadcrumb-bar {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 100%;
}
.breadcrumb-bar a { color: var(--muted); text-decoration: none; }
.breadcrumb-bar a:hover { color: var(--accent); }
.breadcrumb-bar span { margin: 0 0.5rem; }

/* ── UTILITY ─────────────────────────────────────── */
.tag-pill {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(244,97,10,0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  white-space: nowrap;
}

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 900px) {
  .container { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .article-wrap { grid-template-columns: 1fr; gap: 3rem; }
  .toc { position: static; }
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .hero-stat { flex-direction: row; justify-content: flex-start; }
}

@media (max-width: 640px) {
  nav { display: none; }
  .hamburger { display: flex; }
  .hero { padding: 3rem 1.5rem 2.5rem; }
  .container, .article-wrap { padding: 2.5rem 1.5rem; }
  .hero h1 { font-size: 2.2rem; }
}

/* ── ANIMATIONS ─────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-eyebrow { animation: fadeInUp 0.5s ease both; }
.hero h1 { animation: fadeInUp 0.5s 0.1s ease both; }
.hero-desc { animation: fadeInUp 0.5s 0.2s ease both; }
.hero-stat { animation: fadeInUp 0.5s 0.3s ease both; }

.post-card {
  animation: fadeInUp 0.4s ease both;
}
.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }

/* ── SYNTAX HIGHLIGHT (manual) ────────────────── */
.kw { color: #e06c75; }
.str { color: #98c379; }
.cmt { color: #5c6370; font-style: italic; }
.fn { color: #61afef; }
.num { color: #d19a66; }
.var { color: #e5c07b; }
.punc { color: #abb2bf; }
