/* Funding page (VD-7b). The filter panel, callouts, stat tiles, chart cards and the Chart/Table control
 * come from design/components.css. This file adds the page's field grids, the award table, the pager and
 * the amount-basis tables. Colours come from design tokens only. Rules are scoped to #funding-root. */
#funding-root {
  --ink: var(--atlas-ink);
  --muted: var(--atlas-muted);
  --brand-dark: var(--atlas-brand-strong);
  --line: var(--atlas-line);
  --atlas-task: var(--atlas-task-money);
  color: var(--ink);
}

#funding-root * { box-sizing: border-box; }
#funding-root button,
#funding-root input,
#funding-root select { font: inherit; }
#funding-root button { min-height: 2.5rem; cursor: pointer; }
#funding-root button:disabled { opacity: 0.5; cursor: default; }
#funding-root a { color: var(--brand-dark); }
#funding-root :focus-visible { outline: 3px solid var(--atlas-accent); outline-offset: 2px; }

#funding-root .funding-page-head { margin-bottom: 0.15rem; }
#funding-root .atlas-page-head__lead { max-width: 80ch; }
#funding-root .atlas-callout .volume-caption,
#funding-root .atlas-callout p { margin: 0; color: inherit; font-size: inherit; }
#funding-root .data-note { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.9rem; }
#funding-root .result-count { margin: 0; color: var(--muted); font-size: 0.9rem; }

#funding-root .atlas-filters { margin: 0.25rem 0 0.1rem; }
#funding-root .atlas-filters__head { min-height: 2.5rem; padding: 0.25rem 0.75rem; }
#funding-root .atlas-filters__head h2 { font-size: var(--atlas-type-subsection-size); }
#funding-root .atlas-filters__body { gap: 0.4rem; padding: 0.5rem 0.75rem; }
#funding-root .atlas-filters__grid { gap: 0.65rem; }
#funding-root .grants-primary-filters { grid-template-columns: minmax(15rem, 2fr) repeat(4, minmax(9rem, 1fr)); }
#funding-root .grants-more-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
#funding-root .atlas-field { gap: 0.2rem; min-width: 0; }
#funding-root .atlas-label { font-size: 0.8rem; line-height: 1.2; }
#funding-root .atlas-input,
#funding-root .atlas-select,
#funding-root .atlas-search input { min-height: 2.5rem; }
#funding-root .grants-field input[type="number"],
#funding-root .grants-field input[type="search"] { box-sizing: border-box; width: 100%; min-width: 0; }
#funding-root .grants-check { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; }
#funding-root .grants-check label { font-size: 0.85rem; }
/* UX-25 touch target: keep the checkbox at 24 px. */
#funding-root .grants-check input[type="checkbox"] { flex: 0 0 auto; width: 1.5rem; height: 1.5rem; margin: 0; }
#funding-root .atlas-active-filters:not(:empty) { padding: 0 0.75rem 0.65rem; }
#funding-root .atlas-filter-chip button { min-width: 1.5rem; min-height: 1.5rem; }

#funding-root .atlas-result-line { margin: 0.4rem 0 0.55rem; }
#funding-root .atlas-result-line > #grants-status { margin: 0; }
#funding-root .atlas-result-line > .atlas-btn { margin-left: auto; }

