/* ==========================================================================
   Research study page + /research/ hub (CPT research)
   Enqueued only on research pages (functions.php). Layout follows the mock
   docs/tech-tasks/2026-10-research-apr-index-mock.html: one reading column,
   stat tiles in an auto-fit grid, HTML/CSS bar rows that reflow on phones,
   table scrolling sideways inside its own box (never the page).
   Colour is never the only carrier of meaning: every bar has a text value
   and n=, store/bank chips carry a word.
   ========================================================================== */

.fb-rs,
.fb-rs-hub {
    --rs-surface: #ffffff;
    --rs-bg: #f7f9fc;
    --rs-fg: #14213a;
    --rs-muted: #5a6578;
    --rs-faint: #6f7888;
    --rs-line: #e3e7ee;
    --rs-grid: #eef1f5;
    --rs-brand: #1a4fa0;
    --rs-prime: #b9c0cc;
    --rs-store: #a8791f;
    --rs-bank: #1a4fa0;
    --rs-chip-store: #f6eedb;
    --rs-chip-bank: #e7eef9;
    --rs-focus: #1d4ed8;
    --rs-label-w: 190px;
    --rs-val-w: 60px;      /* room right of the bars for the value label */
    --rs-ease: cubic-bezier(.2, .7, .2, 1);
}

/* Dark palette: only when the site itself runs a dark palette (Kadence colour
   switch / data-theme hook), so the blocks never turn dark on a white page. */
.color-switch-dark .fb-rs,
[data-theme="dark"] .fb-rs,
.color-switch-dark .fb-rs-hub,
[data-theme="dark"] .fb-rs-hub {
    --rs-surface: #191d25;
    --rs-bg: #12151b;
    --rs-fg: #e8ecf3;
    --rs-muted: #a3acbb;
    --rs-faint: #8f98a8;
    --rs-line: #2a303b;
    --rs-grid: #222833;
    --rs-brand: #5b8ee0;
    --rs-prime: #566070;
    --rs-store: #c69a3e;
    --rs-bank: #5b8ee0;
    --rs-chip-store: #3a2f17;
    --rs-chip-bank: #1c2b45;
    --rs-focus: #7aa7f0;
}

.fb-rs-num,
.fb-rs-table td {
    font-variant-numeric: tabular-nums;
}

/* --- header ------------------------------------------------------------ */
.fb-rs-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--rs-brand);
    margin: 0 0 6px;
}
.fb-rs-lede {
    color: var(--rs-muted);
    font-size: 1.05rem;
    margin: 10px 0 0;
}
.fb-rs-missing {
    padding: 14px 16px;
    border: 1px solid var(--rs-line);
    border-radius: 8px;
    color: var(--rs-muted);
}

/* --- stat tiles -------------------------------------------------------- */
.fb-rs-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin: 24px 0 8px;
}
.fb-rs-tile {
    background: var(--rs-surface);
    border: 1px solid var(--rs-line);
    border-radius: 10px;
    padding: 16px;
    display: grid;
    gap: 8px;
    align-content: start;
}
.fb-rs-tile p { margin: 0; }
.fb-rs-tile__big {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--rs-fg);
    font-variant-numeric: tabular-nums;
}
.fb-rs-tile__big small {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--rs-muted);
}
.fb-rs-tile__text { font-size: 0.875rem; line-height: 1.45; color: var(--rs-muted); }
.fb-rs-tile__asof { font-size: 0.75rem; color: var(--rs-faint); }

/* --- blocks ------------------------------------------------------------ */
.fb-rs-block {
    margin: 40px 0;
    display: grid;
    gap: 14px;
}
.fb-rs-block h2 { margin: 0; }
.fb-rs-sub,
.fb-rs-foot,
.fb-rs-note {
    color: var(--rs-muted);
    font-size: 0.875rem;
    margin: 0;
}
.fb-rs-note b { color: var(--rs-fg); }

/* controls (shown by research.js) */
.fb-rs-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-rs-controls[hidden] { display: none; }
.fb-rs-seg {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--rs-line);
    border-radius: 999px;
    padding: 3px;
    background: var(--rs-surface);
}
.fb-rs-seg button {
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    color: var(--rs-muted);
    background: none;
    border: 0;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
    min-height: 36px;
}
.fb-rs-seg button[aria-pressed="true"] { background: var(--rs-brand); color: #fff; }

.fb-rs-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.8125rem;
    color: var(--rs-muted);
    margin: 0;
}
.fb-rs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fb-rs-margin-mode .fb-rs-legend__apr { display: none; }
.fb-rs-sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.fb-rs-sw--prime { background: var(--rs-prime); }
.fb-rs-sw--margin { background: var(--rs-brand); }

