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

:root {
  --bg: #fafafa;
  --bg-secondary: #f0f0f0;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-tertiary: #999;
  --border: #e0e0e0;
  --accent-blue: #6ba3c7;
  --accent-red: #c7816b;
  --code-bg: #f5f5f5;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  --font-serif: 'Newsreader', 'Georgia', serif;
  --max-width: 680px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header / Nav ===== */
header {
  padding: 40px 0 0;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

nav .logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

nav .nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

nav .nav-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  letter-spacing: 0.01em;
}

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

/* ===== Hero / Intro ===== */
.hero {
  padding: 64px 0 48px;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 24px;
}

.hero h1 .first-name {
  color: var(--text);
}

.hero h1 .accent-dot {
  color: var(--accent-blue);
}

.hero .subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 560px;
}

.hero .subtitle .highlight-blue {
  color: var(--accent-blue);
  font-weight: 500;
}

.hero .subtitle .highlight-red {
  color: var(--accent-red);
  font-weight: 500;
}

/* ===== Tags / Interests ===== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
}

.tag {
  font-size: 0.75rem;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: transparent;
  letter-spacing: 0.02em;
  transition: all 0.2s;
}

.tag:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
}

.tag.blue {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.tag.red {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* ===== Section ===== */
section {
  padding: 48px 0;
}

section.bordered {
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 24px;
  font-weight: 500;
}

/* ===== Article List ===== */
.article-list {
  list-style: none;
}

.article-list li {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.article-list li:last-child {
  border-bottom: none;
}

.article-list a {
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.article-list .article-title {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
  transition: color 0.2s;
}

.article-list a:hover .article-title {
  color: var(--accent-blue);
}

.article-list .article-date {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ===== Footer ===== */
footer {
  padding: 48px 0 40px;
  border-top: 1px solid var(--border);
}

footer p {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

.footer-links {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

/* ===== Article Page ===== */
.article-header {
  padding: 64px 0 32px;
}

.article-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 12px;
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.article-content {
  padding-bottom: 64px;
}

.article-content h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 48px 0 16px;
  letter-spacing: -0.01em;
}

.article-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 36px 0 12px;
}

.article-content p {
  margin-bottom: 20px;
  color: var(--text);
  line-height: 1.8;
}

.article-content ul,
.article-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

.article-content li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.article-content blockquote {
  border-left: 3px solid var(--accent-blue);
  padding: 12px 20px;
  margin: 24px 0;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text);
}

.article-content pre {
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 20px 24px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 24px 0;
  line-height: 1.5;
}

.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.85rem;
}

.article-content img {
  max-width: 100%;
  border-radius: 4px;
  margin: 24px 0;
}

.article-content a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-decoration-color: rgba(107, 163, 199, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}

.article-content a:hover {
  text-decoration-color: var(--accent-blue);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.article-content thead {
  border-bottom: 2px solid var(--border);
}

.article-content th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.article-content td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.article-content tbody tr:last-child td {
  border-bottom: none;
}

.article-content tbody tr:hover {
  background: var(--bg-secondary);
}

/* Details / Summary (collapsible sections) */
.article-content details {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.article-content details summary {
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg-secondary);
  font-size: 0.95rem;
  transition: background 0.2s;
  list-style: none;
}

.article-content details summary::-webkit-details-marker {
  display: none;
}

.article-content details summary::before {
  content: '>';
  display: inline-block;
  margin-right: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.article-content details[open] summary::before {
  transform: rotate(90deg);
}

.article-content details summary:hover {
  background: var(--border);
}

.article-content details > *:not(summary) {
  padding: 0 16px;
}

.article-content details > p:last-child,
.article-content details > pre:last-child,
.article-content details > ul:last-child {
  margin-bottom: 16px;
}

/* Mermaid diagrams */
.article-content .mermaid {
  margin: 28px 0;
  padding: 24px 16px;
  background: var(--bg-secondary);
  border-radius: 6px;
  text-align: center;
  overflow-x: auto;
}

.article-content .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Math display blocks */
.article-content .katex-display {
  margin: 28px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
}

/* ===== Back link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-top: 24px;
  transition: color 0.2s;
}

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

/* ===== Vibe line ===== */
.vibe {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 24px;
  padding: 12px 16px;
  border-left: 2px solid var(--accent-red);
  background: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .article-list a {
    flex-direction: column;
    gap: 4px;
  }

  .article-header h1 {
    font-size: 1.4rem;
  }
}

/* ===== Article list on articles page ===== */
.articles-page .article-list li {
  padding: 20px 0;
}

.article-list .article-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.6;
}

/* ===== Loading state ===== */
.loading {
  text-align: center;
  padding: 64px 0;
  color: var(--text-tertiary);
  font-size: 0.9rem;
}