#funding-root .grants-list { min-width: 0; margin-top: var(--atlas-space-5); }
#funding-root .grants-table-wrap { max-height: 75vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--atlas-radius-card); background: var(--atlas-surface); }
#funding-root .grants-table { width: 100%; min-width: 68rem; border-collapse: collapse; font-size: 0.85rem; }
#funding-root .grants-table th,
#funding-root .grants-table td { padding: 0.45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
#funding-root .grants-table tbody th { min-width: 16rem; max-width: 24rem; font-weight: 400; }
/* UX-32: award-title links fill their row-header cell, so keep a 24 px target. */
#funding-root .grants-table tbody th a { display: inline-block; min-height: 1.5rem; padding-block: 0.2rem; box-sizing: border-box; }
#funding-root .grants-table tbody th a { font-weight: 600; }
#funding-root .grants-table td { min-width: 5.5rem; }
#funding-root .grants-table td:nth-child(2) { min-width: 11rem; }
#funding-root .grants-table td:nth-child(7) { white-space: nowrap; }
#funding-root .grants-table thead th { position: sticky; top: 0; z-index: 1; padding: 0; background: var(--atlas-sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
#funding-root .grants-table thead th.num,
#funding-root .grants-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#funding-root .grants-sort { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 0.3rem; width: 100%; padding: 0.5rem 0.45rem; font-weight: 700; cursor: pointer; }
#funding-root .grants-table thead th.num .grants-sort { justify-content: flex-end; }
#funding-root .grants-sort:hover { background: var(--atlas-brand-wash); }
#funding-root .grants-sort:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: -3px; }
#funding-root .grants-arrow { min-width: 0.8rem; color: var(--muted); font-size: 0.7rem; }
#funding-root .grants-table th[aria-sort="ascending"] .grants-arrow,
#funding-root .grants-table th[aria-sort="descending"] .grants-arrow { color: var(--brand-dark); font-size: 0.8rem; }
/* The sorted column carries the money plane: a 3 px gold bar along the foot of its header. */
#funding-root .grants-table thead th[aria-sort="ascending"]::after,
#funding-root .grants-table thead th[aria-sort="descending"]::after {
  position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: var(--atlas-task); content: "";
}
#funding-root .grants-table .topic-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.3rem; }
#funding-root .grants-table .topic-chip { font-size: 0.72rem; padding: 0.1rem 0.45rem; }
#funding-root .grants-table .atlas-badge { min-height: 1.5rem; font-size: 0.75rem; }
#funding-root .grants-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#funding-root .empty { padding: 1.25rem; border: 1px dashed var(--atlas-boundary); border-radius: var(--atlas-radius-control); color: var(--muted); text-align: center; }

#funding-root .grants-pager { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.6rem; font-size: 0.85rem; }
#funding-root .grants-pager label { display: inline-flex; gap: 0.35rem; align-items: center; margin-left: auto; }
#funding-root .grants-pager .atlas-select { min-height: 2.5rem; width: auto; }

#funding-root .grants-basis > h2,
#funding-root .open-calls > h2 { margin: var(--atlas-space-5) 0 var(--atlas-space-2); font-size: var(--atlas-type-subsection-size); }
/* Framework's default stylesheet caps every table at 640 px (40rem), which narrowed the amount-basis table and
 * the Sankey table on wide screens. The Funding page lifts that cap for all of its tables. Below about 36rem
 * a table scrolls inside its own box instead of wrapping every cell. */
#funding-root table { max-width: none; }
#funding-root #grants-basis { max-width: 100%; overflow-x: auto; }
#funding-root .grants-subtotals { width: 100%; min-width: 36rem; margin: 0.5rem 0; border-collapse: collapse; font-size: 0.85rem; }
#funding-root .grants-subtotals th[scope="row"] { min-width: 12rem; }
#funding-root .grants-subtotals td:last-child { min-width: 14rem; }
#funding-root .grants-subtotals caption { padding-bottom: 0.4rem; color: var(--muted); text-align: left; }
#funding-root .grants-subtotals th,
#funding-root .grants-subtotals td { padding: 0.4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
#funding-root .grants-subtotals .num { text-align: right; }
/* Heatmap cells are buttons. An empty cell is disabled, but it keeps the full fill of the grid, not the 50% fade. */
#funding-root .fv-cell:disabled { opacity: 1; cursor: default; }
#funding-root .open-calls-list { margin: 0.75rem 0 0; padding-left: 1.25rem; }
#funding-root .open-calls-list li + li { margin-top: 0.75rem; }

@media (max-width: 62rem) {
  #funding-root .grants-primary-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 40rem) {
  #funding-root .grants-primary-filters,
  #funding-root .grants-more-grid { grid-template-columns: minmax(0, 1fr); }
  #funding-root .atlas-result-line > .atlas-btn { margin-left: 0; }
}
