/* Reconbrief — structural stylesheet.
 *
 * All component styling lives here and references CSS custom properties.
 * A theme (static/themes/<name>.css, chosen by viewer.theme in domain.yaml)
 * only re-declares those variables — and, where a theme wants a different
 * layout, overrides a handful of rules. This keeps "add a new look" to a
 * ~30-line file instead of a template fork.
 *
 * The variable defaults below are a neutral light theme, so the viewer is
 * presentable even if a theme file fails to load. */
:root {
  --brand-grad: linear-gradient(135deg, #5b6b7a 0%, #3d4753 100%);
  --brand-fg: #ffffff;
  --accent: #4a6fa5;
  --accent-dark: #3a5a86;
  --link: #0366d6;
  --link-hover: #0247a0;
  --ink: #222222;
  --muted: #6c757d;
  --faint: #8a929b;
  --rule: #e9ecef;
  --panel: #f6f8fa;
  --card-bg: #ffffff;
  --card-border: #e1e4e8;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 6px 16px rgba(0,0,0,0.10);
  --badge-bg: #eef1f6;
  --badge-fg: #3a4a63;
  --page-bg: #ffffff;
  --radius: 8px;
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---- masthead + subnav ---- */
.masthead { background: var(--brand-grad); color: var(--brand-fg); }
.masthead-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.9rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  color: var(--brand-fg); font-size: 1.15rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.5rem; letter-spacing: 0.01em;
}
.brand:hover { color: var(--brand-fg); text-decoration: none; opacity: 0.92; }
.brand svg { display: block; }
.masthead-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.masthead-right a { color: var(--brand-fg); opacity: 0.85; font-size: 0.9rem; }
.masthead-right a:hover { opacity: 1; color: var(--brand-fg); }

.subnav { background: var(--panel); border-bottom: 1px solid var(--rule); }
.subnav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1.25rem;
  font-size: 0.88rem; color: var(--muted);
}
.subnav a { color: var(--muted); }
.subnav a:hover { color: var(--accent); }
.subnav strong { color: var(--ink); font-weight: 600; }

