/*
 * Painel "Refinar" das páginas de termo (v1.73.0).
 *
 * Mesmo visual da ficha pública do plugin (.biblio-sheet / .biblio-copies):
 * cartão branco com borda #e3e8ec, títulos #1d3557, texto secundário
 * #5a6874, contagens em pílula #eef2f5, destaque #2d6da3.
 *
 * O tema do Tainacan (Tainacan Interface, Blocksy…) estiliza h2/h3 e button
 * com fonte, caixa alta e espaçamento próprios: aqui tudo dentro do painel
 * parte de um reset, com seletores de duas classes para vencer o tema.
 */
.tbtf {
    --tbtf-ink: #16212b;
    --tbtf-head: #1d3557;
    --tbtf-muted: #5a6874;
    --tbtf-line: #e3e8ec;
    --tbtf-line-soft: #eef2f5;
    --tbtf-soft: #f4f7f9;
    --tbtf-accent: #2d6da3;
    --tbtf-accent-soft: #e8f0f8;
    box-sizing: border-box;
    width: auto;
    max-width: 100%;
    margin: 24px var(--tainacan-container-padding, 4.1667%) 8px;
    padding: 16px 20px 18px;
    background: #fff;
    border: 1px solid var(--tbtf-line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(16, 32, 48, .05);
    color: var(--tbtf-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    overflow: hidden;
}
.tbtf *, .tbtf *::before, .tbtf *::after { box-sizing: border-box; }

/* Reset contra o tema */
.tbtf .tbtf__title, .tbtf .tbtf__facet-title {
    margin: 0; padding: 0; border: 0;
    font-family: inherit; text-transform: none; letter-spacing: normal;
}
.tbtf button, .tbtf a.tbtf__value {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}
.tbtf button:focus-visible, .tbtf a:focus-visible { outline: 2px solid var(--tbtf-accent); outline-offset: 2px; border-radius: 6px; }

/* Cabeçalho */
.tbtf .tbtf__head { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.tbtf .tbtf__title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--tbtf-head); min-width: 0; }
.tbtf .tbtf__title-verb {
    display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px;
    background: var(--tbtf-accent-soft); color: var(--tbtf-accent);
    font-size: 12px; font-weight: 600; vertical-align: 2px;
}
.tbtf .tbtf__total {
    font-size: 12.5px; font-weight: 600; color: var(--tbtf-muted);
    background: var(--tbtf-line-soft); border-radius: 999px; padding: 2px 10px;
}
.tbtf .tbtf__toggle {
    margin-left: auto; padding: 5px 12px; border: 1px solid var(--tbtf-line); border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--tbtf-accent); background: #fff;
}
.tbtf .tbtf__toggle:hover { background: var(--tbtf-soft); }
.tbtf .tbtf__body { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--tbtf-line-soft); }
.tbtf.is-loading .tbtf__body { opacity: .55; transition: opacity .15s; }
.tbtf.is-collapsed { padding-bottom: 16px; }

/* Caminho na hierarquia */
.tbtf .tbtf__path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; color: var(--tbtf-muted); }
.tbtf .tbtf__path-link { color: var(--tbtf-accent); text-decoration: none; }
.tbtf .tbtf__path-link:hover { text-decoration: underline; }
.tbtf .tbtf__path-here { color: var(--tbtf-ink); font-weight: 600; }

