/* ============================================================
   Leowh Blog — Editorial Design System
   Type-driven. Minimal. Black and white.
   ============================================================ */

:root {
  --bg:            #FCFCFB;
  --surface:       #F6F6F4;
  --text-primary:  #1A1A1A;
  --text-secondary:#555555;
  --text-tertiary: #8A8A8A;
  --text-subtle:   #B0B0B0;
  --text-muted:    #999999;
  --text-quiet:    #B0B0B0;
  --border:        #E8E6E3;
  --border-light:  #F0EEEC;
  --border-hover:  #CCCCCC;
  --accent:        #1A1A1A;
  --highlight:     #1A1A1A;
  --tag-bg:        #F0EEEC;
  --tag-text:      #666666;
  --font-serif:    'DM Serif Display', Georgia, serif;
  --font-sans:     'Inter', 'Noto Sans SC', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --sidebar-w:     264px;
  --content-max-w: 632px;
  --gap:           72px;
  --radius:        4px;
  --radius-sm:     6px;
  --radius-full:   9999px;
}

html { scroll-behavior: smooth; }
::selection { background: rgba(0,0,0,0.08); }

.blog-body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-secondary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* —————————————————————————————
   1. HERO
   ————————————————————————————— */
.blog-hero {
  text-align: left;
  max-width: 640px;
  margin: 0 auto;
  padding: 7rem 24px 4rem;
}
.blog-hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 2.5rem;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
}
.blog-hero .hero-sub {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-bottom: 2.5rem;
  max-width: 480px;
}

/* Search */
.hero-search-wrap {
  position: relative;
  max-width: 320px;
}
.hero-search-wrap input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  font-weight: 400;
  background: transparent;
  color: var(--text-primary);
  padding: 10px 32px 10px 0;
  border-radius: 0;
  transition: border-color 0.2s;
}
.hero-search-wrap input::placeholder {
  color: var(--text-quiet);
}
.hero-search-wrap input:focus {
  border-bottom-color: var(--text-primary);
}
.hero-search-wrap svg {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-quiet);
  pointer-events: none;
}

@media (max-width: 640px) {
  .blog-hero { padding: 5rem 20px 3rem; }
  .blog-hero h1 { font-size: 1.75rem; }
  .blog-hero .hero-sub { font-size: 0.9rem; }
}


/* —————————————————————————————
   2. TWO-COLUMN LAYOUT
   ————————————————————————————— */
.blog-layout {
  max-width: calc(var(--content-max-w) + var(--gap) + var(--sidebar-w));
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: var(--gap);
  flex: 1;
}
.blog-main {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max-w);
  padding-top: 3rem;
  padding-bottom: 64px;
}
.blog-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding-top: 3rem;
  padding-bottom: 64px;
  position: relative;
  padding-left: 28px;
}
.blog-sidebar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2rem;
  bottom: 2rem;
  width: 1px;
  background: var(--border-light);
}
.blog-sidebar-inner {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

@media (max-width: 1064px) {
  .blog-layout {
    flex-direction: column;
    max-width: var(--content-max-w);
    gap: 0;
  }
  .blog-sidebar {
    width: 100%;
    padding-top: 0;
    border-top: 1px solid var(--border-light);
    margin-top: 2rem;
    padding-top: 2rem;
  }
  .blog-sidebar-inner {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}
@media (max-width: 540px) {
  .blog-sidebar-inner { grid-template-columns: 1fr; }
}


/* —————————————————————————————
   3. FEED HEADING
   ————————————————————————————— */
.feed-heading {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-quiet);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}


/* —————————————————————————————
   4. ARTICLE LIST CARDS
   ————————————————————————————— */
.article-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 28px 0;
  border-bottom: 1px solid var(--border-light);
}
.article-card:first-of-type { padding-top: 0; }
.article-card:hover {
  background: transparent;
}