/* --- bar chart --------------------------------------------------------- */
.fb-rs-chart {
    position: relative;
    background: var(--rs-surface);
    border: 1px solid var(--rs-line);
    border-radius: 12px;
    padding: 16px 16px 12px;
    margin: 0;
    list-style: none;
}
.fb-rs-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
    position: relative;
}
.fb-rs-grid {
    position: absolute;
    top: 16px;
    bottom: 34px;
    left: calc(16px + var(--rs-label-w));
    right: calc(16px + var(--rs-val-w));
    pointer-events: none;
}
.fb-rs-grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rs-grid); }
.fb-rs-row {
    display: grid;
    grid-template-columns: var(--rs-label-w) 1fr;
    align-items: center;
    min-height: 34px;
    border-radius: 6px;
    position: relative;
    margin: 0;
}
.fb-rs-row[tabindex] { cursor: pointer; }
.fb-rs-row:focus-visible,
.fb-rs-seg button:focus-visible,
.fb-rs-table a:focus-visible,
.fb-rs-btn:focus-visible,
.fb-rs-copy:focus-visible,
.fb-rs-tablebox:focus-visible {
    outline: 2px solid var(--rs-focus);
    outline-offset: 2px;
}
.fb-rs-row:hover .fb-rs-track,
.fb-rs-row.is-active .fb-rs-track { filter: brightness(1.06); }
.fb-rs-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    padding-right: 10px;
    display: grid;
    color: var(--rs-fg);
}
.fb-rs-name small {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--rs-faint);
    font-variant-numeric: tabular-nums;
}
.fb-rs-track { position: relative; height: 22px; display: flex; align-items: center; padding-right: var(--rs-val-w); }
.fb-rs-bar {
    height: 100%;
    display: block;
    flex: none;            /* widths are the scale: never shrink to make room for the value */
    transition: width 1s var(--rs-ease);
}
.fb-rs-bar--prime { background: var(--rs-prime); border-radius: 4px 0 0 4px; }
.fb-rs-bar--margin { background: var(--rs-brand); border-radius: 0 4px 4px 0; margin-left: 2px; }
.fb-rs-margin-mode .fb-rs-bar--prime { width: 0 !important; }
.fb-rs-margin-mode .fb-rs-bar--margin { border-radius: 4px; margin-left: 0; }
.fb-rs-bar--store { background: var(--rs-store); border-radius: 4px; height: 26px; }
.fb-rs-bar--bank { background: var(--rs-bank); border-radius: 4px; height: 26px; }
.fb-rs-val {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rs-fg);
    padding-left: 8px;
    white-space: nowrap;
    transition: opacity .3s;
}
.fb-rs-axis {
    position: relative;
    height: 14px;
    margin: 8px var(--rs-val-w) 0 var(--rs-label-w);
    font-size: 0.75rem;
    color: var(--rs-faint);
    font-variant-numeric: tabular-nums;
}
.fb-rs-axis span { position: absolute; transform: translateX(-50%); line-height: 1; white-space: nowrap; }
/* first-view growth (research.js adds .is-pre, then removes it) */
.fb-rs-chart.is-pre .fb-rs-bar { width: 0 !important; }
.fb-rs-chart.is-pre .fb-rs-val { opacity: 0; }

/* tooltip */
.fb-rs-tip {
    position: absolute;
    z-index: 5;
    min-width: 220px;
    max-width: 280px;
    background: var(--rs-surface);
    color: var(--rs-fg);
    border: 1px solid var(--rs-line);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(10, 20, 40, .16);
    font-size: 0.8125rem;
    pointer-events: none;
}
.fb-rs-tip.is-pinned { pointer-events: auto; }
.fb-rs-tip[hidden] { display: none; }
.fb-rs-tip h3 { margin: 0 0 6px; font-size: 0.875rem; line-height: 1.25; }
.fb-rs-tip dl { display: grid; grid-template-columns: auto auto; gap: 3px 14px; margin: 0; }
.fb-rs-tip dt { color: var(--rs-muted); }
.fb-rs-tip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.fb-rs-tip a { display: inline-block; margin-top: 8px; color: var(--rs-brand); font-weight: 600; }

/* --- store vs bank ----------------------------------------------------- */
.fb-rs-pair { display: grid; gap: 10px; }
.fb-rs-pair[hidden] { display: none; }
.fb-rs-pair__title { font-size: 1rem; margin: 0; }
.fb-rs-js .fb-rs-pair__title { display: none; }
.fb-rs-chart--pair { display: grid; gap: 8px; }
.fb-rs-gap { font-weight: 600; margin: 0; }
.fb-rs-gap .fb-rs-num { font-size: 1.125rem; }

/* --- most expensive cards --------------------------------------------- */
.fb-rs-top {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--rs-surface);
    border: 1px solid var(--rs-line);
    border-radius: 12px;
}
.fb-rs-top li {
    display: grid;
    grid-template-columns: 2.2em 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid var(--rs-line);
    margin: 0;
}
.fb-rs-top li:first-child { border-top: 0; }
.fb-rs-top__rank { font-size: 0.8125rem; color: var(--rs-faint); }
.fb-rs-top__name { font-weight: 600; font-size: 0.875rem; min-width: 0; }
.fb-rs-top__name small { display: block; font-weight: 400; color: var(--rs-muted); font-size: 0.75rem; }
.fb-rs-top__apr { font-weight: 600; }
.fb-rs-chip {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    line-height: 1;
    border-radius: 999px;
    padding: 5px 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--rs-fg);
}
.fb-rs-chip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.fb-rs-chip--store { background: var(--rs-chip-store); }
.fb-rs-chip--store i { background: var(--rs-store); }
.fb-rs-chip--bank { background: var(--rs-chip-bank); }
.fb-rs-chip--bank i { background: var(--rs-bank); }

