/* =====================================================
   CSS Custom Properties — Dark (default) & Light
   ===================================================== */

:root {
  --bg:           #1a1614;
  --bg-surface:   #2a2320;
  --bg-hover:     #352d29;
  --text:         #f4f3ee;
  --text-muted:   #bcb8b1;
  --accent:       #e0afa0;
  --accent-hover: #ecc4b8;
  --border:       #3d3530;
  --tag-bg:       #3a2e2b;
  --tag-text:     #e0afa0;
}

[data-theme="light"] {
  --bg:           #f4f3ee;
  --bg-surface:   #eae8e2;
  --bg-hover:     #d8d6d0;
  --text:         #463f3a;
  --text-muted:   #8a817c;
  --accent:       #a05a48;
  --accent-hover: #7d4336;
  --border:       #d8d6d0;
  --tag-bg:       #d8d6d0;
  --tag-text:     #463f3a;
}

/* =====================================================
   Reset & Base
   ===================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* =====================================================
   Layout
   ===================================================== */

.main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* =====================================================
   Navigation
   ===================================================== */

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

.nav {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav__title:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav__link {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}

.nav__link:hover {
  color: var(--text);
  background-color: var(--bg-hover);
  text-decoration: none;
}

/* =====================================================
   Theme Toggle
   ===================================================== */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.3rem 0.55rem;
  line-height: 1;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
}

.theme-toggle:hover {
  color: var(--text);
  background-color: var(--bg-hover);
  border-color: var(--text-muted);
}

/* Show sun icon in dark mode (clicking will switch to light) */
.theme-toggle__icon--dark  { display: inline; }
.theme-toggle__icon--light { display: none;   }

[data-theme="light"] .theme-toggle__icon--dark  { display: none;   }
[data-theme="light"] .theme-toggle__icon--light { display: inline; }

/* =====================================================
   Hero (Home Page)
   ===================================================== */

.hero {
  padding: 0.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.hero__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

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

.hero__github-link {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  transition: background-color 0.15s, color 0.15s;
}

.hero__github-link:hover {
  background-color: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

/* =====================================================
   Section Header
   ===================================================== */

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-header__title {
  font-size: 1.25rem;
  font-weight: 700;
}

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

.section-header__link:hover {
  color: var(--accent);
}

/* =====================================================
   Page Header (list pages)
   ===================================================== */

.page-header {
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.page-header__title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* =====================================================
   Post Preview Card
   ===================================================== */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-preview {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

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

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

.post-preview__image-link {
  flex-shrink: 0;
}

.post-preview__image {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.post-preview__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

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

.post-preview__title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

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

.post-preview__title a:hover {
  color: var(--accent);
}

.post-preview__summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.post-preview__read-more {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
}

.post-preview__read-more:hover {
  text-decoration: underline;
}

/* =====================================================
   Tags
   ===================================================== */

.post-preview__tags,
.post__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}

/* =====================================================
   Single Post
   ===================================================== */

.post__cover {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  display: block;
}

.post__header {
  padding-bottom: 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.post__meta time {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post__title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post__description {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Post body typography */
.post__content {
  font-size: 1rem;
  line-height: 1.8;
}

.post__content h2,
.post__content h3,
.post__content h4 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
}

.post__content h2 { font-size: 1.5rem; }
.post__content h3 { font-size: 1.25rem; }
.post__content h4 { font-size: 1.05rem; }

.post__content p {
  margin-bottom: 1.25rem;
}

.post__content ul,
.post__content ol {
  margin: 0 0 1.25rem 1.5rem;
}

.post__content li {
  margin-bottom: 0.35rem;
}

.post__content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--text-muted);
  font-style: italic;
}

.post__content code {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.875em;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

.post__content pre {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

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

.post__content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

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

.post__content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post__footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

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

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

/* =====================================================
   Footer
   ===================================================== */

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

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

.site-footer a:hover {
  color: var(--accent);
}

/* =====================================================
   Empty State
   ===================================================== */

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem 0;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 600px) {
  .post__title {
    font-size: 1.6rem;
  }

  .nav__link {
    padding: 0.3rem 0.5rem;
  }
}
