/* ============================================================
   Paper Survey Site — Academic Style CSS
   ============================================================ */

:root {
  --color-primary: #2c5282;
  --color-primary-light: #ebf4ff;
  --color-accent: #e15759;
  --color-text: #1a202c;
  --color-text-secondary: #4a5568;
  --color-border: #e2e8f0;
  --color-bg: #ffffff;
  --color-bg-alt: #f7fafc;
  --color-code-bg: #edf2f7;
  --color-nav-bg: #2c5282;
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --max-width: 960px;
  --max-width-wide: 1200px;
}

[data-theme="dark"] {
  --color-primary: #63b3ed;
  --color-primary-light: #1a365d;
  --color-accent: #fc8181;
  --color-text: #e2e8f0;
  --color-text-secondary: #a0aec0;
  --color-border: #2d3748;
  --color-bg: #1a202c;
  --color-bg-alt: #2d3748;
  --color-code-bg: #2d3748;
  --color-nav-bg: #1a365d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #63b3ed;
    --color-primary-light: #1a365d;
    --color-accent: #fc8181;
    --color-text: #e2e8f0;
    --color-text-secondary: #a0aec0;
    --color-border: #2d3748;
    --color-bg: #1a202c;
    --color-bg-alt: #2d3748;
    --color-code-bg: #2d3748;
    --color-nav-bg: #1a365d;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  font-size: 15px;
}

/* --- Navigation --- */

.site-nav {
  background: var(--color-nav-bg);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* --- Layout --- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.viz-page .container,
.viz-page.container { max-width: var(--max-width-wide); }

/* Override container for viz page */
main.container:has(.viz-page) { max-width: var(--max-width-wide); }

/* --- Report Content --- */

.report h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.report h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.report h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--color-text);
}

.report p {
  margin: 0.6rem 0;
}

.report blockquote {
  border-left: 4px solid var(--color-primary);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--color-primary-light);
  border-radius: 0 4px 4px 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.report ul, .report ol {
  margin: 0.5rem 0 0.5rem 1.5rem;
}

.report li {
  margin: 0.25rem 0;
}

.report table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.report th, .report td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
}

.report th {
  background: var(--color-bg-alt);
  font-weight: 600;
}

.report tr:nth-child(even) td {
  background: var(--color-bg-alt);
}

.report code {
  font-family: var(--font-mono);
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}

.report pre {
  background: #1a202c;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.report pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.report hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

/* --- Citations --- */

.citation {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  padding: 0.05em 0.2em;
  border-radius: 3px;
  transition: background 0.15s;
}

.citation:hover {
  background: var(--color-primary-light);
  text-decoration: underline;
}

.citation-paywalled {
  color: var(--color-text-secondary);
  font-style: italic;
}

/* --- Paper Detail --- */

.paper-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}

.paper-id-badge {
  display: inline-block;
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.paper-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0.5rem 0;
  line-height: 1.3;
  color: var(--color-text);
}

