/* =============================================================================
   tb-library.css — Corpus Build Library (the Build tab's Builds hub), the
   corpus study panel, provenance badges, the corpus context lane, and the
   shared SC2 glossary tooltips (migrated from the retired learn-guide.css).

   Class namespaces:
     .tb-hub-*     the Builds hub modal chrome (tabs, panes)
     .tb-lib-*     library rail / card grid
     .tbl-*        study panel (tb-build-info.js) — also rendered inside the
                   replay viewer's analyst guide panel
     .tb-prov-*    per-step provenance badges in the editor build list
     .tb-cl-*      corpus context lane markers
     .gloss        shared glossary tooltip (modules/shell/glossary.js)

   Responsive contract: 480 / 768 / 1024 only. The hub modal goes full-sheet
   under 768px; the library rail collapses to a horizontal scroll strip.
   ============================================================================= */

/* ── Builds hub modal ─────────────────────────────────────────────────────── */
.tb-modal--library {
    width: min(960px, calc(100vw - 32px));
    max-width: none;
}
.tb-hub-tabs {
    display: flex;
    gap: 4px;
    margin: 0 10px;
}
.tb-hub-tab {
    appearance: none;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #aab3c2;
    font: inherit;
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.tb-hub-tab.active {
    background: rgba(86, 194, 255, 0.14);
    border-color: rgba(86, 194, 255, 0.45);
    color: #dceaf7;
}
.tb-hub-body { min-height: 320px; }
.tb-hub-pane[hidden] { display: none; }

/* ── Library layout: matchup rail + card grid ─────────────────────────────── */
.tb-lib-layout {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 12px;
    min-height: 300px;
}
.tb-lib-rail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-content: start;
}
.tb-lib-mu {
    appearance: none;
    text-align: left;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 6px;
    padding: 6px 9px;
    cursor: pointer;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.tb-lib-mu:hover { border-color: rgba(86, 194, 255, 0.4); }
.tb-lib-mu.active {
    background: rgba(86, 194, 255, 0.12);
    border-color: rgba(86, 194, 255, 0.55);
}
.tb-lib-mu:disabled { opacity: 0.4; cursor: default; }
.tb-lib-mu-code { font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.tb-lib-mu-n { font-size: 10.5px; color: #8b96a5; }

.tb-lib-main { min-width: 0; max-height: min(62vh, 640px); overflow-y: auto; padding-right: 4px; }
.tb-lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin: 6px 0 14px;
}
.tb-lib-card {
    appearance: none;
    font: inherit;
    text-align: left;
    background: linear-gradient(180deg, rgba(20, 30, 46, 0.92), rgba(13, 20, 33, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 8px;
    padding: 9px 11px;
    cursor: pointer;
    color: #dbe4ee;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: border-color 0.12s, transform 0.12s;
}
.tb-lib-card:hover { border-color: rgba(86, 194, 255, 0.5); transform: translateY(-1px); }
.tb-lib-card-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.tb-lib-card-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.tb-lib-card-edit {
    flex: 0 0 auto;
    font-size: 12px;
    color: #8b96a5;
    padding: 0 3px;
    border-radius: 4px;
}
.tb-lib-card-edit:hover { color: #f7c948; background: rgba(247, 201, 72, 0.12); }
.tbl-card-desc { font-size: 11.5px; color: #97a3b4; line-height: 1.45; }
.tbl-card-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.tb-lib-back { margin-bottom: 8px; }
.tb-lib-info-wrap { padding-bottom: 8px; }

/* ── Study panel (tbl-*) ──────────────────────────────────────────────────── */
.tbl-chip {
    display: inline-block;
    font-size: 10.5px;
    padding: 1.5px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #aab3c2;
    white-space: nowrap;
}
.tbl-cheese { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.tbl-wr.good { background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.4); color: #86efac; }
.tbl-wr.bad { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }

.tbl-hero-name { font-size: 17px; font-weight: 700; color: #ecf2f8; margin-bottom: 4px; }
.tbl-hero-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tbl-desc, .tbl-fp { font-size: 12.5px; color: #aeb9c8; line-height: 1.5; margin: 4px 0; }
.tbl-fp b { color: #cfdae6; }

.tbl-sect {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #7e8a9a;
    margin: 14px 0 6px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    padding-bottom: 3px;
}
.tbl-sect-hint { font-weight: 400; text-transform: none; letter-spacing: normal; color: #66707e; margin-left: 6px; font-size: 10.5px; }
.tbl-list { margin: 4px 0; padding-left: 18px; font-size: 12px; color: #aeb9c8; }
.tbl-list li { margin: 2px 0; }

.tbl-kt { display: flex; flex-direction: column; gap: 2px; }
.tbl-kt-row {
    display: grid;
    grid-template-columns: 44px minmax(120px, auto) 1fr;
    gap: 8px;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.05);
}
.tbl-kt-t { color: #7dd3fc; font-variant-numeric: tabular-nums; font-weight: 600; }
.tbl-kt-action { color: #d7dfe9; }
.tbl-kt-note { color: #8b96a5; }

.tbl-variants { display: flex; flex-direction: column; gap: 5px; }
.tbl-variants-sub { font-size: 10.5px; color: #66707e; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.tbl-variant {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 9px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 6px;
    cursor: pointer;
    background: rgba(148, 163, 184, 0.04);
}
.tbl-variant input { accent-color: #56c2ff; }
.tbl-variant.sel { border-color: rgba(86, 194, 255, 0.55); background: rgba(86, 194, 255, 0.08); }
.tbl-variant-name { font-size: 12.5px; color: #dbe4ee; font-weight: 600; }
.tbl-variant-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: #8b96a5; margin-left: auto; }
.tbl-variant-meta .tbl-wr.good { color: #86efac; }
.tbl-variant-meta .tbl-wr.bad { color: #fca5a5; }

.tbl-steps { display: flex; flex-direction: column; gap: 1px; margin: 4px 0; }
.tbl-step {
    display: grid;
    grid-template-columns: 40px 30px 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    padding: 2.5px 6px;
    border-radius: 3px;
}
.tbl-step:nth-child(odd) { background: rgba(148, 163, 184, 0.045); }
.tbl-step.is-unmapped { opacity: 0.55; }
.tbl-step.is-reflow { box-shadow: inset 2px 0 0 rgba(125, 211, 252, 0.6); }
.tbl-step-t { color: #7dd3fc; font-variant-numeric: tabular-nums; }
.tbl-step-sup { color: #66707e; font-size: 10.5px; text-align: right; }
.tbl-step-name { color: #d7dfe9; }
.tbl-step-prov { display: flex; align-items: center; gap: 6px; }
.tbl-step-more { font-size: 11px; color: #66707e; padding: 4px 6px; }
.tbl-freq {
    display: inline-block;
    width: 46px; height: 5px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 3px;
    overflow: hidden;
}
.tbl-freq i { display: block; height: 100%; background: rgba(86, 194, 255, 0.75); border-radius: 3px; }
.tbl-win { font-size: 10px; color: #8b96a5; font-variant-numeric: tabular-nums; }
.tbl-rf { font-size: 9.5px; color: #7dd3fc; border: 1px solid rgba(125, 211, 252, 0.35); border-radius: 999px; padding: 0 5px; }

.tbl-refs { display: flex; flex-direction: column; gap: 4px; }
.tbl-ref {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 6px;
}
.tbl-ref-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.tbl-ref-name { font-size: 12.5px; color: #dbe4ee; font-weight: 600; }
.tbl-ref-sub { font-size: 10.5px; color: #8b96a5; }
.tbl-btn {
    appearance: none;
    font: inherit;
    font-size: 11.5px;
    background: rgba(86, 194, 255, 0.1);
    border: 1px solid rgba(86, 194, 255, 0.35);
    color: #aee2ff;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.tbl-btn:hover { background: rgba(86, 194, 255, 0.2); }
.tbl-btn:disabled { opacity: 0.5; cursor: default; }
.tbl-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.tbl-import { font-size: 13px; padding: 7px 16px; font-weight: 600; }
.tbl-actions-msg { font-size: 11.5px; color: #f7c948; }

/* ── Editor build-list provenance badges ──────────────────────────────────── */
.tb-prov { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; vertical-align: middle; }
.tb-prov-freq {
    display: inline-block;
    width: 34px; height: 4px;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 2px;
    overflow: hidden;
}
.tb-prov-freq i { display: block; height: 100%; background: rgba(86, 194, 255, 0.7); }
.tb-prov-win { font-size: 9.5px; color: #7e8a9a; font-variant-numeric: tabular-nums; }
.tb-prov-rf { font-size: 9.5px; color: #7dd3fc; }

/* Branch-bar corpus chip (games · win rate) */
.tb-branch-prov {
    font-size: 9.5px;
    color: #8b96a5;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    padding: 0 6px;
    margin-left: 4px;
}

/* ── Corpus context lane ──────────────────────────────────────────────────── */
.tb-corpus-lane {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 12px;
    padding: 3px 10px;
    background: rgba(13, 20, 33, 0.72);
    border: 1px solid rgba(125, 211, 252, 0.16);
    border-radius: 6px;
}
.tb-cl-lbl {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #5d89a8;
    flex: 0 0 auto;
}
.tb-cl-track { position: relative; flex: 1; height: 18px; min-width: 0; }
.tb-cl-band {
    position: absolute;
    top: 7px; height: 4px;
    background: rgba(86, 194, 255, 0.16);
    border-radius: 2px;
}
.tb-cl-mark {
    appearance: none;
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    background: none;
    border: none;
    padding: 0 2px;
    height: 18px;
    line-height: 18px;
    font-size: 11px;
    cursor: pointer;
    color: #9fb2c5;
}
.tb-cl-mark:hover { color: #e2f2ff; }
.tb-cl-mark.scout { color: #7dd3fc; }
.tb-cl-mark.decision { color: #f7c948; }
.tb-cl-mark.check { color: #86efac; }
.tb-cl-mark.hl { color: #64748b; font-size: 14px; }

/* Map intel (pro heat) card — relocated from its old floating-over-the-canvas
   position into the Notes side-tab. Neutralize the float chrome from
   tactical-build.css (absolute bottom-center + blur + shadow + the ≤767px
   bottom-sheet pin); the card flows as a normal section body here. Loads
   after tactical-build.css + higher specificity → wins both rules. */
.tb-root.tb-standalone .tb-side .tb-heat-info {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    max-width: none;
    pointer-events: auto;
    background: rgba(148, 163, 184, 0.05);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
    border: 1px solid rgba(148, 163, 184, 0.12);
    margin: 0 4px;
}

/* Notes-tab section-caption ghost actions (pin / clear guide notes). They sit
   on the "YOUR NOTES" caption row itself, styled to its quiet micro-label
   chrome — lowercase, borderless, accent only on hover. */
.tb-sn-cap-acts {
    float: right;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: 10px;
}
.tb-sn-act {
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;            /* inherits the caption's micro typography */
    letter-spacing: inherit;
    text-transform: none;
    font-weight: 600;
    color: #6f93ad;
    cursor: pointer;
    white-space: nowrap;
}
.tb-sn-act:hover { color: #aee2ff; text-decoration: underline; }
.tb-sn-act-danger { color: #9c7a7a; }
.tb-sn-act-danger:hover { color: #fca5a5; }

/* Eco-bar corpus delta chip */
.tb-corpus-delta { font-variant-numeric: tabular-nums; }
.tb-corpus-delta.good { color: #86efac; }
.tb-corpus-delta.warn { color: #f7c948; }
.tb-corpus-delta.bad { color: #fca5a5; }

/* ── Shared glossary tooltips (migrated from learn-guide.css) ─────────────── */
.gloss {
    border-bottom: 1px dotted rgba(125, 211, 252, 0.55);
    cursor: help;
    position: relative;
    color: inherit;
    transition: border-color 0.15s, color 0.15s;
    display: inline;
}
.gloss:hover,
.gloss:focus-visible {
    border-bottom-color: rgba(125, 211, 252, 0.9);
    color: #bae6fd;
    outline: none;
}
.gloss:focus-visible {
    outline: 1px solid rgba(125, 211, 252, 0.35);
    outline-offset: 2px;
    border-radius: 1px;
}
.gloss::after {
    content: attr(data-def);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 50;
    min-width: 200px;
    max-width: 340px;
    padding: 0.45rem 0.65rem;
    background: #0b1220;
    border: 1px solid rgba(125, 211, 252, 0.45);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    font-style: normal;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    white-space: normal;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    display: none;
    pointer-events: none;
}
.gloss:hover::after,
.gloss:focus-visible::after,
.gloss.is-open::after {
    display: block;
}
.gloss.is-open::after { pointer-events: auto; }

/* ── Mobile / tablet (≤767px): rail → horizontal strip, single-column grid.
   The modal CHROME deliberately inherits tactical-build.css's `.tb-root
   .tb-modal` bottom-sheet treatment (higher specificity, the editor's
   established mobile idiom) — only the library's INNER layout adapts here. ── */
@media (max-width: 767px) {
    .tb-lib-layout { grid-template-columns: 1fr; }
    .tb-lib-rail {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        gap: 6px;
    }
    .tb-lib-mu { flex: 0 0 auto; }
    .tb-lib-mu-n { display: none; }
    .tb-lib-main { max-height: none; }
    .tb-lib-grid { grid-template-columns: 1fr; }
    .tbl-kt-row { grid-template-columns: 44px 1fr; }
    .tbl-kt-note { grid-column: 1 / -1; padding-left: 52px; }
    .tbl-step { grid-template-columns: 40px 1fr auto; }
    .tbl-step-sup { display: none; }
    .tb-corpus-lane { margin: 2px 6px; }
    /* Touch has no hover — taps toggle .is-open (glossary.js). */
}
