/* ======================================
   thesis-backtester showcase site
   ====================================== */

:root {
  --header-bg: #1a1a2e;
  --header-text: #e0e0e0;
  --accent: #4a90d9;
  --accent-hover: #357abd;
  --accent-light: #e8f0fe;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- Header ---- */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.site-header .tagline {
  font-size: 1rem;
  color: #9ca3af;
  margin-bottom: 1rem;
}

.site-header .gh-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.site-header .gh-link:hover {
  color: #fff;
}

.gh-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ---- Tabs ---- */
.tab-bar {
  display: flex;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tab-btn {
  padding: 0.85rem 1.5rem;
  border: none;
  background: none;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--accent);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---- Tab Content ---- */
.tab-panel {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-panel.active {
  display: block;
}

/* ---- Search & Filters ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.search-box {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.search-box:focus {
  border-color: var(--accent);
}

.filter-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text-muted);
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.count-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* ---- Operator Cards Grid ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.op-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.op-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.op-card .card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.op-card .op-name {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
}

.op-card .op-id {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.category-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.cat-screening { background: #dbeafe; color: #1e40af; }
.cat-fundamental { background: #dcfce7; color: #166534; }
.cat-valuation { background: #fef3c7; color: #92400e; }
.cat-decision { background: #fce7f3; color: #9d174d; }
.cat-forward_risk { background: #ede9fe; color: #5b21b6; }
.cat-special { background: #f1f5f9; color: #475569; }
.cat-bank { background: #ccfbf1; color: #065f46; }
.cat-consumer { background: #fff7ed; color: #9a3412; }
.cat-manufacturing { background: #f0f9ff; color: #0c4a6e; }
.cat-tech { background: #faf5ff; color: #7c3aed; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.tag {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 4px;
}

.gate-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 4px;
  margin-top: 0.4rem;
  display: inline-block;
}

/* ---- Card Expanded Details ---- */
.card-details {
  display: none;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.op-card.expanded .card-details {
  display: block;
}

.expand-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
  padding-left: 0.5rem;
}

.op-card.expanded .expand-hint {
  display: none;
}

.op-content-body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-main);
  border-radius: 4px;
}

.op-content-body h4, .op-content-body h5 {
  color: var(--text-primary);
  margin: 0.75rem 0 0.25rem;
}

.op-content-body code {
  background: rgba(0,0,0,0.05);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

.op-content-body li {
  margin-left: 1rem;
}

.op-content-body td {
  padding: 0.2rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-section {
  margin-bottom: 0.6rem;
}

.detail-section h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.output-item {
  font-size: 0.82rem;
  padding: 0.2rem 0;
  display: flex;
  gap: 0.5rem;
}

.output-field {
  font-family: "SFMono-Regular", Consolas, monospace;
  color: var(--accent);
  font-weight: 500;
}

.output-type {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.data-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.data-item {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
}

/* ---- Strategy Sections ---- */
.strategy-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.strategy-header {
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.strategy-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.strategy-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
}

.meta-tag.version { background: var(--accent-light); color: var(--accent); }
.meta-tag.buy { background: #dcfce7; color: #166534; }
.meta-tag.avoid { background: #fef2f2; color: #b91c1c; }

/* ---- Chapter Timeline ---- */
.chapter-timeline {
  padding: 0 1.25rem 1.25rem;
}

.ch-item {
  display: flex;
  gap: 1rem;
  position: relative;
  padding-bottom: 1rem;
}

.ch-item:last-child {
  padding-bottom: 0;
}

.ch-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 32px;
  flex-shrink: 0;
}

.ch-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ch-connector {
  flex: 1;
  width: 2px;
  background: var(--border);
  min-height: 8px;
}

.ch-item:last-child .ch-connector {
  display: none;
}

.ch-content {
  flex: 1;
  padding-top: 0.3rem;
}

.ch-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ch-title:hover {
  color: var(--accent);
}

.ch-op-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.ch-deps {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.ch-ops {
  display: none;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.ch-item.expanded .ch-ops {
  display: flex;
}

.ch-op-tag {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

/* ---- Backtest Results ---- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.baseline-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.baseline-table th,
.baseline-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.baseline-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.baseline-table tr:last-child td {
  border-bottom: none;
}

.baseline-table .highlight {
  background: #f0fdf4;
  font-weight: 600;
}

/* ---- Contribute Tab ---- */
.contribute-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.contribute-section h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.contribute-section h4 {
  font-size: 0.9rem;
  margin: 0.75rem 0 0.4rem;
  color: var(--text-muted);
}

.contribute-section p,
.contribute-section li {
  font-size: 0.9rem;
  line-height: 1.7;
}

.contribute-section ul,
.contribute-section ol {
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.code-block {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0.5rem 0;
}

.code-block .comment { color: #6c7086; }
.code-block .key { color: #89b4fa; }
.code-block .string { color: #a6e3a1; }
.code-block .punct { color: #6c7086; }

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .site-header h1 { font-size: 1.3rem; }
  .tab-btn { padding: 0.7rem 0.8rem; font-size: 0.85rem; }
  .card-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .search-box { width: 100%; }
  .strategy-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Intro Page ---- */
.intro-hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.intro-hero h2 {
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.intro-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 0 1.5rem 2rem;
}

.intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.intro-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.intro-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.intro-example {
  background: var(--bg-main);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.intro-example-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.intro-example-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.intro-tag {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
}

.intro-tag.bank { background: #e8f5e9; color: #2e7d32; }
.intro-tag.mfg { background: #fff3e0; color: #e65100; }
.intro-tag.consumer { background: #fce4ec; color: #c62828; }
.intro-tag.tech { background: #e3f2fd; color: #1565c0; }

.intro-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-main);
  border-radius: 6px;
}

.flow-node {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  white-space: nowrap;
}

.flow-node.highlight {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.flow-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.intro-stats {
  display: flex;
  justify-content: space-around;
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-main);
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.intro-stats strong {
  font-size: 1.3rem;
  color: var(--accent);
}

.intro-stats span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.intro-link {
  font-size: 0.85rem;
  color: var(--accent);
}

.intro-link a {
  color: var(--accent);
  text-decoration: underline;
}
