/* TextbookLens — Custom CSS (Tailwind CDN handles most utilities) */

/* ── Base ────────────────────────────────────────────────────────────────── */
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif; }

/* ── Segmented control ───────────────────────────────────────────────────── */
.seg-btn       { transition: background 0.15s, box-shadow 0.15s; }
.seg-btn.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ── Tab nav ─────────────────────────────────────────────────────────────── */
.tab-btn        { border-bottom: 2px solid transparent; transition: border-color 0.15s, color 0.15s; }
.tab-btn.active { border-bottom-color: #5880a0; color: #5880a0; }

/* ── Autocomplete dropdown ───────────────────────────────────────────────── */
.autocomplete-item:hover { background: #f3f4f6; }

/* ── Matrix table ────────────────────────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; }

.matrix th {
  position: sticky; top: 0; z-index: 2;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 500;
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.matrix td {
  border-bottom: 1px solid #f3f4f6;
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  font-size: 0.875rem;
}

.matrix tr:last-child td { border-bottom: none; }
.matrix tr:hover td     { background: #f9fafb; }

.category-row td {
  background: #f1f5f9;
  font-weight: 600;
  font-size: 0.75rem;
  color: #475569;
  padding: 0.375rem 0.75rem;
  letter-spacing: 0.02em;
}

/* ── Cell truncation + hover expand ─────────────────────────────────────── */
.cell-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 3rem;
  transition: max-height 0.2s;
}

.matrix td:hover .cell-text {
  -webkit-line-clamp: unset;
  max-height: 20rem;
  overflow: visible;
}

/* Grammar label above example */
.grammar-label { font-size: 0.7rem; color: #9ca3af; margin-bottom: 2px; }

/* ── Chip / tag ──────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef4f8; border: 1px solid #b8d1e0; border-radius: 9999px; padding: 2px 10px; font-size: 0.8rem; color: #446a84; }
.chip button { color: #85afc8; font-size: 1rem; line-height: 1; cursor: pointer; }
.chip button:hover { color: #344d61; }

/* ── Recurrence icon ─────────────────────────────────────────────────────── */
.recur { font-size: 0.85em; opacity: 0.7; }

/* ── Grammar code box (compare left column) ──────────────────────────────── */
.code-box { cursor: pointer; padding: 0.375rem 0.5rem; border-radius: 0.375rem; transition: background 0.1s; }
.code-box:hover { background: #eef4f8; }
.code-subcategory { font-size: 0.65rem; color: #9ca3af; line-height: 1.2; }
.code-term        { font-size: 0.825rem; color: #1e293b; font-weight: 500; line-height: 1.3; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 0.75rem; padding: 2rem; max-width: 32rem; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2); position: relative; }

/* ── Coming soon ─────────────────────────────────────────────────────────── */
.coming-soon { text-align: center; padding: 5rem 2rem; color: #9ca3af; font-size: 0.95rem; }

/* ── Filter chips row ───────────────────────────────────────────────────────*/
.filter-chip { border: 1px solid #e5e7eb; border-radius: 9999px; padding: 2px 12px; font-size: 0.8rem; cursor: pointer; transition: background 0.1s, border-color 0.1s; color: #6b7280; }
.filter-chip.active { background: #5880a0; border-color: #5880a0; color: #fff; }
.filter-chip:not(.active):hover { background: #f3f4f6; }

/* ── Coverage bar ────────────────────────────────────────────────────────── */
.coverage-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #6b7280; }
.coverage-val  { font-weight: 600; color: #5880a0; font-size: 0.9rem; }

/* ── Browse result items (inside browse mode) ───────────────────────────── */
.browse-item { background: #fafcfd; border: 1px solid #e8f0f5; border-radius: 0.875rem; padding: 0.75rem 1rem; }

/* ── Coverage stats card ─────────────────────────────────────────────────── */
.coverage-card { background: #f7fafc; border: 1px solid #e8f0f5; border-radius: 0.875rem; padding: 0.75rem 1.25rem; }

/* ── Compare matrix cells (A = blue, B = green) ─────────────────────────── */
.compare-cell { border-radius: 0.5rem; padding: 0.5rem 0.75rem; min-height: 2.5rem; }
.compare-cell-a { background: #eef4fb; border-left: 3px solid #5880a0; }
.compare-cell-b { background: #edf6ee; border-left: 3px solid #72a882; }

/* ── Scrollbar (webkit) ──────────────────────────────────────────────────── */
.matrix-wrap::-webkit-scrollbar { height: 6px; }
.matrix-wrap::-webkit-scrollbar-track { background: #f1f5f9; }
.matrix-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Stats Overview · 体量卡片 ───────────────────────────────────────────── */
.stats-scale-card {
  background: #fafcfd; border: 1px solid #e8f0f5; border-radius: 0.875rem;
  padding: 0.875rem 1rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.stats-scale-title { font-size: 0.8rem; color: #6b7280; font-weight: 500; }
.stats-scale-num { display: flex; align-items: baseline; gap: 0.375rem; }
.stats-scale-num .num   { font-size: 1.75rem; font-weight: 700; color: #344d61; line-height: 1; }
.stats-scale-num .label { font-size: 0.75rem; color: #9ca3af; }
.stats-scale-cefr-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  background: #f1f5f9; margin-top: 0.25rem;
}
.cefr-seg { height: 100%; transition: width 0.2s; }
.cefr-pre-a1 { background: #d0e3f0; }
.cefr-a1     { background: #a5cce0; }
.cefr-a2     { background: #71a7c8; }
.cefr-b1     { background: #466e89; }
.stats-scale-cefr-legend {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem;
  font-size: 0.65rem; color: #6b7280; margin-top: 0.125rem;
}
.stats-scale-cefr-legend > div { display: flex; flex-direction: column; line-height: 1.3; }
.stats-scale-cefr-legend > div > span:last-child { color: #344d61; font-weight: 600; }

/* ── Stats Overview · 韦恩图卡片 ─────────────────────────────────────────── */
.venn-card {
  background: #fafcfd; border: 1px solid #e8f0f5; border-radius: 0.875rem;
  padding: 0.875rem 1rem;
}
.venn-title {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-size: 0.8rem; font-weight: 500; margin-bottom: 0.25rem;
}
.venn-title-a { color: #5880a0; }
.venn-title-b { color: #4c8a5b; }
.venn-vs      { color: #9ca3af; font-size: 0.7rem; }
.venn-svg     { width: 100%; height: 90px; display: block; }
.venn-circle-a { fill: #5880a0; fill-opacity: 0.35; }
.venn-circle-b { fill: #72a882; fill-opacity: 0.35; }
.venn-num     { font-size: 12px; font-weight: 600; }
.venn-num-a   { fill: #2f4858; }
.venn-num-b   { fill: #2e5a3a; }
.venn-num-shared { fill: #1f2937; font-weight: 700; }
.venn-coverage {
  font-size: 0.7rem; color: #6b7280; margin-top: 0.375rem;
  display: flex; flex-direction: column; gap: 0.125rem;
}
.venn-coverage > div { display: flex; justify-content: space-between; align-items: center; }
.venn-pct { font-weight: 600; color: #5880a0; font-size: 0.8rem; }
