/* ========================================
   iBooks-inspired Blog Theme
   ======================================== */

/* --- CSS Variables --- */
:root {
  /* Light mode (warm parchment) */
  --bg: #faf6ef;
  --bg-secondary: #f2ece3;
  --text: #3b3330;
  --text-secondary: #8a7e76;
  --text-muted: #b0a89f;
  --accent: #8b5e3c;
  --border: #e2dbd2;
  --code-bg: #f0ebe4;
  --code-border: #e0d9cf;
  --shadow: rgba(139, 94, 60, 0.06);
}

[data-theme="dark"] {
  --bg: #1c1a17;
  --bg-secondary: #262320;
  --text: #d4cfc8;
  --text-secondary: #8a8279;
  --text-muted: #5e574f;
  --border: #3a3530;
  --code-bg: #23201d;
  --code-border: #3a3530;
  --shadow: rgba(0, 0, 0, 0.2);
  --accent: #c4956a;
}

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

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

body {
  font-family: sohne, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.54;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Layout --- */
.site-wrapper {
  max-width: 728px;
  margin: 0 auto;
  padding: 0 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-wrapper > main {
  flex: 1;
}

/* --- Header --- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

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

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  padding: 0.25rem 0;
  line-height: 1;
  transition: color 0.2s;
}

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

.nav-icon {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

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

/* --- Homepage --- */
.page-heading {
  font-size: 1.6rem;
  font-weight: 400;
  margin-bottom: 2.5rem;
  letter-spacing: 0.01em;
}

.post-list {
  list-style: none;
}

.post-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

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

.post-item:first-child {
  padding-top: 0;
}

.post-item-title {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.post-item-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

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

.post-item-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 0.8rem;
  display: block;
}

.post-item-excerpt {
  font-family: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, "Noto Serif SC", serif;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.75;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Article --- */
.article-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-size: 2.625rem;
  font-weight: 700;
  line-height: 1.238;
  margin-bottom: 0.8rem;
  letter-spacing: -0.011em;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.article-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.article-tags {
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.article-tags li {
  font-size: 0.75rem;
  background: var(--bg-secondary);
  padding: 0.15rem 0.6rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.article-tags li a {
  color: var(--accent);
  text-decoration: none;
}

/* --- Article Content --- */
.article-content {
  font-family: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, "Noto Serif SC", serif;
  font-size: 20px;
  line-height: 1.6;
  letter-spacing: -0.003em;
}

.article-content p {
  margin-bottom: 2rem;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: sohne, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: normal;
}

.article-content h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.016em;
  margin-top: 3rem;
  margin-bottom: 1rem;
}

.article-content h3 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 2.5rem;
  margin-bottom: 0.8rem;
}

.article-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 0.15em;
  transition: text-decoration-color 0.2s;
}

.article-content a:hover {
  text-decoration-color: var(--accent);
}

.article-content blockquote {
  margin: 2rem 0;
  padding: 0.1rem 1.5rem;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
  font-style: italic;
}

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

.article-content li {
  margin-bottom: 0.4rem;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 2rem 0;
  display: block;
}

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

/* --- Code --- */
.article-content code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--code-border);
}

.article-content pre {
  margin: 2rem 0;
  padding: 1.2rem 1.5rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  overflow-x: auto;
  line-height: 1.6;
}

.article-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
}

/* --- Tags Page --- */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  margin-bottom: 3rem;
}

.tags-list li a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--bg-secondary);
  padding: 0.3rem 0.8rem;
  border-radius: 3px;
  transition: color 0.2s, background 0.2s;
}

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

.tag-section {
  margin-bottom: 2.5rem;
}

.tag-section-title {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.tag-section ul {
  list-style: none;
}

.tag-section li {
  padding: 0.4rem 0;
}

.tag-section a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

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

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

/* --- Footer --- */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

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

  .site-header {
    padding: 1.5rem 0 1.2rem;
    margin-bottom: 2rem;
  }

  .article-title {
    font-size: 32px;
    letter-spacing: -0.014em;
  }

  .article-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }

  .post-item {
    padding: 1.5rem 0;
  }

  .article-content pre {
    padding: 1rem;
    border-radius: 0;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    width: calc(100% + 3rem);
  }
}