main.container { max-width: var(--maxw); margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

/* ---- headings ---- */
h1 { font-weight: 600; font-size: 1.7rem; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
h2 { font-weight: 600; font-size: 1.2rem; margin: 2rem 0 0.75rem; }
h3 { font-weight: 600; font-size: 1.02rem; margin: 1.25rem 0 0.5rem; }
.page-sub { color: var(--muted); font-size: 0.92rem; margin: 0 0 1.5rem; }
.page-sub a { color: var(--accent); }
/* domain description: crisp lead + collapsible detail */
.domain-desc { max-width: 72ch; margin: 0 0 0.9rem; }
.domain-desc .lead { color: var(--ink); font-size: 1.02rem; line-height: 1.55; margin: 0; }
.domain-desc details.desc-more { margin-top: 0.4rem; }
.domain-desc details.desc-more > summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
.domain-desc details.desc-more p { color: var(--muted); font-size: 0.9rem; line-height: 1.55; margin: 0.6rem 0 0; }
.meta { font-size: 0.85rem; color: var(--muted); }

/* ---- standardized view switcher (rendered in _base for every domain page) ---- */
.view-tools { background: var(--card-bg); border-bottom: 1px solid var(--rule); }
.view-tools-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem;
  display: flex; gap: 0.25rem; flex-wrap: wrap;
}
.view-tools a {
  padding: 0.55rem 0.85rem; font-size: 0.85rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tools a:hover { color: var(--accent); text-decoration: none; border-bottom-color: var(--rule); }
.view-tools a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ---- pills / badges ---- */
.pill {
  display: inline-block; padding: 0.12rem 0.55rem; border-radius: 1rem;
  background: var(--badge-bg); color: var(--badge-fg); font-size: 0.78rem;
  font-weight: 500; white-space: nowrap;
}
.badge-score {
  display: inline-flex; align-items: baseline; gap: 0.25rem;
  background: var(--accent); color: #fff; border-radius: 1rem;
  padding: 0.12rem 0.6rem; font-size: 0.82rem; font-weight: 600;
}
.badge-score .lbl { font-size: 0.62rem; font-weight: 500; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- stage tabs ---- */
.stage-tabs { display: flex; gap: 0.4rem; margin: 0 0 1.25rem; flex-wrap: wrap; }
.stage-tabs a {
  padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.85rem;
  color: var(--muted); background: var(--panel); border: 1px solid var(--rule);
}
.stage-tabs a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.stage-tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- browse drill-down (breadcrumb + facet grid) ---- */
.browse-crumbs { font-size: 0.9rem; margin: 0 0 1.1rem; color: var(--muted); }
.browse-crumbs a { color: var(--accent); }
.browse-crumbs .sep { margin: 0 0.5rem; color: var(--rule); }
.browse-crumbs .current { color: var(--ink); font-weight: 600; }
.facet-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}
.facet-cell {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; box-shadow: var(--card-shadow); transition: border-color .12s, transform .12s;
}
.facet-cell:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.facet-cell__value { color: var(--ink); font-weight: 500; }
.facet-cell__count {
  color: var(--badge-fg); background: var(--badge-bg); border-radius: 999px;
  padding: 0.05rem 0.5rem; font-size: 0.8rem; font-variant-numeric: tabular-nums;
}

/* ---- toolbar / filters ---- */
.toolbar {
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 0.85rem 1rem; margin-bottom: 1.5rem;
  display: flex; gap: 0.85rem; align-items: baseline; flex-wrap: wrap;
}
.toolbar label { font-size: 0.88rem; color: var(--muted); }
.toolbar input[type=text], .toolbar input[type=search], .toolbar select, .toolbar input[type=number] {
  padding: 0.4rem 0.6rem; border: 1px solid var(--card-border); border-radius: 5px;
  font-size: 0.92rem; font-family: inherit; background: #fff; color: var(--ink);
}
.toolbar input[type=text], .toolbar input[type=search] { min-width: 240px; }
.toolbar .chip {
  display: inline-block; padding: 0.12rem 0.45rem; margin: 0 0.1rem; border-radius: 1rem;
  background: var(--badge-bg); font-size: 0.82rem; cursor: pointer; color: var(--badge-fg);
}
.toolbar .chip input { margin-right: 0.25rem; }
.btn {
  padding: 0.42rem 0.95rem; border: none; border-radius: 5px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 0.9rem; font-family: inherit; font-weight: 500;
}
.btn:hover { background: var(--accent-dark); }
.clear-filters { color: #c53030; }

/* ---- entity card grid (listing) ---- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.entity-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease; position: relative;
}
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.entity-card__head { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.4rem; }
.entity-card__name { font-size: 1.05rem; font-weight: 600; line-height: 1.3; }
.entity-card__name a { color: var(--ink); }
.entity-card__name a:hover { color: var(--accent); text-decoration: none; }
.entity-card__score { margin-left: auto; flex-shrink: 0; }
.entity-card__id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; color: var(--faint); word-break: break-all; }
.entity-card__fields { margin-top: 0.7rem; display: grid; gap: 0.25rem; }
.entity-card__field { display: flex; gap: 0.5rem; font-size: 0.86rem; }
.entity-card__field .k { color: var(--muted); flex: 0 0 42%; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; font-weight: 600; padding-top: 0.08rem; }
.entity-card__field .v { color: var(--ink); flex: 1; overflow-wrap: anywhere; }

/* ---- data tables (index / stats / coverage) ---- */
.data-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.data-table th, .data-table td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.data-table th { font-weight: 600; color: var(--muted); background: var(--panel); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table th a { color: var(--muted); }
.data-table tbody tr:hover { background: var(--panel); }
.bar-track { background: var(--rule); border-radius: 3px; width: 10rem; height: 0.6rem; display: inline-block; vertical-align: middle; }
.bar-fill { height: 100%; border-radius: 3px; }
/* coverage: fields produced by a later stage — expected-empty, greyed out */
.cov-pending-head { color: var(--muted); font-weight: 600; }
table.cov-pending { opacity: 0.55; }
table.cov-pending td { color: var(--muted); }
table.cov-pending tbody tr:hover { opacity: 1; }

/* ---- detail page ---- */
.summary-card {
  display: flex; align-items: center; gap: 1.25rem; background: var(--panel);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 1rem 0 1.75rem;
}
.summary-score {
  font-size: 2.4rem; font-weight: 700; color: var(--accent); line-height: 1;
  display: flex; flex-direction: column; align-items: center;
}
.summary-score-label { font-size: 0.66rem; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.25rem; }
.summary-headline { flex: 1; font-size: 1.05rem; color: var(--ink); }
.field-row { display: flex; padding: 0.45rem 0; border-bottom: 1px dotted var(--rule); }
.field-name { flex: 0 0 210px; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 0.18rem; }
.tip { cursor: help; position: relative; }
.tip:hover { color: var(--ink); }
.field-name .tip:hover, .entity-card__field .k .tip:hover { border-bottom: 1px dotted var(--rule); }
/* column headers carry tooltips too — hint it with a dotted underline */
th.tip { text-decoration: underline dotted; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: 100%; z-index: 20; margin-top: 5px;
  width: max-content; max-width: 320px;
  background: var(--ink); color: #fff;
  padding: 0.45rem 0.65rem; border-radius: 5px;
  font-size: 0.8rem; font-weight: 400; line-height: 1.45;
  text-transform: none; white-space: normal;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.field-value { flex: 1; overflow-wrap: anywhere; }
/* structured value rendering (nested dicts + lists of objects) */
.field-value .kv { margin: 0; }
.field-value .kv-row { display: flex; gap: 0.5rem; padding: 0.1rem 0; }
.field-value .kv-row > dt { flex: 0 0 130px; color: var(--muted); font-size: 0.85rem; text-transform: capitalize; margin: 0; }
.field-value .kv-row > dd { flex: 1; margin: 0; overflow-wrap: anywhere; }
.field-value .item-list { display: flex; flex-direction: column; gap: 0.5rem; }
.field-value .item-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 0.6rem 0.75rem; }
.field-value .item-card .kv-row > dt { flex-basis: 110px; font-size: 0.8rem; }
.evidence-block { background: #fff8e7; padding: 0.5rem 0.75rem; border-left: 3px solid #d4a72c; margin-top: 0.25rem; font-size: 0.85rem; }
.evidence-block code { color: #555; }
/* provenance + research-notes share the same collapsible panel look */
details.tech-detail, details.research-notes { margin-top: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.6rem 1rem; background: var(--panel); }
details.tech-detail > summary, details.research-notes > summary { cursor: pointer; color: var(--accent); font-weight: 500; }
details.tech-detail[open], details.research-notes[open] { padding-bottom: 1rem; }
details.tech-detail > *:not(summary) { margin-top: 0.75rem; }
details.research-notes .notes-caption { margin: 0.75rem 0 0; padding: 0.6rem 0.8rem; font-size: 0.85rem; color: var(--muted); background: var(--card-bg); border-left: 3px solid var(--accent); border-radius: 4px; }
details.research-notes .notes-body { margin-top: 0.75rem; font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
details.research-notes .notes-body h3, .notes-body h4, .notes-body h5, .notes-body h6 { margin: 1rem 0 0.4rem; }
details.research-notes .notes-body p { margin: 0 0 0.8rem; }
details.research-notes .notes-body a { color: var(--link); }
details.research-notes .notes-body a.cite { font-size: 0.78em; vertical-align: super; text-decoration: none; color: var(--accent); padding: 0 0.1em; font-weight: 600; }
details.research-notes .notes-body a.cite:hover { text-decoration: underline; }

/* markdown-valued schema fields rendered inline in a detail section */
.md-field { line-height: 1.5; }
.md-field h4, .md-field h5, .md-field h6 { margin: 0.9rem 0 0.35rem; font-size: 0.95rem; }
.md-field h4:first-child { margin-top: 0; }
.md-field p { margin: 0 0 0.7rem; }
.md-field ul { margin: 0.2rem 0 0.8rem; padding-left: 1.2rem; }
.md-field li { margin: 0.15rem 0; }
.md-field a { color: var(--link); }

/* ---- about / project overview ---- */
.about { max-width: 78ch; }
.about .lead { font-size: 1.05rem; line-height: 1.6; color: var(--ink); margin: 0 0 0.5rem; }
.about p { line-height: 1.6; }
.about-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0 0.5rem; }
.about-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--card-shadow); }
.about-card h3 { margin: 0; font-size: 1.05rem; }
.about-card .about-tag { margin: 0.1rem 0 0.6rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; }
.about-card p:last-child { margin: 0; font-size: 0.9rem; color: var(--muted); }
.about-stages { list-style: none; counter-reset: stage; padding: 0; margin: 1rem 0; }
.about-stages li { counter-increment: stage; position: relative; padding: 0.6rem 0 0.6rem 2.4rem; border-bottom: 1px dotted var(--rule); }
.about-stages li:last-child { border-bottom: none; }
.about-stages li::before {
  content: counter(stage); position: absolute; left: 0; top: 0.6rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 600;
}
.about-stage-name { display: block; font-weight: 600; color: var(--ink); }
.about-stage-desc { display: block; font-size: 0.92rem; color: var(--muted); margin-top: 0.15rem; }
.about-names { margin: 1rem 0; }
.about-names dt { font-weight: 700; color: var(--ink); margin-top: 0.9rem; font-size: 1rem; }
.about-names dd { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

/* ---- misc ---- */
.empty { padding: 2.5rem; text-align: center; color: var(--faint); background: var(--panel); border-radius: var(--radius); border: 1px dashed var(--card-border); }
pre.json { background: var(--panel); padding: 0.75rem; border-radius: 6px; overflow: auto; font-size: 0.85rem; border: 1px solid var(--rule); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 640px) {
  .field-row { flex-direction: column; }
  .field-name { flex-basis: auto; }
  .masthead-inner, .subnav-inner, main.container { padding-left: 1rem; padding-right: 1rem; }
}

/* Ranked leaderboard (viewer.rank) */
table.ranked { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.ranked th, table.ranked td { padding: 0.45rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border, #e5e5e5); }
table.ranked th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.7; }
table.ranked td.rank-pos, table.ranked th.rank-pos { width: 2.5rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted, #888); font-weight: 600; }
table.ranked td.rank-name a { font-weight: 600; text-decoration: none; }
table.ranked td.rank-key { font-variant-numeric: tabular-nums; font-weight: 600; }
table.ranked tbody tr:hover { background: var(--hover, rgba(0,0,0,0.03)); }
table.ranked .muted { color: var(--muted, #aaa); }
