/* ==========================================================================
   Leo 睡眠实验室 · 周报共享样式
   从 index.html 抽取,所有页面共用
   ========================================================================== */

:root {
  --bg-page: #fafafa;
  --bg-card: #ffffff;
  --text-primary: #37352f;
  --text-secondary: #787774;
  --text-tertiary: #9b9a97;
  --divider: #e9e9e7;
  --accent: #5e6ad2;
  --tag-s-bg: #b91c1c;
  --tag-s-fg: #ffffff;
  --tag-a-bg: #d97706;
  --tag-a-fg: #ffffff;
  --tag-b-bg: #ffffff;
  --tag-b-fg: #6c6c6c;
  --tag-b-border: #6c6c6c;
  --code-bg: #f7f6f3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 20px 64px;
}

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

/* ==========================================================================
   Top Nav
   ========================================================================== */
.topnav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--divider);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  font-size: 13px;
}
.topnav-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.topnav-brand {
  font-weight: 600;
  color: var(--text-primary);
}
.topnav-week-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
.topnav-week-list a {
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}
.topnav-week-list a:hover {
  background: var(--bg-page);
  text-decoration: none;
}
.topnav-week-list a.current {
  background: var(--text-primary);
  color: var(--bg-card);
}
.topnav-extra {
  color: var(--text-secondary);
  padding: 4px 8px;
}
.topnav-extra:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ==========================================================================
   Week Banner (timeline & detail)
   ========================================================================== */
.week-banner {
  margin-top: 36px;
  padding: 20px 24px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--divider);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}
.timeline-section.current {
  margin-top: 8px;
  padding: 32px 28px 36px;
  background: linear-gradient(180deg, #eef0fc 0%, #f7f8fe 60%, #ffffff 100%);
  border-radius: 14px;
  border: 1px solid #c8d0f0;
  box-shadow: 0 4px 20px rgba(94, 106, 210, 0.1);
  position: relative;
}
.timeline-section.current::before {
  content: '本期';
  position: absolute;
  top: -10px;
  left: 20px;
  padding: 2px 12px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 1px;
}
.timeline-section.is-past {
  margin-top: 8px;
  padding: 20px 24px;
}
.week-banner.is-latest {
  background: linear-gradient(135deg, #ffffff 0%, #f5f4ff 100%);
  border-left: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(94, 106, 210, 0.08);
}
.week-banner-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg-page);
  color: var(--text-secondary);
  text-transform: uppercase;
}
.week-banner.is-latest .week-banner-tag {
  background: var(--accent);
  color: #ffffff;
}
.week-banner-id {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-left: 10px;
}
.week-banner-range {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 10px;
}
.week-banner-lead {
  flex-basis: 100%;
  margin: 6px 0 -2px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(94,106,210,0.08) 0%, rgba(94,106,210,0) 100%);
  border-left: 3px solid #5e6ad2;
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  font-weight: 500;
}
.week-banner-permalink {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.week-banner-permalink:hover { color: var(--accent); }

/* ==========================================================================
   Header (single week)
   ========================================================================== */
header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--divider);
}
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 14px 0;
  letter-spacing: -0.02em;
}
.lead {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  font-weight: 500;
  margin: 14px 0 10px;
  padding: 12px 16px 12px 18px;
  background: linear-gradient(90deg, rgba(94,106,210,0.06) 0%, rgba(94,106,210,0) 60%);
  border-left: 3px solid #5e6ad2;
  border-radius: 4px;
}
.lead-sub {
  font-size: 13px;
  line-height: 1.5;
  color: #4e5969;
  font-style: italic;
  opacity: 1;
  margin: 0 0 18px;
  padding: 0 16px 0 18px;
}
.banner-lead {
  display: block;
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(94,106,210,0.08) 0%, rgba(94,106,210,0) 100%);
  border-left: 3px solid #5e6ad2;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  font-weight: 500;
  margin: 16px 0 0;
}

/* ==========================================================================
   Sections
   ========================================================================== */
section {
  margin: 36px 0;
}
section > h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 14px 0;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(15, 15, 15, 0.05);
  border: 1px solid var(--divider);
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.card-meta .source { color: var(--text-secondary); font-weight: 500; }
.card-meta .dot { color: var(--text-tertiary); }
.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px 0;
  line-height: 1.4;
  letter-spacing: -0.005em;
}
.card h3 a { color: var(--text-primary); }
.card h3 a:hover { color: var(--accent); }
.card-summary {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 6px 0;
  line-height: 1.55;
}
.card-why {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
  padding-top: 6px;
  border-top: 1px dashed var(--divider);
  line-height: 1.5;
}
.card-why strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ==========================================================================
   Tags
   ========================================================================== */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 18px;
  text-align: center;
  vertical-align: middle;
}
.tag-s { background: var(--tag-s-bg); color: var(--tag-s-fg); }
.tag-a { background: var(--tag-a-bg); color: var(--tag-a-fg); }
.tag-b {
  background: var(--tag-b-bg);
  color: var(--tag-b-fg);
  border: 1px solid var(--tag-b-border);
}

/* ==========================================================================
   Leo Angles
   ========================================================================== */
.leo-angles {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 16px 20px;
  margin-top: 32px;
  border: 1px solid var(--divider);
}
.leo-angles h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
}
.angle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.angle-item {
  padding: 10px 12px;
  background: var(--bg-page);
  border-radius: 4px;
  border: 1px solid var(--divider);
}
.angle-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.angle-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.angle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  line-height: 1.4;
}
.angle-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ==========================================================================
   Footer / Sources
   ========================================================================== */
footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
}
footer h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 10px 0;
}
.source-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 16px;
}
.source-grid a {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
  display: block;
}
.source-grid a:hover { color: var(--accent); }

.archive-note {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ==========================================================================
   Timeline (main page only)
   ========================================================================== */
.timeline-intro {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0 0 8px 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.archive-stats {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 10px;
  flex-wrap: wrap;
}
.archive-stats span strong { color: var(--text-secondary); font-weight: 600; }

/* ==========================================================================
   Search & Filters (main page only)
   ========================================================================== */
.search-wrap {
  margin: 24px 0 12px;
  position: relative;
}
.search-wrap input[type="search"] {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap input[type="search"]::placeholder {
  color: var(--text-tertiary);
}
.search-wrap input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.15);
}
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.7;
}

.filter-chips {
  display: flex;
  gap: 6px;
  margin: 12px 0 24px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--divider);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
  background: var(--bg-card);
  border: 1px dashed var(--divider);
  border-radius: 8px;
  margin: 24px 0;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(94, 106, 210, 0.3);
  z-index: 50;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  transform: translateY(-2px);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 600px) {
  main { padding: 28px 16px 56px; }
  h1 { font-size: 28px; }
  .lead { font-size: 15px; }
  section > h2 { font-size: 18px; }
  .card { padding: 12px 14px; }
  .angle-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr; }
  .week-banner { padding: 14px 16px; }
  .topnav-week-list { margin-left: 0; width: 100%; }
}