.article-card .card-author {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.article-card .card-author .sep {
  color: var(--border);
  font-weight: 400;
}
.article-card .card-date {
  font-size: 0.78rem;
  color: var(--text-quiet);
  font-weight: 400;
}

.article-card h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  transition: color 0.15s;
}
.article-card:hover h3 { color: var(--text-primary); }

.article-card .card-excerpt {
  font-size: 0.88rem;
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.card-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0;
  background: transparent;
  color: var(--text-quiet);
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.card-tag:hover {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
  background: transparent;
}

.article-card-img {
  width: 100%;
  aspect-ratio: 800 / 420;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  margin-top: 0.75rem;
  background: var(--border);
}


/* —————————————————————————————
   5. LOAD MORE
   ————————————————————————————— */
.load-more-wrap {
  text-align: center;
  margin-top: 2.5rem;
}
.load-more-btn {
  display: inline-block;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 1px solid var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: -0.01em;
}
.load-more-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.articles-stats {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--text-quiet);
}


/* —————————————————————————————
   6. FILTER RESET BAR
   ————————————————————————————— */
.filter-reset-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}
.filter-reset-btn {
  font-size: 0.82rem;
  color: var(--text-primary);
  background: none;
  border: none;
  border-bottom: 1px solid var(--text-primary);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
}
.filter-reset-btn:hover { opacity: 0.7; }


/* —————————————————————————————
   7. SKELETON LOADING
   ————————————————————————————— */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  padding: 28px 0;
  border-bottom: 1px solid var(--border-light);
}
.skeleton-line {
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(90deg, #eee 25%, #e8e8e8 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  margin-bottom: 12px;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line--sm  { width: 25%; }
.skeleton-line--md  { width: 60%; }
.skeleton-line--lg  { width: 85%; }


/* —————————————————————————————
   8. SIDEBAR — Tags
   ————————————————————————————— */
.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-quiet);
  margin-bottom: 12px;
}
.sidebar-tags {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-tag {
  display: block;
  font-size: 0.88rem;
  padding: 0;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: 0;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.15s;
  text-align: left;
  line-height: 1.5;
}
.sidebar-tag:hover {
  color: var(--text-primary);
}
.sidebar-tag .tag-count {
  font-size: 0.72rem;
  color: var(--text-quiet);
  margin-left: 2px;
  font-weight: 400;
}

/* ============================================================
   13. PROSE — Article detail pages
   ============================================================ */
.prose {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-secondary);
}
.prose h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.75rem;
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 0.85rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.prose h3 {
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.45;
}
.prose p { margin-bottom: 1.35rem; font-weight: 400; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose ul, .prose ol {
  margin-bottom: 1.35rem;
  padding-left: 1.4rem;
  color: var(--text-secondary);
}
.prose li { margin-bottom: 0.4rem; }
.prose blockquote {
  border-left: 2px solid var(--border-hover);
  padding: 0.4rem 0 0.4rem 1.25rem;
  margin: 1.6rem 0;
  color: var(--text-muted);
  font-style: italic;
}
.prose blockquote p { margin-bottom: 0; }
.prose a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-hover);
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s;
}
.prose a:hover { text-decoration-color: var(--accent); color: var(--accent); }
.prose code {
  background: var(--tag-bg);
  color: var(--text-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: var(--font-mono);
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.prose pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.prose hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.5rem 0;
}

/* ---- Article header tags ---- */
.article-header-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.article-header-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.2rem 0.65rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: var(--radius-full);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}
.article-header-tag:hover { background: var(--border); }

/* ---- Article footer tags ---- */
.article-footer-tags {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.article-footer-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.2rem 0.65rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: var(--radius-full);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
  cursor: pointer;
}
.article-footer-tag:hover { background: var(--border); }

