/* Quanteta Package Index — Phase C design (bplus design language) */
/* "Public data bank" look: Lato light typography, borderless tables, per-ecosystem
   color system (npm / PyPI / crates.io), Quanteta-index gauges (clearly labelled as
   computed), related-package cards. Single source of truth: build.py. Registry values
   are OFFICIAL — reproduced verbatim. Q-indices are DERIVED — never dressed up as facts.
   This is a package DATABASE, not a package manager. */

:root {
    --bg: #FAFAFA;
    --surface: #ffffff;
    --text: #2A2A33;
    --text-muted: #8A8A95;
    --border: #ECECEC;
    --accent: #059669;
    --accent-hover: #047A56;
    /* Ecosystem brand-ish bands (kept muted/neutral, used consistently sitewide). */
    --eco-npm:    #CB3837;
    --eco-pypi:   #3775A9;
    --eco-crates: #B7794F;
    --eco-popular: #2F80ED;
    /* Quanteta index accent (distinct from ecosystem colors so a computed index is
       never visually confused with an official registry value). */
    --index: #6D5BD0;
    --max-width: 1140px;
}

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

body {
    font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Typography === */
h1, h2, h3 { font-family: "Lato", sans-serif; color: var(--text); }
h1 { font-size: 40px; font-weight: 200; letter-spacing: -1.2px; line-height: 1.15; margin-bottom: 8px; }
h2 { font-size: 24px; font-weight: 300; letter-spacing: -0.5px; margin-bottom: 12px; }
h3 { font-size: 18px; font-weight: 400; }

/* === Navigation === */
.nav-bar {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.logo { font-size: 25px; font-weight: 200; letter-spacing: -0.5px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-sub { display: block; font-size: 12px; font-weight: 300; color: var(--text-muted); letter-spacing: 2px; text-transform: uppercase; }
.nav-links { display: flex; gap: 16px; font-size: 14px; align-items: center; flex-wrap: wrap; }
header { background: transparent; border-bottom: 1px solid var(--border); }
.lang-switch { margin-left: 4px; display: inline-flex; gap: 6px; }
.lang-switch a { font-size: 12px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; }
.lang-switch a.active { background: var(--accent); color: #fff; }

/* === Main === */
main { max-width: var(--max-width); margin: 0 auto; padding: 28px 20px; }
.hero, .pkg-hero, .about-hero { margin-bottom: 28px; }
.tldr { font-size: 18px; font-weight: 300; line-height: 1.6; color: var(--text); margin-bottom: 6px; }
.lead { font-size: 15px; font-weight: 300; color: var(--text); margin: 8px 0; max-width: 78ch; line-height: 1.7; }
.callout { font-size: 14px; color: var(--text); background: #F1F0FB; border-left: 3px solid var(--index); padding: 10px 14px; border-radius: 4px; margin: 10px 0; max-width: 78ch; }
.updated { font-size: 13px; color: var(--text-muted); }
.muted { color: var(--text-muted); font-size: 13px; }

/* === Package detail hero: ecosystem-tinted accent bar === */
.pkg-hero { border-left: 4px solid var(--text-muted); padding-left: 16px; }
.pkg-hero.eco-border-npm    { border-left-color: var(--eco-npm); }
.pkg-hero.eco-border-pypi   { border-left-color: var(--eco-pypi); }
.pkg-hero.eco-border-crates { border-left-color: var(--eco-crates); }
.hero-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.copy-row { margin-top: 8px; }
.version-pill { display: inline-block; background: #EEF0F3; color: var(--text); padding: 3px 11px; border-radius: 4px; font-size: 13px; font-weight: 700; font-family: "SFMono-Regular", Menlo, Consolas, monospace; }

/* === Ecosystem badges === */
.eco-badge {
    display: inline-block; padding: 2px 9px; border-radius: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.4px; color: #fff;
}
.eco-badge-lg { font-size: 14px; padding: 4px 14px; }
.eco-badge.eco-npm    { background: var(--eco-npm); }
.eco-badge.eco-pypi   { background: var(--eco-pypi); }
.eco-badge.eco-crates { background: var(--eco-crates); }

/* === Score / value cards (bplus) === */
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.score-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.score-item {
    background: var(--surface);
    border: none;
    border-bottom: 2px solid var(--accent);
    border-radius: 4px 4px 0 0;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    text-align: left;
}
.score-item.eco-border-npm    { border-bottom-color: var(--eco-npm); }
.score-item.eco-border-pypi   { border-bottom-color: var(--eco-pypi); }
.score-item.eco-border-crates { border-bottom-color: var(--eco-crates); }
.score-item.index-item { border-bottom-color: var(--index); background: #FBFAFE; }
.score-label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 700; letter-spacing: 0.5px; margin-bottom: 4px; text-transform: uppercase; }
.score-value {
    display: block;
    font-size: 34px;
    font-weight: 200;
    letter-spacing: -1.5px;
    font-family: "Lato", sans-serif;
    line-height: 1.1;
}
.score-value small, .score-value .of100 { font-size: 13px; color: var(--text-muted); font-weight: 300; letter-spacing: 0; }
.score-sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.score-src { display: block; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* "Quanteta" computed tag — visually marks a derived index, never a registry fact */
.computed-tag {
    display: inline-block; background: var(--index); color: #fff;
    font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
    padding: 1px 6px; border-radius: 3px; text-transform: uppercase; vertical-align: middle;
}
.pkg-indices .index-note { margin-bottom: 10px; }

/* Quanteta-index gauge (0-100 percentile fill; a derived index, not a measurement) */
.gauge-track { display: block; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.gauge-fill { display: block; height: 100%; background: var(--index); border-radius: 3px; width: 0; transition: width 1.2s cubic-bezier(0.25,0.46,0.45,0.94); }

/* === Ecosystem summary cards on index === */
.eco-summary { margin-bottom: 28px; }
.eco-summary .score-card {
    background: var(--surface);
    border: none;
    border-bottom: 2px solid var(--text-muted);
    border-radius: 4px 4px 0 0;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    text-align: center;
}
.eco-summary .score-card h3 { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 4px; }
.eco-summary .eco-count { font-size: 32px; font-weight: 200; letter-spacing: -1px; margin: 0; }
.score-card.eco-npm     { border-bottom-color: var(--eco-npm); }
.score-card.eco-pypi    { border-bottom-color: var(--eco-pypi); }
.score-card.eco-crates  { border-bottom-color: var(--eco-crates); }
.score-card.eco-popular { border-bottom-color: var(--eco-popular); }
.score-card.eco-npm h3 a     { color: var(--eco-npm); }
.score-card.eco-pypi h3 a    { color: var(--eco-pypi); }
.score-card.eco-crates h3 a  { color: var(--eco-crates); }
.score-card.eco-popular h3 a { color: var(--eco-popular); }

/* === Tables (borderless, bplus) === */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: transparent; border: none; font-size: 14px; }
thead { background: transparent; border-bottom: 2px solid var(--border); }
th { padding: 12px 14px; text-align: left; font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
td { padding: 10px 14px; border-top: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #F5F7FA; }

/* FIXED column layout for the packages list tables — "can never break".
   table-layout:fixed + width:100% makes column widths come ONLY from the
   <colgroup> percentages below, never from cell content. A very long value
   (package name, license, version) cannot widen its column; it is clipped
   with an ellipsis instead. The percentages add up to exactly 100% so the
   table fills the wrapper precisely — no dead space on the right.
   When the viewport is too narrow, .table-wrapper{overflow-x:auto} scrolls. */
.data-table-section table { table-layout: fixed; width: 100%; }
/* headers stay fully readable; let them wrap rather than clip a column name */
.data-table-section th { white-space: normal; word-break: break-word; }

/* --- index.html column widths (6 cols, sum = 100%) --- */
#pkg-table .col-pkg   { width: 35%; }
#pkg-table .col-eco   { width: 10%; }
#pkg-table .col-ver   { width: 10%; }
#pkg-table .col-dl    { width: 15%; }
#pkg-table .col-lic   { width: 15%; }
#pkg-table .col-facts { width: 15%; }

/* --- list.html column widths (7 cols, sum = 100%) --- */
.list-table .col-rank { width: 6%; }
.list-table .col-pkg  { width: 32%; }
.list-table .col-eco  { width: 11%; }
.list-table .col-ver  { width: 12%; }
.list-table .col-dl   { width: 15%; }
.list-table .col-lic  { width: 12%; }
.list-table .col-rel  { width: 12%; }

/* Data cells: single line, clip overflow with ellipsis — can never widen. */
.data-table-section .eco-cell,
.data-table-section .ver-cell,
.data-table-section .dl-cell,
.data-table-section .lic-cell,
.data-table-section .rel-cell,
.data-table-section .rank-cell {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Eco badge sits inside an ellipsis cell; keep it from forcing width. */
.data-table-section .eco-cell .eco-badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Package cell: name ellipsizes on one line; description clamps to 2 lines. */
.data-table-section .name-cell { white-space: normal; overflow: hidden; }
.data-table-section .name-cell > a { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table-section .name-cell .row-desc {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
/* Facts cell: pills wrap inside the fixed 15% width; anything that does not
   fit is hidden. The cell can never push the column wider than its 15%. */
.data-table-section .facts-cell { white-space: normal; overflow: hidden; }
.data-table-section .facts-cell .fact-tag { white-space: nowrap; }
code { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }

/* === Filters === */
.filters { background: transparent; border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 0; margin-bottom: 22px; }
.filters h2 { font-size: 18px; font-weight: 300; margin-bottom: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 16px; }
.filter-group { flex: 1; min-width: 150px; }
.filter-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.filter-group input, .filter-group select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; background: var(--surface); }
.filter-group input:focus, .filter-group select:focus { outline: none; border-color: var(--accent); }
.filter-count { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

/* === Detail metadata grid === */
.meta-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0;
    font-size: 14px;
    border-top: 1px solid var(--border);
}
.meta-grid dt, .meta-grid dd { padding: 9px 14px; border-bottom: 1px solid var(--border); align-self: stretch; }
.meta-grid dt { font-weight: 700; color: var(--text-muted); }
.meta-grid dd { margin: 0; word-break: break-word; }
.meta-grid dt:nth-of-type(odd), .meta-grid dt:nth-of-type(odd) + dd { background: #FAFBFC; }

/* === Related package cards (shared-facet neighbourhood) === */
.related-pkgs { margin-top: 36px; }
.related-axis { margin-bottom: 22px; }
.related-axis-title {
    font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
    color: var(--text-muted); margin: 0 0 10px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.related-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.related-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: none;
    border-bottom: 2px solid var(--text-muted);
    border-radius: 4px 4px 0 0;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    color: var(--text);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.related-card:hover { text-decoration: none; box-shadow: 0 3px 10px rgba(0,0,0,0.08); transform: translateY(-2px); }
.related-card.eco-border-npm    { border-bottom-color: var(--eco-npm); }
.related-card.eco-border-pypi   { border-bottom-color: var(--eco-pypi); }
.related-card.eco-border-crates { border-bottom-color: var(--eco-crates); }
.related-name { display: block; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--text); font-family: "SFMono-Regular", Menlo, Consolas, monospace; word-break: break-all; }
.related-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.related-value { font-size: 13px; font-weight: 700; color: var(--text); }

/* === Rank tabs === */
.rank-tabs { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.rank-tabs a { padding: 5px 14px; border: 1px solid var(--border); border-radius: 6px; font-weight: 600; font-size: 13px; }
.rank-tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === Breadcrumb / copy button === */
.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.copy-btn { display: inline-block; background: transparent; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; color: var(--text-muted); font-family: inherit; }
.copy-btn:hover { background: #F1F3F5; color: var(--text); }

/* === Generic sections === */
section { margin-bottom: 28px; }
section h2 { font-size: 24px; font-weight: 300; margin-bottom: 12px; }
section h3 { font-size: 17px; font-weight: 400; margin: 14px 0 6px; }
section p, section li { font-size: 14px; color: var(--text); margin-bottom: 6px; }
section ul, section ol { padding-left: 20px; }
section dl { margin-bottom: 8px; }
section dt { font-weight: 700; margin-top: 8px; }
section dd { margin: 0 0 4px 0; }
.source-text { background: #F5F7FA; border-radius: 6px; padding: 12px 16px; line-height: 1.7; }
pre { background: #F5F7FA; border-radius: 6px; padding: 12px 16px; overflow-x: auto; }

.back-link { margin-top: 32px; }
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 40px; margin-bottom: 16px; }

/* === Footer === */
footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 24px 0; font-size: 13px; color: var(--text-muted); }
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; text-align: center; }
.footer-inner a { color: var(--text-muted); text-decoration: underline; }

/* === Responsive === */
@media (max-width: 768px) {
    h1 { font-size: 30px; }
    h2, section h2 { font-size: 21px; }
    .nav-bar { flex-direction: column; align-items: flex-start; }
    .filter-row { flex-direction: column; }
    .score-grid { grid-template-columns: 1fr 1fr; }
    .related-cards { grid-template-columns: 1fr 1fr; }
    .meta-grid { grid-template-columns: 140px 1fr; }
    td, th { padding: 8px 8px; font-size: 13px; }
}
@media (max-width: 480px) {
    .score-grid, .related-cards { grid-template-columns: 1fr; }
    .meta-grid { grid-template-columns: 110px 1fr; }
}

/* ===== UX facts pass (2026-05) — factual tags, quick filters, summary card ===== */
:root {
    --fact-good-bg: #E6F4EC; --fact-good-fg: #0B7A47; --fact-good-bd: #B6E0C8;
    --fact-warn-bg: #FCEEE6; --fact-warn-fg: #B5521C; --fact-warn-bd: #F3D2BD;
    --fact-info-bg: #EAEEF7; --fact-info-fg: #3A5180; --fact-info-bd: #CCD6EC;
}
.fact-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.fact-tag {
    display: inline-block; font-size: 12px; line-height: 1.4; font-weight: 700;
    padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.fact-tag.fact-mini { font-size: 11px; padding: 1px 7px; font-weight: 700; }
.fact-good { background: var(--fact-good-bg); color: var(--fact-good-fg); border-color: var(--fact-good-bd); }
.fact-warn { background: var(--fact-warn-bg); color: var(--fact-warn-fg); border-color: var(--fact-warn-bd); }
.fact-info { background: var(--fact-info-bg); color: var(--fact-info-fg); border-color: var(--fact-info-bd); }
.facts-cell { line-height: 2; }
.facts-cell .fact-tag { margin: 1px 2px 1px 0; }

/* Quick-filter chips */
.quick-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.qf-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.qf-chip {
    font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
    padding: 3px 11px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); transition: all .12s ease;
}
.qf-chip:hover { border-color: var(--accent); }
.qf-chip.on { box-shadow: 0 0 0 2px var(--accent) inset; }
.qf-chip.fact-good.on { background: var(--fact-good-bg); color: var(--fact-good-fg); }
.qf-chip.fact-warn.on { background: var(--fact-warn-bg); color: var(--fact-warn-fg); }
.qf-chip.fact-info.on { background: var(--fact-info-bg); color: var(--fact-info-fg); }
.qf-chip.qf-clear { color: var(--text-muted); margin-left: auto; }

/* Legend disclosure */
.legend { margin-top: 12px; font-size: 14px; }
.legend > summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.legend-list { list-style: none; margin: 10px 0; display: grid; gap: 8px; }
.legend-list li { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text); }
.legend-list .fact-tag { flex: 0 0 auto; }

/* Package summary card (key facts above the fold) */
.pkg-summary-card {
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 8px; padding: 16px 18px; margin: 18px 0;
}
.pkg-summary-card.eco-border-npm    { border-left-color: var(--eco-npm); }
.pkg-summary-card.eco-border-pypi   { border-left-color: var(--eco-pypi); }
.pkg-summary-card.eco-border-crates { border-left-color: var(--eco-crates); }
.summary-title { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 10px; }
.summary-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 18px; }
.summary-list li { display: flex; flex-direction: column; }
.sum-k { font-size: 12px; color: var(--text-muted); }
.sum-v { font-size: 15px; font-weight: 700; }
.missing-note { margin-top: 10px; font-size: 12px; }

/* --- Cleansing pass 1: descriptions, install command, secondary indices --- */
.name-cell { max-width: 360px; }
.row-desc { display: block; font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-top: 3px; font-weight: 400; }
.summary-desc { font-size: 15px; line-height: 1.55; margin: 4px 0 14px; color: var(--text); }
.summary-desc.muted { color: var(--text-muted); font-style: italic; }
.install-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.install-cmd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; color: var(--text); }
.desc-src-note { font-size: 12px; margin-top: 6px; }
.raw-desc { margin-top: 8px; }
.raw-desc > summary { cursor: pointer; font-size: 13px; color: var(--text-muted); }
.raw-desc-body { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 12px; color: var(--text-muted); margin-top: 8px; overflow-x: auto; }
.secondary-indices > details > summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.secondary-indices .indices-summary-title { font-size: 17px; }
.secondary-indices .index-note { margin-top: 6px; }