/* --- table ------------------------------------------------------------- */
.fb-rs-tablebox {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--rs-surface);
    border: 1px solid var(--rs-line);
    border-radius: 12px;
    max-width: 100%;
}
.fb-rs-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 640px;
    font-size: 0.875rem;
    margin: 0;
    border: 0;
}
.fb-rs-table th,
.fb-rs-table td {
    padding: 10px 10px;
    text-align: right;
    border: 0;
    border-top: 1px solid var(--rs-line);
    white-space: nowrap;
    background: var(--rs-surface);
    color: var(--rs-fg);
}
.fb-rs-table thead th {
    white-space: normal;   /* headers wrap so the table fits the 860px column on desktop */
    min-width: 4.5em;
    border-top: 0;
    font-weight: 600;
    color: var(--rs-muted);
    font-size: 0.75rem;
    vertical-align: bottom;
}
.fb-rs-table th:first-child,
.fb-rs-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 1;
}
.fb-rs-table tbody th { font-weight: 600; }
.fb-rs-table thead a { color: inherit; text-decoration: none; }
.fb-rs-table thead a::after { content: " \2195"; color: var(--rs-faint); }
.fb-rs-table th[aria-sort="descending"] a::after { content: " \2193"; color: var(--rs-fg); }
.fb-rs-table th[aria-sort="ascending"] a::after { content: " \2191"; color: var(--rs-fg); }

/* --- use this data ----------------------------------------------------- */
.fb-rs-use {
    background: var(--rs-surface);
    border: 1px solid var(--rs-line);
    border-radius: 12px;
    padding: 16px;
}
.fb-rs-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.fb-rs-btn {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rs-brand);
    border: 1px solid var(--rs-line);
    border-radius: 999px;
    padding: 9px 14px;
    text-decoration: none;
}
.fb-rs-btn:hover { border-color: var(--rs-brand); }
.fb-rs-cite { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.fb-rs-cite code {
    font-size: 0.8125rem;
    line-height: 1.5;
    background: var(--rs-bg);
    color: var(--rs-fg);
    border: 1px solid var(--rs-line);
    border-radius: 8px;
    padding: 10px 12px;
    white-space: normal;
    word-break: break-word;
    min-width: 0;
}
.fb-rs-copy {
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    background: var(--rs-brand);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    cursor: pointer;
}
.fb-rs-copy[hidden] { display: none; }

/* --- methodology ------------------------------------------------------- */
.fb-rs-acc {
    border: 1px solid var(--rs-line);
    border-radius: 10px;
    background: var(--rs-surface);
}
.fb-rs-acc summary { cursor: pointer; font-weight: 600; padding: 12px 16px; }
.fb-rs-acc__body { padding: 0 16px 14px; margin: 0; font-size: 0.9375rem; }
ul.fb-rs-acc__body { padding-left: calc(16px + 1.25em); }   /* the padding above would put the bullets outside the box */
.fb-rs-defs dt { font-weight: 600; margin-top: 10px; }
.fb-rs-defs dd { margin: 2px 0 0; color: var(--rs-muted); }

/* --- hub (/research/) -------------------------------------------------- */
.fb-rs-hub { max-width: 1100px; margin: 0 auto; padding: 0 16px 60px; }
.fb-rs-hub__header { text-align: center; padding: 40px 0 32px; }
.fb-rs-hub__header h1 { margin: 0 0 10px; }
.fb-rs-hub__header p:last-child { color: var(--rs-muted); max-width: 600px; margin: 0 auto; }
.fb-rs-hub__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.fb-rs-hub__card { border: 1px solid var(--rs-line); border-radius: 10px; overflow: hidden; background: var(--rs-surface); }
.fb-rs-hub__thumb img { display: block; width: 100%; height: auto; }
.fb-rs-hub__body { padding: 16px; }
.fb-rs-hub__body h2 { font-size: 1.15rem; margin: 0 0 6px; }
.fb-rs-hub__body h2 a { text-decoration: none; }
.fb-rs-hub__meta { font-size: 0.8125rem; color: var(--rs-faint); margin: 0 0 8px; }
.fb-rs-hub__empty { text-align: center; padding: 60px 0; color: var(--rs-muted); }

@media (max-width: 560px) {
    .fb-rs { --rs-label-w: 118px; }
    .fb-rs-top li { grid-template-columns: 1.8em 1fr auto; }
    .fb-rs-top li .fb-rs-chip { grid-column: 2; justify-self: start; }
    .fb-rs-cite { grid-template-columns: 1fr; }
    /* table: issuer names wrap so Issuer + Cards + Avg highest APR fit before the sideways scroll */
    .fb-rs-table tbody th { white-space: normal; min-width: 7.5em; max-width: 9em; }
    .fb-rs-table th,
    .fb-rs-table td { padding: 10px 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .fb-rs-bar,
    .fb-rs-val,
    .fb-rs-row { transition: none !important; }
}
