/* BITIG Data — style.css
   Academic, restrained, mobile-first.
   Dark charcoal + cream + gold accents.
*/

:root {
  --bg: #1c1c1c;
  --bg-card: #262626;
  --bg-card-hover: #2e2e2e;
  --text: #e8e0d3;
  --text-dim: #9a9487;
  --text-muted: #6b655a;
  --gold: #c9a96e;
  --gold-dim: #8b734a;
  --border: #3a3a3a;
  --border-light: #2e2e2e;
  --accent-red: #b85450;
  --accent-green: #6b8e6b;
  --radius: 6px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

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

html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: 0.02em; }
h2 { font-size: 1.2rem; font-weight: 600; letter-spacing: 0.02em; margin-bottom: 0.75rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.5rem; }
p { margin-bottom: 0.75rem; color: var(--text-dim); }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 0.8rem; color: var(--text-muted); }

/* ── Nav ────────────────────────────────── */
.nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--gold); letter-spacing: 0.04em; }
.nav-links { display: flex; gap: 1.2rem; list-style: none; }
.nav-links a { color: var(--text-dim); font-size: 0.85rem; }
.nav-links a:hover, .nav-links a.active { color: var(--gold); text-decoration: none; }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; }

@media (max-width: 640px) {
  .nav-links { display: none; flex-direction: column; position: absolute; top: 48px; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 0.75rem 1rem; gap: 0.6rem; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
}

/* ── Layout ─────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ── Hero (index) ───────────────────────── */
.hero { padding: 2.5rem 0 1.5rem; text-align: center; }
.hero h1 { font-size: 2rem; letter-spacing: 0.06em; color: var(--gold); margin-bottom: 0.25rem; }
.hero .subtitle { font-size: 0.95rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.hero .desc { font-size: 0.88rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 1.5rem; }

/* ── Cards ──────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  transition: background 0.15s;
}
.card:hover { background: var(--bg-card-hover); }
.card h3 { font-size: 1rem; margin-bottom: 0.35rem; color: var(--text); }
.card p { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.card .tag {
  display: inline-block;
  background: rgba(201,169,110,0.12);
  color: var(--gold-dim);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
}
.card .source-line { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ── Source cards (corpus) ──────────────── */
.source-card { margin-bottom: 2rem; }
.source-card .meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }

/* ── Segment block ──────────────────────── */
.segment {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.segment .translit {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
  word-break: break-all;
}
.segment .zh { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 0.35rem; }
.segment .notes { color: var(--text-muted); font-size: 0.78rem; margin-bottom: 0.5rem; }
.segment .glossary { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.segment .glossary-item {
  font-size: 0.72rem;
  background: rgba(201,169,110,0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  color: var(--text-dim);
}
.segment .glossary-item a { color: var(--gold-dim); }

/* ── Search ─────────────────────────────── */
.search-bar {
  display: flex; gap: 0.5rem; margin-bottom: 1.2rem;
}
.search-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-mono);
}
.search-bar input:focus { outline: none; border-color: var(--gold-dim); }
.search-bar input::placeholder { color: var(--text-muted); }

/* ── Letter index ───────────────────────── */
.letter-index {
  display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem;
}
.letter-index button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
.letter-index button:hover, .letter-index button.active {
  background: rgba(201,169,110,0.15);
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ── Table ──────────────────────────────── */
.table-wrap { overflow-x: auto; margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 0.5rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border-light); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
td { color: var(--text-dim); }
td.translit-col { font-family: var(--font-mono); color: var(--gold); }

/* ── Pipeline flow ──────────────────────── */
.pipeline {
  display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0;
  justify-content: center;
}
.pipeline-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  flex: 1 1 140px;
  max-width: 180px;
}
.pipeline-step .step-num {
  font-size: 1.3rem; font-weight: 700; color: var(--gold); margin-bottom: 0.25rem;
}
.pipeline-step .step-title { font-size: 0.8rem; color: var(--text-dim); }
.pipeline-arrow { display: flex; align-items: center; color: var(--gold-dim); font-size: 1.2rem; }

/* ── Badges ─────────────────────────────── */
.badge {
  display: inline-block; font-size: 0.68rem; padding: 0.12rem 0.45rem;
  border-radius: 3px; margin-right: 0.3rem;
}
.badge-source { background: rgba(255,255,255,0.06); color: var(--text-dim); }
.badge-warn { background: rgba(184,84,80,0.15); color: var(--accent-red); }

/* ── Dict entry ─────────────────────────── */
.dict-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
}
.dict-entry .head {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.3rem;
}
.dict-entry .translit { font-family: var(--font-mono); font-size: 1rem; color: var(--gold); }
.dict-entry .pos { font-size: 0.72rem; color: var(--text-muted); font-style: italic; }
.dict-entry .def { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.25rem; }
.dict-entry .meta { font-size: 0.7rem; color: var(--text-muted); }

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

/* ── Utilities ──────────────────────────── */
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.mt { margin-top: 1.5rem; }
.mb { margin-bottom: 1rem; }
