/* Typography improvements for Chinese content */
body {
  line-height: 1.8em;
  font-size: 16px;
}

main p {
  margin: 1.2em 0;
}

.page .container {
  padding: 0 20px;
}

article {
  padding: 2em 2.5em;
}

/* Fix footer */
.footer {
  position: relative;
  width: 100%;
}

/* Page fade-in */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.container {
  animation: fadeIn 0.5s ease-out;
}

/* Reading progress bar */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #b0956e, #d4a86a, #e8c47c);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* Hero card (first post on homepage) */
.hero-card {
  flex: 1 0 100% !important;
  max-width: calc(100% - 5px) !important;
  display: flex;
  align-items: stretch;
  min-height: 280px;
  padding: 0 !important;
  overflow: hidden;
  margin: 1em 0 0 5px;
  box-sizing: border-box;
}
.hero-content {
  flex: 1;
  padding: 2em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.hero-content h1 {
  font-size: 1.6em;
  margin: 0.3em 0;
  line-height: 1.3em;
}
.hero-summary {
  font-size: 1.05em;
  color: #555;
  margin-top: 0.5em;
}
.hero-image {
  flex: 0 0 40%;
  overflow: hidden;
}
.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (max-width: 600px) {
  .hero-card { flex-direction: column; min-height: auto; }
  .hero-image { flex: none; height: 200px; }
}

/* Card hover effects */
.list section {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  border-radius: 6px;
  overflow: hidden;
}
.list section:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Allow Chinese titles to wrap */
@media (min-width: 715px) {
  .article-list h1 { white-space: normal; text-overflow: unset; }
}

/* Floating TOC sidebar */
.single-container { position: relative; }
.toc-sidebar { display: none; }

@media (min-width: 1300px) {
  .toc-sidebar {
    display: block;
    position: absolute;
    right: -260px;
    top: 0;
    width: 240px;
  }
  .toc-sidebar-inner {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 1em;
    background: #faf8f4;
    border-radius: 8px;
    border: 1px solid #e8e4dc;
    font-size: 0.85em;
    line-height: 1.6;
  }
  .toc-sidebar-inner::-webkit-scrollbar { width: 3px; }
  .toc-sidebar-inner::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
  .toc-sidebar h4 {
    margin: 0 0 0.5em;
    font-size: 1em;
    color: #666;
    border-bottom: 1px solid #e8e4dc;
    padding-bottom: 0.4em;
  }
  .toc-sidebar #TableOfContents ul,
  .toc-sidebar #TOC ul { list-style: none; padding-left: 0.8em; margin: 0; }
  .toc-sidebar #TableOfContents > ul,
  .toc-sidebar #TOC > ul { padding-left: 0; }
  .toc-sidebar #TableOfContents a,
  .toc-sidebar #TOC a {
    color: #888;
    text-decoration: none;
    display: block;
    padding: 0.2em 0;
    border-left: 2px solid transparent;
    padding-left: 0.6em;
    transition: all 0.2s ease;
  }
  .toc-sidebar #TableOfContents a:hover,
  .toc-sidebar #TOC a:hover { color: #333; }
  .toc-sidebar #TableOfContents a.toc-active,
  .toc-sidebar #TOC a.toc-active {
    color: #b0956e;
    border-left-color: #b0956e;
    font-weight: 600;
  }
  /* Hide inline TOC when sidebar is visible */
  article > #TableOfContents,
  article > #TOC { display: none; }
}

