/* Eigen Theme - CSS Variables */
:root {
  --color-bg: #ffffff;
  --color-text: #232333;
  --color-text-muted: #737373;
  --color-primary: #dc143c;
  --color-primary-hover: #b91c3c;
  --color-border: #663399;
  --color-code-bg: #f5f5f5;
  --color-code-block-bg: #f1f1f1;
  --gap: 24px;
  --content-width: 720px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --color-bg: #1d1e20;
  --color-text: #d8d8d8;
  --color-text-muted: #a0a0a0;
  --color-primary: #ff6b6b;
  --color-primary-hover: #ff8585;
  --color-border: #9370db;
  --color-code-bg: #2d2d2d;
  --color-code-block-bg: #252525;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--gap);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
  margin: 1em 0;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

a:hover, a:focus {
  border-bottom-color: var(--color-primary);
}

/* Header */
header {
  padding: var(--gap) 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--gap);
}

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

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.site-title a {
  color: var(--color-text);
  border-bottom: none;
}

.site-title a:hover {
  color: var(--color-primary);
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

nav a {
  color: var(--color-text);
  font-size: 0.95rem;
}

nav a:hover {
  color: var(--color-primary);
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  border-radius: 4px;
  transition: color 0.2s ease;
}

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

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

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root:not([data-theme="dark"]) .icon-sun { display: none; }
:root:not([data-theme="dark"]) .icon-moon { display: block; }

/* Footer */
footer {
  padding: var(--gap) 0;
  border-top: 2px solid var(--color-border);
  margin-top: var(--gap);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.copyright {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Social Icons */
.social-icons {
  display: flex;
  gap: 0.75rem;
}

.social-icons a {
  color: var(--color-text-muted);
  border-bottom: none;
  display: flex;
  align-items: center;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.social-icons a:hover {
  color: var(--color-primary);
}

.social-icons svg {
  width: 20px;
  height: 20px;
}

/* Post List */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  margin-bottom: 1.5rem;
}

.post-list-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.post-list-title {
  font-size: 1.1rem;
  font-weight: 500;
}

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

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

.post-list-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.post-list-summary {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Archive Page */
.archive-year {
  margin-top: 2rem;
}

.archive-year:first-child {
  margin-top: 0;
}

.archive-year-header {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

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

.archive-posts li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
}

.archive-date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 5rem;
}

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

.archive-title a:hover {
  color: var(--color-primary);
}

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

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

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

.post-content {
  line-height: 1.8;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2em;
}

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

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  margin: 1.5em 0;
  padding-left: 1em;
  color: var(--color-text-muted);
}

.post-content ul, .post-content ol {
  padding-left: 1.5em;
}

.post-content li {
  margin: 0.5em 0;
}

/* Tags */
.post-tags {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.post-tags a {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-right: 0.5rem;
}

.post-tags a:hover {
  color: var(--color-primary);
}

.post-tags a::before {
  content: "#";
}

/* Tags Page */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.tags-list li a {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-size: 0.9rem;
}

.tags-list li a:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.tag-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo,
               Consolas, "Liberation Mono", monospace;
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--color-code-block-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
}

/* Subtitle (homepage) */
.site-subtitle {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-style: italic;
}

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

.pagination a {
  color: var(--color-text-muted);
}

.pagination a:hover {
  color: var(--color-primary);
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --gap: 16px;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .footer-inner {
    flex-direction: column-reverse;
    align-items: flex-start;
  }

  .archive-posts li {
    flex-direction: column;
    gap: 0.25rem;
  }

  .archive-date {
    min-width: auto;
  }
}
