/* CSS Variables - Light Mode (default) */
:root {
  --color-bg: #f0eee6;
  --color-text: #1f1e1d;
  --color-text-secondary: #5e5d59;
  --color-link: #1f1e1d;
  --color-link-hover: #5e5d59;
  --color-border: #d1cfc5;
  --color-code-bg: #e8e6dc;
  --color-code-block-bg: #282c34;
  --color-code-block-text: #abb2bf;
  --color-blockquote-bg: #e8e6dc;
  --color-blockquote-border: #5e5d59;
  --color-tag-bg: #e8e6dc;
}

/* Dark Mode */
html.dark-mode {
  --color-bg: #1f1e1d;
  --color-text: #f0eee6;
  --color-text-secondary: #b0aea5;
  --color-link: #f0eee6;
  --color-link-hover: #b0aea5;
  --color-border: #3d3d3a;
  --color-code-bg: #2d2c2b;
  --color-code-block-bg: #0d0d0d;
  --color-code-block-text: #abb2bf;
  --color-blockquote-bg: #2d2c2b;
  --color-blockquote-border: #b0aea5;
  --color-tag-bg: #3d3d3a;
}

/* Reset and base styles */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  line-height: 1.7;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Newsreader', Georgia, 'Times New Roman', serif;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

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

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

/* Container */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 0;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

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

.site-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  margin-left: 1.25rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:first-child {
  margin-left: 0;
}

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

/* Theme Toggle */
.theme-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-border);
  border-radius: 20px;
  transition: background-color 0.3s ease;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-bg);
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.theme-toggle input:checked + .toggle-slider {
  background-color: var(--color-text-secondary);
}

.theme-toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* Main content */
.site-content {
  padding: 3rem 0;
  min-height: calc(100vh - 180px);
}

/* Post list (home page) */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list-item {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

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

.post-list-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

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

.post-list-title a:hover {
  color: var(--color-text-secondary);
}

.post-list-meta {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.post-list-excerpt {
  color: var(--color-text-secondary);
  margin: 0;
}

/* Single post */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

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

.post-content {
  margin-bottom: 2rem;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

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

.post-content ul, .post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

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

.post-content img {
  display: block;
  margin: 2rem auto;
  border-radius: 4px;
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--color-blockquote-border);
  background: var(--color-blockquote-bg);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

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

.post-content code {
  background: var(--color-code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
}

.post-content pre {
  background: var(--color-code-block-bg);
  color: var(--color-code-block-text);
  padding: 1.25rem;
  border-radius: 6px;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

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

.post-footer {
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.tag {
  background: var(--color-tag-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--color-text-secondary);
  transition: background-color 0.2s ease;
}

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

/* Post navigation */
.post-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.post-navigation .prev,
.post-navigation .next {
  max-width: 45%;
}

/* Page styles */
.page-title {
  margin-bottom: 1.5rem;
}

/* Remove top margin from first element in content */
.site-content > .container > *:first-child,
.site-content > .container > *:first-child > *:first-child {
  margin-top: 0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* Responsive */
@media (max-width: 600px) {
  html {
    font-size: 17px;
  }

  .site-header .container {
    flex-wrap: wrap;
  }

  .site-title {
    font-size: 1rem;
  }

  .header-right {
    gap: 1rem;
  }

  .site-nav a {
    margin-left: 0.75rem;
    font-size: 0.9rem;
  }

  .post-title {
    font-size: 1.75rem;
  }

  .post-content h2 {
    font-size: 1.35rem;
  }
}