/* Related posts */
.related-posts {
  margin: 2em 0;
  padding-top: 1.5em;
  border-top: 1px dashed #ddd;
}
.related-posts h3 { font-size: 1.1em; color: #666; margin-bottom: 1em; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1em;
}
.related-card {
  display: flex;
  flex-direction: column;
  padding: 1em;
  background: #faf8f4;
  border-radius: 6px;
  border: 1px solid #e8e4dc;
  text-decoration: none;
  color: #333;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.related-date { font-size: 0.8em; color: #999; }
.related-title { font-weight: 600; margin: 0.3em 0; line-height: 1.4; }
.related-tags { font-size: 0.75em; color: #b0956e; margin-top: auto; }

/* Timeline archive */
.timeline { position: relative; padding-left: 2em; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #b0956e, #d4c4a8);
}
.timeline-year { margin-bottom: 2em; }
.timeline-year-title {
  font-size: 1.6em;
  color: #b0956e;
  margin: 0 0 0.5em -1.5em;
  position: relative;
}
.timeline-year-title::before {
  content: "";
  position: absolute;
  left: -0.6em; top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  background: #b0956e;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #b0956e;
}
.timeline-month { margin-bottom: 1em; }
.timeline-month-title { font-size: 1em; color: #888; margin: 0.5em 0; }
.timeline-posts { list-style: none; padding: 0; margin: 0; }
.timeline-item {
  padding: 0.4em 0;
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.8em;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.65em; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  background: #d4c4a8;
  border-radius: 50%;
}
.timeline-date {
  font-size: 0.85em; color: #999;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.timeline-item a { color: #333; text-decoration: none; transition: color 0.15s; }
.timeline-item a:hover { color: #b0956e; }
.timeline-tags { font-size: 0.75em; color: #b0956e; flex-shrink: 0; }

/* Tag cloud */
.tag-cloud {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 0.6em; padding: 2em 0;
}
.tag-pill {
  display: inline-flex; align-items: center; gap: 0.3em;
  padding: 0.3em 0.8em;
  background: #f5f0e8; border: 1px solid #e0d8c8;
  border-radius: 20px; color: #555;
  text-decoration: none;
  transition: all 0.2s ease; line-height: 1.4;
}
.tag-pill:hover {
  background: #b0956e; color: #fff;
  border-color: #b0956e; transform: scale(1.05);
}
.tag-count {
  font-size: 0.7em;
  background: rgba(0, 0, 0, 0.08);
  padding: 0.1em 0.4em; border-radius: 10px;
}
.tag-pill:hover .tag-count { background: rgba(255, 255, 255, 0.25); }

/* Improved blockquote */
blockquote {
  border-left: 4px solid #b0956e;
  background: #faf8f4;
  padding: 0.8em 1.2em;
  margin: 1.2em 0;
  border-radius: 0 4px 4px 0;
}

/* Better code blocks */
pre { border-radius: 6px; border: 1px solid #e0ddd6; box-shadow: none; }
code { padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; }
pre code { padding: 1em; font-size: 0.85em; }

/* Links */
a { transition: color 0.15s ease; }
.header a:hover { opacity: 0.7; }

/* Images */
main img { border-radius: 4px; }

/* Banner hero with latest post image */
.banner-hero {
  position: relative;
  background-size: cover;
  background-position: center;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 1em;
}
.banner-overlay {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.5em 3em;
  border-radius: 12px;
  text-align: center;
}
.banner-title {
  font-size: 2.8em;
  font-weight: 700;
  color: #333;
  text-decoration: none;
  letter-spacing: 0.05em;
  display: block;
  line-height: 1.2;
}
.banner-subtitle {
  font-size: 1.1em;
  color: #666;
  margin: 0.3em 0 0;
  letter-spacing: 0.1em;
}

/* Reading info */
.reading-info {
  font-size: 0.85em;
  color: #999;
  margin-top: 0.5em;
}

/* Back to top button */
#back-to-top {
  position: fixed;
  bottom: 2em;
  right: 2em;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #b0956e;
  color: #fff;
  font-size: 1.3em;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#back-to-top:hover {
  background: #8a7550;
}

/* Pagination */
.pagination { padding-bottom: 40px; }

/* Mobile */
@media (max-width: 600px) {
  article { padding: 1.2em 1em; }
  .banner { font-size: 2.5em; }
  .list section { margin: 0.8em 0 0 0; }
  .thumbnail { height: 12em; }
  .timeline { padding-left: 1.5em; }
  .timeline-year-title { margin-left: -1em; }
  .related-grid { grid-template-columns: 1fr; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  body { background-color: #1a1a1a; color: #d4d4d4; }
  .header, .list section, article { background: #242424; }
  .header { border-top-color: #555; border-bottom-color: #555; }
  .article-list a, .banner a { color: #e0e0e0; }
  .categories a { color: #999; }
  .article-meta { background: #2a2a2a; }
  .hero-summary, .hero-summary a { color: #aaa; }
  .list section { box-shadow: 0 0 8px rgba(0,0,0,0.4); }
  .list section:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
  .footer { background: #333; }
  blockquote { background: #2a2820; border-left-color: #8a7550; }
  pre { border-color: #3a3a3a; }
  code { background: #2a2a2a; }
  hr { color: #444; }
  a { color: #6db3f2; }
  .header a, footer a { color: #ccc; }
  .footer, .footer a { color: #ddd; }
  img { opacity: 0.9; }
  #progress-bar { background: linear-gradient(90deg, #8a7550, #b0956e, #d4a86a); }
  .toc-sidebar-inner { background: #242424; border-color: #3a3a3a; }
  .toc-sidebar h4 { color: #999; border-bottom-color: #3a3a3a; }
  .toc-sidebar #TableOfContents a, .toc-sidebar #TOC a { color: #777; }
  .toc-sidebar #TableOfContents a:hover, .toc-sidebar #TOC a:hover { color: #ddd; }
  .related-card { background: #2a2a2a; border-color: #3a3a3a; color: #d4d4d4; }
  .related-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
  .timeline::before { background: linear-gradient(to bottom, #8a7550, #5a4a30); }
  .timeline-year-title { color: #d4a86a; }
  .timeline-year-title::before { background: #d4a86a; border-color: #242424; box-shadow: 0 0 0 2px #d4a86a; }
  .timeline-item::before { background: #8a7550; }
  .timeline-item a { color: #d4d4d4; }
  .timeline-item a:hover { color: #d4a86a; }
  .tag-pill { background: #2a2820; border-color: #3a3530; color: #ccc; }
  .tag-pill:hover { background: #8a7550; border-color: #8a7550; }
  .tag-count { background: rgba(255,255,255,0.1); }
  .banner-overlay { background: rgba(30, 30, 30, 0.8); }
  .banner-title { color: #e0e0e0; }
  .banner-subtitle { color: #aaa; }
  .reading-info { color: #777; }
  #back-to-top { background: #8a7550; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
  #back-to-top:hover { background: #d4a86a; }
}
