/* ============================================================
   合成生物学市场情报周报 - 站点样式
   现代化设计：暗色模式、响应式、卡片布局、打印支持
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --bg: #f0f2f5;
  --bg-alt: #ffffff;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #4a4a68;
  --muted: #8892a6;
  --accent: #0f766e;
  --accent-light: #14b8a6;
  --accent-bg: rgba(15, 118, 110, 0.08);
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 960px;
  --header-height: 60px;
  --tag-bg: #eef2f5;
  --tag-text: #4a4a68;
  --code-bg: #f8f9fa;
  --table-stripe: #f8fafc;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-alt: #1a1b26;
  --card: #1e1f2b;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --muted: #71717a;
  --accent: #2dd4bf;
  --accent-light: #5eead4;
  --accent-bg: rgba(45, 212, 191, 0.1);
  --border: #2e2f3d;
  --border-light: #252633;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
  --tag-bg: #2e2f3d;
  --tag-text: #a1a1aa;
  --code-bg: #252633;
  --table-stripe: #1a1b26;
  --danger: #f87171;
  --warning: #fbbf24;
  --success: #34d399;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.75;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-ososx-font-smoothing: grayscale;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-light); text-decoration: underline; }

/* ---------- 头部导航 ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-height);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header .brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-header nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.site-header nav a:hover {
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
}

.site-header nav a.active {
  background: var(--accent-bg);
  color: var(--accent);
}

/* 主题切换按钮 */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  margin-left: 8px;
}

.theme-toggle:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 主内容区 ---------- */
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.content-narrow {
  max-width: 720px;
}

/* ---------- 标题层级 ---------- */
h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 0.5em;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2em 0 0.8em;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5em 0 0.6em;
  color: var(--text-secondary);
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.2em 0 0.5em;
  color: var(--text-secondary);
}

p { margin: 0.6em 0; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h2 { margin-top: 0; }

.card-compact {
  padding: 16px 20px;
}

/* ---------- 仪表盘卡片网格 ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.metric-card .metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.metric-card .metric-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.metric-card .metric-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--accent-light);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.btn-sm {
  padding: 5px 14px;
  font-size: 0.82rem;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}

.tag-accent {
  background: var(--accent-bg);
  color: var(--accent);
}

.tag-warning {
  background: rgba(217, 119, 6, 0.12);
  color: var(--warning);
}

.tag-success {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
}

/* ---------- 列表 ---------- */
ul, ol {
  padding-left: 1.5em;
  margin: 0.6em 0;
}

li { margin: 0.3em 0; }

/* ---------- 表格 ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.88rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

tbody tr:hover {
  background: var(--accent-bg);
}

/* ---------- 引用 ---------- */
blockquote {
  margin: 14px 0;
  padding: 10px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---------- 代码 ---------- */
code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--border);
}

pre code {
  background: none;
  padding: 0;
}

/* ---------- 分割线 ---------- */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 24px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ---------- 密码门禁 ---------- */
.gate {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.gate-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  width: min(380px, 90vw);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.gate-box h1 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.gate-box p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.gate-box input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gate-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.gate-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.gate-box button:hover {
  background: var(--accent-light);
}

.gate-box button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pw-msg {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 8px 0 0;
}

.gate-hint {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- 搜索框 ---------- */
.search-box {
  position: relative;
  margin-bottom: 20px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.search-box::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-box::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 55%;
  width: 2px;
  height: 7px;
  background: var(--muted);
  border-radius: 1px;
  transform: rotate(-45deg);
  pointer-events: none;
}

/* ---------- 目录导航 ---------- */
.toc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc li {
  margin: 4px 0;
}

.toc a {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.toc a:hover {
  color: var(--accent);
}

.toc .toc-h2 { padding-left: 0; }
.toc .toc-h3 { padding-left: 16px; font-size: 0.82rem; }

/* ---------- 报告元信息 ---------- */
.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--muted);
}

.report-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- 归档列表 ---------- */
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.archive-item:hover {
  box-shadow: var(--shadow);
  transform: translateX(2px);
}

.archive-item .archive-date {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  white-space: nowrap;
}

.archive-item .archive-desc {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0 16px;
  flex: 1;
}

.archive-item .archive-link {
  white-space: nowrap;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* ---------- 返回顶部 ---------- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 90;
  box-shadow: var(--shadow-lg);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  transform: translateY(-2px);
  background: var(--accent-light);
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .content { padding: 20px 16px 40px; }
  .site-header { padding: 0 16px; }
  .site-header .brand { font-size: 0.9rem; }
  .site-header nav a { padding: 6px 10px; font-size: 0.85rem; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
  .card { padding: 18px 20px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .archive-item { flex-direction: column; align-items: flex-start; gap: 6px; }
  .archive-item .archive-desc { margin: 0; }
  table { font-size: 0.82rem; }
  th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .site-header nav { gap: 0; }
  .site-header nav a { padding: 6px 8px; font-size: 0.8rem; }
}

/* ---------- 打印样式 ---------- */
@media print {
  .site-header, .site-footer, .gate, .back-to-top, .toc, .search-box, .theme-toggle { display: none !important; }
  .content { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: none; page-break-inside: avoid; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: underline; }
  a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  h2 { page-break-after: avoid; }
  table { font-size: 10pt; }
  .report-meta { display: none; }
}

/* ---------- 加载动画 ---------- */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 淡入动画 ---------- */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ICP filing link in footer */
.site-footer .icp { color: inherit; text-decoration: none; margin-left: .5em; }
.site-footer .icp:hover { text-decoration: underline; }
