/* ===== YLF News — 三栏阅读界面 ===== */

/* --- 设计系统 --- */
:root {
  --bg-deep: #07070a;
  --bg-base: #0d0d12;
  --bg-surface: #14141a;
  --bg-elevated: #1c1c24;
  --bg-hover: #252530;
  --border-subtle: rgba(255,255,255,0.06);
  --border-medium: rgba(255,255,255,0.1);
  --text-primary: #e8e6e3;
  --text-secondary: #9a9894;
  --text-tertiary: #5c5a56;
  --accent: #f04e32;
  --accent-soft: rgba(240,78,50,0.15);
  --accent-glow: rgba(240,78,50,0.3);
  --success: #4ade80;
  --warning: #fbbf24;
  --font-mono: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --sidebar-left-w: 240px;
  --sidebar-right-w: 200px;
  --nav-h: 48px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg-deep: #f5f3f0;
    --bg-base: #faf8f5;
    --bg-surface: #ffffff;
    --bg-elevated: #f0ece6;
    --bg-hover: #eae5de;
    --border-subtle: rgba(0,0,0,0.06);
    --border-medium: rgba(0,0,0,0.1);
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent-soft: rgba(240,78,50,0.08);
    --accent-glow: rgba(240,78,50,0.15);
  }
}

:root[data-theme="light"] {
  --bg-deep: #f5f3f0;
  --bg-base: #faf8f5;
  --bg-surface: #ffffff;
  --bg-elevated: #f0ece6;
  --bg-hover: #eae5de;
  --border-subtle: rgba(0,0,0,0.06);
  --border-medium: rgba(0,0,0,0.1);
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent-soft: rgba(240,78,50,0.08);
  --accent-glow: rgba(240,78,50,0.15);
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: opacity 0.15s; }
a:hover { opacity: 0.85; }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}

/* --- 顶部导航 --- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(7,7,10,0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
}

:root[data-theme="light"] .site-header {
  background: rgba(250,248,245,0.85);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.site-brand:hover { text-decoration: none; opacity: 1; }

.site-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: block;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
  display: none;
}

@media (min-width: 768px) {
  .brand-tagline { display: inline; }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.site-nav a {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s;
}

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

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: all 0.2s;
}

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

/* --- 三栏布局 --- */
.app-layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar-left {
  width: var(--sidebar-left-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  padding: 20px 0;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
}

.sidebar-right {
  width: var(--sidebar-right-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  border-left: 1px solid var(--border-subtle);
  padding: 20px 16px;
}

/* 单栏布局（文章详情页） */
.app-layout.layout-single .main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* 非首页页面隐藏侧边栏，主内容区居中 */
body:not([data-page-layout="home"]) .sidebar-left,
body:not([data-page-layout="home"]) .sidebar-right {
  display: none;
}

body:not([data-page-layout="home"]) .main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* 移动端隐藏侧边栏 */
@media (max-width: 1024px) {
  .sidebar-left, .sidebar-right { display: none; }
  .main-content { padding: 20px; }
  body:not([data-page-layout="home"]) .main-content { padding: 20px; }
}

/* --- 左侧时间线导航 --- */
.timeline-header {
  padding: 0 16px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.timeline-month {
  margin-bottom: 4px;
}

.month-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.month-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.month-toggle.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.month-toggle .month-chevron {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-tertiary);
}

.month-toggle.collapsed .month-chevron {
  transform: rotate(-90deg);
}

.month-dates {
  padding: 2px 0 6px 24px;
}

.month-dates.collapsed {
  display: none;
}

.timeline-date {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 16px;
  margin: 2px 8px 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: inherit;
  width: calc(100% - 8px);
  text-align: left;
}

/* 时间线竖线 */
.timeline-date::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-medium);
  transition: all 0.2s;
}

.timeline-date::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-subtle);
  z-index: -1;
}

.timeline-date:first-child::after { top: 50%; }
.timeline-date:last-child::after { bottom: 50%; }

.timeline-date:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.timeline-date:hover::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.timeline-date.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.timeline-date.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.timeline-date .date-day {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  min-width: 32px;
}

.timeline-date .date-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* --- 中间内容区 --- */
.content-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.content-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.content-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 空状态 */
.news-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.news-empty p {
  color: var(--text-tertiary);
  font-size: 14px;
}

/* 新闻条目卡片 */
.news-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 14px;
  transition: all 0.2s;
}

