/* ===== CSS Variables ===== */
:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --surface-hover: #f0f0f1;
  --text: #18181b;
  --text-secondary: #71717a;
  --text-tertiary: #a1a1aa;
  --border: #e4e4e7;
  --border-light: #f4f4f5;
  --accent: #18181b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --max-width: 720px;
  --header-height: 64px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #52525b;
  --border: #27272a;
  --border-light: #1f1f23;
  --accent: #fafafa;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.7;
}

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

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

.container.narrow {
  max-width: 680px;
}

.main {
  min-height: calc(100vh - var(--header-height) - 120px);
  padding-bottom: 80px;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(var(--bg), 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.3s ease, border-color 0.3s ease;
}

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

.site-brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  padding: 4px 0;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  opacity: 1;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

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

/* ===== Hero ===== */
.hero {
  padding: 80px 0 48px;
  text-align: center;
}

.hero-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== Post List ===== */
.post-list {
  padding-top: 16px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  font-weight: 500;
}

.post-meta time {
  letter-spacing: 0.02em;
}

.post-meta .sep {
  color: var(--border);
}

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

.post-card .post-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

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

.post-card .post-title a:hover {
  opacity: 0.75;
}

.post-excerpt {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  opacity: 1;
  color: var(--text);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
  padding: 16px 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.pagination a:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
  opacity: 1;
}

.pagination .current {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.pagination .prev,
.pagination .next {
  padding: 0 16px;
}

/* ===== Post Detail ===== */
.post-detail {
  padding-top: 48px;
}

.post-header {
  margin-bottom: 48px;
  text-align: center;
}

.post-header .post-meta {
  justify-content: center;
  margin-bottom: 16px;
}

.post-header .post-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.post-header .post-tags {
  justify-content: center;
}

/* ===== Post Content ===== */
.post-content {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 48px;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.post-content h2 {
  font-size: 26px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.post-content h3 {
  font-size: 21px;
}

.post-content h4 {
  font-size: 18px;
}

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

.post-content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-tertiary);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}

.post-content a:hover {
  opacity: 1;
  text-decoration-color: var(--text);
}

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

.post-content li {
  margin-bottom: 8px;
}

.post-content blockquote {
  margin: 28px 0;
  padding: 16px 24px;
  border-left: 3px solid var(--text);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.88em;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  color: var(--text);
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 20px;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 14px;
}

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

.post-content th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-content hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: 48px 0;
}

/* ===== Post Nav ===== */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border-light);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.post-nav a:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  opacity: 1;
}

.post-nav-prev {
  text-align: left;
}

.post-nav-next {
  text-align: right;
}

.post-nav .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-nav .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

.site-footer .copyright {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.site-footer .powered {
  font-size: 12px;
  color: var(--text-tertiary);
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Archives / Categories / Tags ===== */
.archive-list,
.category-list,
.tag-list {
  padding-top: 48px;
}

.archive-list h1,
.category-list h1,
.tag-list h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s ease;
}

.archive-item:hover {
  background: var(--surface);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: var(--radius-sm);
  opacity: 1;
}

.archive-item time {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  min-width: 90px;
  flex-shrink: 0;
}

.archive-item a {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  :root {
    --header-height: 56px;
  }

  .hero {
    padding: 48px 0 32px;
  }

  .hero-title {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .site-nav {
    gap: 16px;
  }

  .nav-link {
    font-size: 13px;
  }

  .post-card {
    padding: 24px;
    margin-bottom: 16px;
  }

  .post-card .post-title {
    font-size: 19px;
  }

  .post-header .post-title {
    font-size: 26px;
  }

  .post-content h2 {
    font-size: 22px;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav-next {
    text-align: left;
  }
}

/* ===== Smooth transitions for theme switch ===== */
*, *::before, *::after {
  transition-property: background-color, border-color, color;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}

/* Override for transform/opacity transitions */
.post-card,
.post-nav a,
.pagination a,
.archive-item {
  transition-property: transform, box-shadow, background-color, border-color, opacity, color;
}