/* Filtros aplicados */
.tbtf .tbtf__active { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.tbtf .tbtf__active-label { font-size: 12.5px; font-weight: 600; color: var(--tbtf-muted); margin-right: 2px; }
.tbtf .tbtf__chip {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    padding: 3px 4px 3px 10px; border: 1px solid #c9dbeb; border-radius: 999px;
    background: var(--tbtf-accent-soft); color: var(--tbtf-ink); font-size: 13px;
}
.tbtf .tbtf__chip:hover { border-color: var(--tbtf-accent); }
.tbtf .tbtf__chip.is-negated .tbtf__chip-label { text-decoration: line-through; }
.tbtf .tbtf__chip-group { color: var(--tbtf-muted); }
.tbtf .tbtf__chip-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.tbtf .tbtf__chip-x {
    display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
    border-radius: 50%; font-size: 15px; line-height: 1; color: var(--tbtf-accent);
}
.tbtf .tbtf__chip:hover .tbtf__chip-x { background: #fff; }
.tbtf .tbtf__clear { font-size: 13px; color: var(--tbtf-accent); text-decoration: underline; margin-left: 4px; }

/* Facetas */
.tbtf .tbtf__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px 24px; }
.tbtf .tbtf__facet { min-width: 0; }
.tbtf .tbtf__facet-title {
    display: block; margin: 0 0 6px; padding: 0 0 6px; border-bottom: 1px solid var(--tbtf-line-soft);
    font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--tbtf-head);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbtf .tbtf__values { list-style: none; margin: 0; padding: 0; }
.tbtf .tbtf__values li { margin: 0; padding: 0; list-style: none; }
.tbtf .tbtf__values li::before { content: none; }
.tbtf .tbtf__value {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
    padding: 4px 6px; margin: 0 -6px; width: calc(100% + 12px);
    border-radius: 6px; font-size: 13.5px; line-height: 1.35; color: var(--tbtf-ink); text-decoration: none;
}
.tbtf .tbtf__value:hover { background: var(--tbtf-soft); color: var(--tbtf-accent); }
.tbtf .tbtf__value-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbtf .tbtf__count {
    flex-shrink: 0; min-width: 24px; text-align: center; padding: 0 7px; border-radius: 999px;
    background: var(--tbtf-line-soft); color: var(--tbtf-muted);
    font-size: 11.5px; font-weight: 600; line-height: 18px; font-variant-numeric: tabular-nums;
}
.tbtf .tbtf__value:hover .tbtf__count { background: var(--tbtf-accent-soft); color: var(--tbtf-accent); }
.tbtf .tbtf__more { margin-top: 4px; padding: 2px 0; font-size: 12.5px; font-weight: 600; color: var(--tbtf-accent); }
.tbtf .tbtf__more:hover { text-decoration: underline; }
.tbtf .tbtf__empty { margin: 0; color: var(--tbtf-muted); font-size: 13px; }

@media (max-width: 720px) {
    .tbtf { margin: 16px 12px 8px; padding: 14px; }
    .tbtf .tbtf__grid { grid-template-columns: 1fr; gap: 14px; }
    .tbtf .tbtf__toggle { margin-left: 0; }
}

/* Painel na coluna da esquerda (sem filtros do Tainacan na página de termo, 1.73.0-beta.18):
   mesmo lugar dos filtros nas outras listas; facetas empilhadas. */
.tbtf.tbtf--side {
    flex: 0 0 20%;
    max-width: 20%;
    min-width: 230px;
    margin: 0 18px 0 0;
    align-self: flex-start;
    padding: 16px 14px;
    border-radius: 12px;
}
.tbtf.tbtf--side .tbtf__head { align-items: flex-start; }
.tbtf.tbtf--side .tbtf__title { font-size: 18px; font-weight: 700; flex: 1 1 100%; }
.tbtf.tbtf--side .tbtf__title-verb { display: block; margin: 0 0 6px; width: max-content; }
.tbtf.tbtf--side .tbtf__toggle { margin-left: 0; }
.tbtf.tbtf--side .tbtf__grid { grid-template-columns: 1fr; gap: 0; }
.tbtf.tbtf--side .tbtf__facet { padding: 12px 0 10px; border-top: 1px solid var(--tbtf-line); }
.tbtf.tbtf--side .tbtf__facet:first-child { border-top: 0; padding-top: 0; }
.tbtf.tbtf--side .tbtf__facet-title { font-size: 15px; font-weight: 700; color: var(--tbtf-ink); border-bottom: 0; white-space: normal; }
.tbtf.tbtf--side .tbtf__value-label { white-space: normal; overflow-wrap: anywhere; }
body.tbtf-side.tb-term-no-filters #tainacan-items-page .items-list-area {
    max-width: calc(80% - 18px) !important;
    flex: 1 1 0 !important;
}
@media (max-width: 768px) {
    .tbtf.tbtf--side { flex: 1 1 100%; max-width: 100%; margin: 0 0 14px; }
    body.tbtf-side.tb-term-no-filters #tainacan-items-page .items-list-area { max-width: 100% !important; flex: 1 1 100% !important; }
}
/* O tema dá tamanho grande a h2/h3; na coluna lateral os títulos seguem a escala dos filtros. */
.tbtf.tbtf--side :is(.tbtf__title, #tb-lists) { font-size: 17px !important; line-height: 1.3 !important; text-transform: none !important; }
.tbtf.tbtf--side :is(.tbtf__facet-title, #tb-lists) { font-size: 15px !important; font-weight: 700 !important; line-height: 1.3 !important; text-transform: none !important; }
/* Um só controle para mostrar/esconder filtros (1.73.0-beta.20): o botão de filtros do
   Tainacan volta a aparecer e o painel lateral segue o estado dele (.is-filters-menu-open),
   como a coluna de filtros nas outras listas. O "Recolher" próprio sai no modo lateral. */
/* Só no desktop: no celular o botão do Tainacan abre a coluna como janela (vazia nesta
   página); ali o painel fica sempre visível acima da lista. */
@media (min-width: 769px) {
    .tbtf.tbtf--side .tbtf__body[hidden] { display: block !important; }
    body.tbtf-side.tb-term-no-filters #tainacan-items-page #filter-menu-compress-button { display: inline-flex !important; }
    .tbtf.tbtf--side .tbtf__toggle { display: none !important; }
    body.tbtf-side #tainacan-items-page:not(.is-filters-menu-open) > .tbtf.tbtf--side { display: none; }
    body.tbtf-side.tb-term-no-filters #tainacan-items-page:not(.is-filters-menu-open) .items-list-area {
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }
}
