/* ── Theme Variables ──────────────────────────────────────── */

:root {
  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-text-secondary: #555;
  --color-text-muted: #888;
  --color-nav: #444;
  --color-link: #0066cc;
  --color-link-hover: #004499;
  --color-border: #e0e0e0;
  --color-code-bg: #f5f5f5;
  --color-blockquote: #ddd;
  --color-heading-secondary: #333;
}

[data-theme="dark"] {
  --color-bg: #161616;
  --color-text: #e0e0e0;
  --color-text-secondary: #aaa;
  --color-text-muted: #777;
  --color-nav: #bbb;
  --color-link: #5ba3f5;
  --color-link-hover: #7db9ff;
  --color-border: #333;
  --color-code-bg: #222;
  --color-blockquote: #444;
  --color-heading-secondary: #ccc;
}

/* ── Reset & Base ────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  transition: color 0.2s, background 0.2s;
}

/* ── Container ───────────────────────────────────────────── */

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

/* ── Header ──────────────────────────────────────────────── */

header {
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

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

.site-logo {
  display: block;
  text-decoration: none;
}

.site-logo .logo {
  height: 44px;
  width: auto;
}

[data-theme="dark"] .site-logo .logo {
  filter: brightness(0) invert(1);
}

.social-links {
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

.social-links a {
  text-decoration: none;
  margin-right: 0.75rem;
  display: inline-flex;
  align-items: center;
}

.github-icon {
  vertical-align: middle;
  transition: opacity 0.2s;
}

.github-link:hover .github-icon {
  opacity: 0.7;
}

[data-theme="dark"] .github-icon path {
  fill: #5ba3f5;
}

nav {
  display: flex;
  align-items: center;
  gap: 0;
}

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

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

/* ── Theme Toggle ────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 1.75rem;
  height: 1.75rem;
  margin-left: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

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

.theme-toggle-icon {
  display: block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--color-text);
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}

/* Light mode: sun icon (filled circle with rays via box-shadow) */
:root .theme-toggle-icon {
  background: #888;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 3px #888;
}

/* Dark mode: moon icon (crescent via inset shadow) */
[data-theme="dark"] .theme-toggle-icon {
  background: transparent;
  box-shadow: inset -4px -2px 0 0 #e0e0e0;
}

/* ── Homepage ────────────────────────────────────────────── */

.intro {
  margin-bottom: 2.5rem;
}

.intro h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.intro p {
  color: var(--color-text-secondary);
  font-size: 1rem;
}

.recent-posts h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-heading-secondary);
}

/* ── Post Lists ──────────────────────────────────────────── */

.post-preview,
.post-entry {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
}

.post-preview a,
.post-entry a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.post-preview a:hover,
.post-entry a:hover {
  color: var(--color-link);
}

.post-preview time,
.post-entry time {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: 1rem;
}

.posts-list h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.posts-year {
  margin-bottom: 2rem;
}

.posts-year h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* ── Single Post ─────────────────────────────────────────── */

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

.post-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

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

.post-header .reading-time {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-left: 0.75rem;
}

.post-summary {
  color: var(--color-text-secondary);
  font-style: italic;
  margin-top: 0.5rem;
}

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

.post-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

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

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

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

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

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

.post-content blockquote {
  border-left: 3px solid var(--color-blockquote);
  padding-left: 1rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
}

.post-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

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

.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

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

/* ── Pages (Background, etc.) ────────────────────────────── */

.page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.page-content h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.page-content li {
  margin-bottom: 0.3rem;
}

.page-content a {
  color: var(--color-link);
  text-decoration: underline;
}

/* ── Footer ──────────────────────────────────────────────── */

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    gap: 0.5rem;
  }

  nav a {
    margin-left: 0;
    margin-right: 1rem;
  }

  .theme-toggle {
    margin-left: 1rem;
  }

  .post-preview,
  .post-entry {
    flex-direction: column;
    gap: 0.15rem;
  }

  .post-preview time,
  .post-entry time {
    margin-left: 0;
  }
}
