/* === Tokens === */
:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --max-width: 720px;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #586069;
  --border: #e1e4e8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --code-bg: #f0f2f5;
  --tag-bg: #e8eef6;
  --tag-text: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #161b22;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --code-bg: #1c2128;
  --tag-bg: #1c3a5f;
  --tag-text: #58a6ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

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

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

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

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

img { max-width: 100%; height: auto; border-radius: var(--radius); }

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

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

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
}

#theme-toggle:hover { color: var(--text); }

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

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

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

.footer-copy {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* === Main / Pages === */
main {
  flex: 1;
  padding: 3rem 0;
}

.page h1, .hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  line-height: 1.2;
}

/* === Home === */
.hero {
  padding: 2rem 0 1rem;
}

.hero .intro {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 560px;
}

.hero blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-secondary);
  font-style: italic;
  margin: 1.5rem 0 2rem;
}

.about-section {
  margin: 2rem 0;
  line-height: 1.8;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 3rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* === Card grid === */
.card-grid {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: block;
  color: var(--text);
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  color: var(--text);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.card .card-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* === Writings index === */
.category-group {
  margin-bottom: 2.5rem;
}

.category-group h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.writing-item {
  display: block;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: padding-left 0.15s;
}

.writing-item:last-child { border-bottom: none; }

.writing-item:hover {
  padding-left: 0.5rem;
  color: var(--accent);
}

.writing-item h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.writing-item p {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* === Post === */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.post-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.post-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag {
  font-size: 0.75rem;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* === Post content === */
.post-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
}

.post-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul, .post-content ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.25rem 0;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  line-height: 1.5;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

.post-content th, .post-content td {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.post-content strong {
  font-weight: 600;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-footer a {
  font-size: 0.9rem;
  font-weight: 500;
}

/* === Readings === */
.reading-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.reading-item:last-child { border-bottom: none; }

.reading-item h3 {
  font-size: 0.95rem;
  font-weight: 500;
}

.reading-item h3 a { color: var(--text); }
.reading-item h3 a:hover { color: var(--accent); }

.reading-item .reading-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.reading-item p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.5;
}

/* === Resources (home) === */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  transition: border-color 0.2s;
  color: var(--text);
  display: block;
}

.resource-card:hover {
  border-color: var(--accent);
  color: var(--text);
}

.resource-card h4 {
  font-size: 0.9rem;
  font-weight: 500;
}

.resource-card p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* === Responsive === */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .post-header h1 { font-size: 1.35rem; }
  .site-nav { gap: 1rem; }
  .resource-grid { grid-template-columns: 1fr 1fr; }
  main { padding: 2rem 0; }
}
