/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-serif: 'Playfair Display', Georgia, serif;

  --radius: 8px;
  --radius-sm: 4px;
  --max-w: 720px;
  --max-w-wide: 1100px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg:        #0d0d0f;
  --bg-2:      #141416;
  --bg-3:      #1c1c1f;
  --border:    #2a2a2e;
  --muted:     #6b6b75;
  --text:      #e2e2e6;
  --text-dim:  #a0a0aa;
  --accent:    #7c6af7;
  --accent-2:  #4fc3f7;
  --green:     #4ade80;
  --red:       #f87171;
  --yellow:    #fbbf24;

  --header-bg: rgba(13, 13, 15, 0.85);
  --code-color: #4fc3f7;
  --hl-comment: #4b5563;
  --hl-string:  #4ade80;
  --hl-keyword: #c084fc;
  --hl-func:    #60a5fa;
  --hl-number:  #fb923c;
}

/* Light theme */
[data-theme="light"] {
  --bg:        #fafaf9;
  --bg-2:      #f5f5f4;
  --bg-3:      #e7e5e4;
  --border:    #d6d3d1;
  --muted:     #6b7280;
  --text:      #1c1917;
  --text-dim:  #44403c;
  --accent:    #5b45e8;
  --accent-2:  #0284c7;
  --green:     #16a34a;
  --red:       #dc2626;
  --yellow:    #d97706;

  --header-bg: rgba(250, 250, 249, 0.88);
  --code-color: #0284c7;
  --hl-comment: #9ca3af;
  --hl-string:  #16a34a;
  --hl-keyword: #7c3aed;
  --hl-func:    #1d4ed8;
  --hl-number:  #ea580c;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-2); }

img { max-width: 100%; height: auto; display: block; }

/* ================================================================
   LAYOUT
   ================================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ================================================================
   HEADER
   ================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-w-wide);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.site-logo {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-logo:hover { color: var(--text); }

.logo-bracket {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.site-nav a {
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}

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

.site-nav .rss-link {
  display: flex;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.site-nav .rss-link:hover { opacity: 1; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  line-height: 0;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--bg-3);
}

/* Show sun in dark mode, moon in light mode */
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ================================================================
   HOME PAGE — HERO
   ================================================================ */
.hero {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1.25rem;
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

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

.hero-bio {
  font-size: 1.0625rem;
  color: var(--text-dim);
  max-width: 520px;
  line-height: 1.7;
}

/* ================================================================
   POST LIST
   ================================================================ */
.post-list-section {
  padding: 2rem 0;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.archived-btn {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}

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

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}

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

.no-posts {
  color: var(--muted);
  font-size: 0.9rem;
}

.post-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0 1.5rem;
  align-items: baseline;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.post-item:first-child { border-top: 1px solid var(--border); }

.post-item-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 2px;
  white-space: nowrap;
}

.post-item-body {}

.post-item-tags {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(124, 106, 247, 0.1);
  border: 1px solid rgba(124, 106, 247, 0.25);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-item-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  transition: color 0.2s;
}

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

.post-item-excerpt {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ================================================================
   POST FULL
   ================================================================ */
.post-header {
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--border);
}

.post-tags {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-subtitle {
  font-size: 1.125rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot { color: var(--border); }

/* ================================================================
   POST BODY — TYPOGRAPHY
   ================================================================ */
.post-body {
  padding: 3rem 0;
}

.post-body p {
  margin-bottom: 1.5rem;
  color: var(--text-dim);
  font-size: 1.0625rem;
  line-height: 1.8;
}

.post-body h2 {
  font-family: var(--font-serif);
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.01em;
}

.post-body h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}

.post-body h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.75rem 0 0.5rem;
}

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(124, 106, 247, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.post-body a:hover { text-decoration-color: var(--accent); }

.post-body ul,
.post-body ol {
  margin: 0 0 1.5rem 1.5rem;
  color: var(--text-dim);
}

.post-body li { margin-bottom: 0.4rem; line-height: 1.7; }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.5rem;
  margin: 2rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.post-body blockquote p { margin-bottom: 0; font-size: 1.0625rem; }

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.post-body img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius);
  margin: 2rem 0;
}

/* Code — inline */
.post-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-3);
  color: var(--code-color);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Code — blocks */
.post-body pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
  position: relative;
}

.post-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
}

/* Rouge syntax highlighting */
.highlight { background: var(--bg-2) !important; }
.highlight .c,  .highlight .c1, .highlight .cm { color: var(--hl-comment); }
.highlight .s,  .highlight .s1, .highlight .s2 { color: var(--hl-string); }
.highlight .k,  .highlight .kd, .highlight .kn { color: var(--hl-keyword); }
.highlight .n  { color: var(--text); }
.highlight .nf { color: var(--hl-func); }
.highlight .mi { color: var(--hl-number); }
.highlight .o  { color: var(--text-dim); }
.highlight .p  { color: var(--text-dim); }

/* ================================================================
   POST FOOTER / NAV
   ================================================================ */
.post-comments {
  padding: 3rem 0 1rem;
  border-top: 1px solid var(--border);
}

.post-footer {
  padding: 2.5rem 0 4rem;
  border-top: 1px solid var(--border);
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.prev-post, .next-post {
  display: flex;
  flex-direction: column;
  max-width: 45%;
  color: var(--text-dim);
}

.next-post { text-align: right; margin-left: auto; }

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

.nav-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  transition: color 0.2s;
  line-height: 1.4;
}

.prev-post:hover .nav-title,
.next-post:hover .nav-title {
  color: var(--accent);
}

/* ================================================================
   ABOUT PAGE
   ================================================================ */
.about-page {
  padding: 4rem 0;
}

.about-page h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  color: var(--text);
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.about-page p {
  color: var(--text-dim);
  font-size: 1.0625rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.about-page a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(124, 106, 247, 0.35);
  text-underline-offset: 3px;
}

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-w-wide);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

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

.footer-links {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
}

.footer-links a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--text); }

/* ================================================================
   TERMINAL CURSOR BLINK
   ================================================================ */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1.1s step-start infinite;
  margin-left: 2px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
  .post-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .post-item-date { font-size: 0.7rem; }

  .footer-inner { flex-direction: column; gap: 0.5rem; text-align: center; }

  .post-nav { flex-direction: column; }
  .next-post { text-align: left; margin-left: 0; }
}

/* ================================================================
   SCROLL PROGRESS BAR
   ================================================================ */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  z-index: 999;
  transition: width 0.1s linear;
}