.paper-meta {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.paper-meta a { color: var(--color-primary); }

/* --- Badges --- */

.badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.badge-type { background: #dbeafe; color: #1e40af; }
.badge-scope { background: #dcfce7; color: #166534; }
.badge-auto { background: #fef3c7; color: #92400e; }
.badge-framework { background: #f3e8ff; color: #6b21a8; }
.badge-planning { background: #ffe4e6; color: #9f1239; }

/* --- Tags --- */

.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.5rem 0; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.tag-model { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.tag-tool { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.badge-link, .tag-link {
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.badge-link:hover, .tag-link:hover {
  opacity: 0.85;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* --- Paper Sections --- */

.paper-section {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.paper-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--color-primary);
}

.paper-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
  color: var(--color-text);
}

.paper-section p { margin: 0.4rem 0; }
.paper-section ul { margin: 0.4rem 0 0.4rem 1.25rem; }
.paper-section li { margin: 0.2rem 0; font-size: 0.95rem; }

/* --- Phase Bar --- */

.phase-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0;
}

.phase-cell {
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.78rem;
  background: var(--color-border);
  color: var(--color-text-secondary);
  text-transform: capitalize;
}

.phase-cell.phase-active {
  background: var(--color-primary);
  color: white;
}

/* --- Paper Navigation --- */

.paper-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
}

.paper-nav-link {
  text-decoration: none;
  color: var(--color-primary);
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-width: 48%;
  transition: border-color 0.15s;
}

.paper-nav-link:hover { border-color: var(--color-primary); }

.paper-nav-link .nav-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.2rem;
}

.paper-nav-link .nav-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paper-nav-link.next { text-align: right; }

/* --- Papers Index --- */

.papers-index h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--color-text-secondary); margin-bottom: 1.5rem; }

.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input, .filter-select {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text);
}

.search-input { flex: 1; min-width: 200px; }
.search-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
}

.paper-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.paper-card {
  display: block;
  text-decoration: none;
  color: var(--color-text);
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: all 0.15s;
}

.paper-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(44, 82, 130, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.card-id {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 0.9rem;
}

.card-year {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.card-authors {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badges {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

/* --- Visualization Page --- */

.viz-page { max-width: var(--max-width-wide); }

.viz-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.viz-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.chart-container { position: relative; width: 100%; max-height: 500px; }
.chart-small { max-height: 350px; }

.viz-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

/* --- Heatmap --- */

.heatmap-container { overflow-x: auto; }

.heatmap-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
}

.heatmap-table th, .heatmap-table td {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  text-align: center;
}

.heatmap-table th {
  background: var(--color-primary);
  color: white;
  font-weight: 500;
}

.phase-header { writing-mode: horizontal-tb; white-space: nowrap; }

.paper-label {
  text-align: left !important;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-label a { color: var(--color-primary); text-decoration: none; font-weight: 600; }

.heatmap-cell { width: 60px; }

.phase-covered {
  background: var(--color-primary);
  color: white;
  font-weight: bold;
}

.summary-row td { font-weight: 700; }
.summary-cell { background: var(--color-primary-light) !important; color: var(--color-primary); }

/* --- Graph --- */

.graph-container {
  width: 100%;
  min-height: 500px;
  position: relative;
  overflow: hidden;
}

.graph-container svg {
  display: block;
  width: 100%;
  height: auto;
}

.placeholder {
  text-align: center;
  color: var(--color-text-secondary);
  padding: 3rem;
  font-style: italic;
}

/* --- Footer --- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-footer a { color: var(--color-primary); }

/* --- Theme Toggle --- */

.theme-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
}

.theme-toggle:hover {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* Dark mode badge adjustments */
[data-theme="dark"] .badge-type { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-scope { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-auto { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-framework { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .badge-planning { background: #4c0519; color: #fda4af; }

[data-theme="dark"] .report pre {
  background: #0d1117;
  color: #e2e8f0;
}

/* --- Language Switching --- */

[data-lang="zh"] .lang-en {
  display: none !important;
}
[data-lang="en"] .lang-zh {
  display: none !important;
}

/* Fallback: if data-lang is not set, show zh */
html:not([data-lang]) .lang-en {
  display: none;
}
html:not([data-lang]) .lang-zh {
  display: block;
}

.lang-toggle-container {
  display: flex;
  gap: 0.25rem;
  margin-left: 1rem;
  background: rgba(255,255,255,0.1);
  padding: 0.2rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
}

.lang-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}

.lang-btn:hover {
  color: white;
}

.lang-btn.active {
  background: white;
  color: var(--color-primary);
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .nav-inner { padding: 0 1rem; }
  .nav-links a { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
  .container { padding: 1rem; }
  .viz-grid { grid-template-columns: 1fr; }
  .paper-cards { grid-template-columns: 1fr; }
  .paper-nav { flex-direction: column; }
  .paper-nav-link { max-width: 100%; }
  .report h1 { font-size: 1.4rem; }
  .report h2 { font-size: 1.2rem; }
}

/* --- Print --- */

@media print {
  .site-nav, .site-footer, .paper-nav, .filter-bar { display: none; }
  .container { max-width: 100%; padding: 0; }
  .paper-section { break-inside: avoid; }
  .citation { color: var(--color-primary); }
}