.news-item:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.news-item-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.news-rank {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.news-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  flex: 1;
}

.news-title a {
  color: var(--text-primary);
}

.news-title a:hover {
  opacity: 1;
  color: var(--accent);
}

.news-score {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.news-score.high {
  background: var(--accent);
  color: #fff;
}

.news-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-tertiary);
}

.news-meta .meta-source {
  color: var(--text-secondary);
  font-weight: 500;
}

.news-meta .meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* 分类分组 */
.category-section {
  margin-bottom: 40px;
}

.category-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-section-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

.category-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

/* 卡片内参考链接 */
.news-references {
  margin: 10px 0 14px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
}

.news-references summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  user-select: none;
}

.news-references summary:hover {
  color: var(--text-primary);
}

.news-references ul {
  margin: 8px 0 4px 16px;
  padding: 0;
}

.news-references li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.news-references li a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 1px;
}

.news-references li a:hover {
  border-bottom-color: var(--accent);
  opacity: 1;
}

/* --- 右侧分类 TOC --- */
.toc-header {
  padding: 0 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toc-category {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-category:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.toc-category.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* --- 文章详情页 (post.html) --- */
.post-detail {
  max-width: 720px;
  margin: 0 auto;
}

.post-breadcrumb {
  margin-bottom: 24px;
  font-size: 13px;
}

.post-breadcrumb a {
  color: var(--text-secondary);
}

.post-detail h1 {
  font-size: 22px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.post-meta-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.post-body {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-primary);
}

.post-body h2 {
  font-size: 17px;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.post-body h3 {
  font-size: 15px;
  margin: 24px 0 12px;
}

.post-body p {
  margin-bottom: 14px;
}

.post-body a {
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 1px;
}

.post-body a:hover {
  border-bottom-color: var(--accent);
}

.post-body ul, .post-body ol {
  margin: 12px 0 16px 20px;
}

.post-body li {
  margin-bottom: 6px;
}

.post-body blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.post-body details {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.post-body summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.post-body details ul {
  margin-top: 10px;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.post-body pre {
  background: var(--bg-elevated);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 16px 0;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.tag-list {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  margin: 4px 4px 0 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 来源行 */
.source-line {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* 背景段落 */
.background-section {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}

/* 社区讨论链接 */
.community-links {
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.community-links a {
  margin-right: 10px;
}

/* --- 归档页面 --- */
.archive-page h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.archive-year {
  margin-bottom: 32px;
}

.archive-year > h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}

.archive-month {
  margin-bottom: 20px;
}

.archive-month > h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: none;
}

.archive-post {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

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

.archive-post-date {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  min-width: 48px;
}

.archive-post a {
  color: var(--text-primary);
  font-weight: 500;
}

.archive-post a:hover {
  color: var(--accent);
  opacity: 1;
}

/* --- 信息源页面 --- */
.sources-page h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.sources-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sources-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.2s;
}

.category-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.category-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.category-count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.category-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

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

.source-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-block;
}

.source-icon--twitter { background: #1da1f2; }
.source-icon--rss { background: #f26522; }
.source-icon--github { background: #6e7681; }
.source-icon--hackernews { background: #ff6600; }
.source-icon--reddit { background: #ff4500; }
.source-icon--telegram { background: #0088cc; }

/* --- Page (关于等) --- */
.post-detail h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.post-detail .post-body h2 {
  font-size: 18px;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.post-detail .post-body h3 {
  font-size: 15px;
  margin: 20px 0 10px;
}

.post-detail .post-body p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.post-detail .post-body strong {
  color: var(--text-primary);
}

.post-detail .post-body a {
  border-bottom: 1px solid var(--accent-soft);
}

.post-detail .post-body a:hover {
  border-bottom-color: var(--accent);
}

.post-detail .post-body ul,
.post-detail .post-body ol {
  margin: 12px 0 16px 20px;
}

.post-detail .post-body li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.post-detail .post-body code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.post-detail .post-body pre {
  background: var(--bg-elevated);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 16px 0;
}

.post-detail .post-body pre code {
  background: none;
  padding: 0;
}

.post-detail .post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.post-detail .post-body th,
.post-detail .post-body td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.post-detail .post-body th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.post-detail .post-body tr:hover td {
  background: var(--bg-hover);
}

/* --- Footer --- */
.site-footer {
  padding: 32px 40px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-subtle);
  margin-top: 40px;
}

/* --- 滚动条美化 --- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
