/* Base */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #666666;
  --color-border: #e0e0e0;
  --color-accent: #1a1a1a;
  --color-surface: #f5f5f5;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --max-width: 860px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background 0.2s, color 0.2s;
}

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

/* Header */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
}

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

.site-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-nav a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 15px;
  margin-left: 24px;
}

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

/* Main */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px;
}

/* Home */
.home h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.tagline {
  color: var(--color-muted);
  font-size: 16px;
  margin: 0 0 48px;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
}

.post-list time {
  display: block;
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.post-list a {
  color: var(--color-text);
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
}

.post-list-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.post-list p {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--color-muted);
}

/* Post list item with cover thumbnail */
.post-list-item {
  display: flex;
  gap: 20px;
  align-items: center;
}

.post-list-cover {
  flex-shrink: 0;
  width: 30%;
  aspect-ratio: 3 / 2;
  border-radius: 4px;
  overflow: hidden;
  display: block;
}

.post-list-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}

.post-list-cover:hover img {
  opacity: 0.88;
}

.post-list-body {
  flex: 1;
  min-width: 0;
}

.post-list-title {
  display: block;
  margin-top: 4px;
}

/* Latest posts section header */
.latest-posts-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0;
}

.latest-posts-header h2 {
  margin: 0;
}

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

.view-all:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Articles page */
.articles-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

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

.post-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 12px;
}

.post-meta {
  font-size: 14px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-description {
  font-size: 18px;
  color: var(--color-muted);
  margin: 16px 0 0;
  line-height: 1.5;
}

.category {
  background: var(--color-surface);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
}

/* Post cover image */
.post-cover {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: 4px;
  margin: 32px 0;
}

/* Post content */
.post-content h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 40px 0 12px;
}

.post-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 10px;
}

.post-content p {
  margin: 0 0 20px;
}

.post-content a {
  color: var(--color-text);
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--color-surface);
  padding: 2px 5px;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-surface);
  border-radius: 6px;
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  margin: 24px 0;
  padding: 0 0 0 20px;
  color: var(--color-muted);
}

.post-content img {
  max-width: 100%;
  border-radius: 6px;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 24px 0;
}

.post-content th,
.post-content td {
  border: 1px solid var(--color-border);
  padding: 10px 14px;
  text-align: left;
}

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

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  margin-top: 48px;
}

.site-footer p {
  margin: 0;
  font-size: 14px;
  color: var(--color-muted);
  text-align: center;
}

/* Mobile */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .post-title { font-size: 26px; }
}

/* Dark mode — auto (OS) unless user has explicitly chosen light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #111111;
    --color-text: #e8e8e8;
    --color-muted: #888888;
    --color-border: #2a2a2a;
    --color-accent: #e8e8e8;
    --color-surface: #1e1e1e;
  }
}

/* Dark mode — explicit user toggle */
:root[data-theme="dark"] {
  --color-bg: #111111;
  --color-text: #e8e8e8;
  --color-muted: #888888;
  --color-border: #2a2a2a;
  --color-accent: #e8e8e8;
  --color-surface: #1e1e1e;
}

/* Toggle button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  margin-left: 20px;
  line-height: 1;
  color: var(--color-muted);
}

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

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--color-muted);
  margin: 0 0 16px;
}

.breadcrumb a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* Back link */
.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--color-muted);
  text-decoration: none;
  margin-bottom: 32px;
}

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

/* Category page */
.category-page h1,
.projects-page h1,
.archive-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

/* Category link (replaces plain span in some contexts) */
a.category {
  text-decoration: none;
  color: var(--color-text);
}

a.category:hover {
  text-decoration: underline;
}

/* Category filters on articles page */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 32px;
}

.category-filter-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.category-filter-link:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* Tag pills */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  font-size: 12px;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 2px 7px;
}

/* Featured badge */
.featured-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-bg);
  background: var(--color-text);
  border-radius: 3px;
  padding: 2px 6px;
}

/* Empty state */
.empty-state {
  color: var(--color-muted);
  font-size: 15px;
}

/* Related posts */
.related-posts {
  border-top: 1px solid var(--color-border);
  margin-top: 64px;
  padding-top: 32px;
}

.related-posts h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin: 0 0 16px;
}

.related-list li {
  padding: 14px 0;
}

/* Archive page */
.archive-year h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-muted);
  margin: 40px 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.archive-list time {
  font-size: 13px;
  color: var(--color-muted);
  min-width: 52px;
  flex-shrink: 0;
}

.archive-list a:not(.category) {
  color: var(--color-text);
  text-decoration: none;
  font-size: 15px;
  flex: 1;
}

.archive-list a:not(.category):hover {
  text-decoration: underline;
}

/* Footer link */
.site-footer a {
  color: var(--color-muted);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 600px) {
  .category-filters { gap: 6px; }
  .archive-list li { flex-wrap: wrap; }
  .archive-list time { min-width: auto; }
}