/* ---- Article header: back link ---- */
.article-back-link {
  position: absolute;
  top: -0.5rem;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: #52525B;
  text-decoration: none;
  border: 1px solid #E4E4E7;
  background: #FAFAFA;
  transition: all 0.2s;
}
.article-back-link:hover {
  border-color: #D4D4D8;
  background: #F4F4F5;
  color: #1E293B;
}
.article-back-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* 防止长标题与右上角返回按钮重叠 */
.article-back-link ~ h1 {
  padding-right: 90px;
}

/* ---- Article header: subtitle ---- */
.article-header-subtitle {
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 300;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* ---- Article header: author meta ---- */
.article-author-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.article-author-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.article-meta-sep {
  color: var(--text-subtle);
  font-size: 0.75rem;
}
.article-meta-label {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

/* ---- Article cover image ---- */
.article-cover {
  width: 100%;
  aspect-ratio: 800 / 420;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--border);
  margin: 1.25rem 0 1.5rem;
}

/* ---- Related articles ---- */
.related-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--border);
}
.related-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
}
.related-card {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-light);
}
.related-card:last-of-type { border-bottom: none; }
.related-card-tags { margin-bottom: 0.4rem; }
.related-tag {
  font-size: 0.72rem;
  color: var(--text-quiet);
  margin-right: 8px;
}
.related-card-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.02em;
  transition: color 0.15s;
}
.related-card:hover .related-card-title {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-hover);
}
.related-card-excerpt {
  font-size: 0.88rem;
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-top: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Heading anchor links ---- */
.prose h2, .prose h3 { position: relative; }
.heading-anchor {
  position: absolute;
  left: -1.15em;
  top: 0;
  opacity: 0;
  color: var(--text-subtle);
  text-decoration: none;
  font-weight: 400;
  font-family: var(--font-sans);
  font-size: 0.85em;
  transition: opacity 0.2s;
  line-height: inherit;
}
.prose h2 .heading-anchor { padding-top: 0.15em; }
.prose h3 .heading-anchor { padding-top: 0.05em; }
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--text-secondary); }

/* ---- TOC for article pages ---- */
.toc-container {
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toc-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin-bottom: 0.35rem; }
.toc-list li:last-child { margin-bottom: 0; }
.toc-list a {
  display: block;
  padding: 0.25rem 0;
  padding-left: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}
.toc-list a:hover,
.toc-list a.toc-active {
  color: var(--text-primary);
  border-left-color: var(--accent);
}

@media (min-width: 1280px) {
  .toc-container {
    position: fixed;
    top: 120px;
    left: max(24px, calc(50vw - 618px));
    width: 170px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
  }
  .toc-title {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    margin-bottom: 1rem;
    font-family: var(--font-sans);
  }
  .toc-list a {
    font-size: 0.8rem;
    padding: 0.35rem 0;
    padding-left: 0.65rem;
    border-left-width: 1.5px;
  }
  .toc-container::-webkit-scrollbar { width: 3px; }
  .toc-container::-webkit-scrollbar-track { background: transparent; }
  .toc-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
}

/* ============================================================
   14. RESPONSIVE — Prose on mobile
   ============================================================ */
@media (max-width: 640px) {
  .prose { font-size: 1rem; }
  .prose h2 { font-size: 1.45rem; margin-top: 2.2rem; }
  .prose h3 { font-size: 1.05rem; }
}

/* ============================================================
   15. PRINT STYLES
   ============================================================ */
@media print {
  #header, #global-nav, header, nav,
  #global-footer, footer,
  .toc-container, .adsbygoogle,
  .blog-sidebar, .blog-hero, .feed-heading,
  .load-more-wrap, .adsbygoogle {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; }
  .prose, article, main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .prose { font-size: 11pt; line-height: 1.7; color: #000; }
  .prose h2 { font-size: 16pt; color: #000; page-break-after: avoid; }
  .prose h3 { font-size: 13pt; color: #000; page-break-after: avoid; }
  .prose a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em; color: #666;
  }
  .prose a[href^="#"]::after { content: none; }
}
