/* ============================================================
   QFI Grant Insights Dashboard — styles
   Self-contained. No framework. Brand fonts via Adobe Typekit:
   URW DIN (titles) + Lato (body), kit vlo7ifg.
   Sections:  1) palette + base   2) FDD chrome (header/footer/
   carousel)   3) dashboard (hero, KPIs, map, purpose, table)
   ============================================================ */

/* ---- 1. Palette + base --------------------------------------------------- */
:root {
    --bg: #242629; /* page */
    --card: #16161a; /* primary card surface */
    --card-2: #1d1e22; /* nested / hover surface */
    --map-bg: #131316; /* map well */
    --map-land: #1d1d22; /* state fill */
    --map-stroke: #34343d; /* state borders */
    --border: #2b2e33;
    --border-2: #3a3e44;
    --ink: #fffffe; /* headlines */
    --body: #94a1b2; /* body text */
    --muted: #6f7785;
    --accent: #8a1538; /* Qatar maroon */
    --accent-2: #b83a5b; /* lighter maroon (links, hovers, highlights) */

    --font-title: "urw-din", system-ui, sans-serif;
    --font-cond: "urw-din-semi-condensed", "urw-din", system-ui, sans-serif;
    --font-body:
        "lato", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --surface-blur: blur(10px);
    --footer-surface: linear-gradient(90deg, #16161a 0%, #241019 100%);
    --maxw: 1180px;
}

* {
    box-sizing: border-box;
}
html {
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
}
body {
    margin: 0;
    background:
        radial-gradient(
            1100px 540px at 50% -6%,
            rgba(138, 21, 56, 0.16),
            rgba(138, 21, 56, 0) 60%
        ),
        radial-gradient(
            900px 700px at 100% 100%,
            rgba(138, 21, 56, 0.06),
            rgba(138, 21, 56, 0) 55%
        ),
        linear-gradient(180deg, #2c2e32 0%, #242629 42%, #1c1e20 100%);
    background-color: var(--bg);
    background-attachment: fixed;
    color: var(--body);
    font-family: var(--font-body);
    line-height: 1.6;
}
h1,
h2,
h3,
h4 {
    font-family: var(--font-title);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}
a {
    color: var(--accent-2);
}
::selection {
    background: var(--accent);
    color: var(--ink);
}

/* ---- 2. FDD chrome: header --------------------------------------------- */
.fdd-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 75px;
    background: var(--footer-surface);
    -webkit-backdrop-filter: var(--surface-blur);
    backdrop-filter: var(--surface-blur);
}
.fdd-header-inner {
    height: 75px;
    display: flex;
    align-items: center;
    padding: 4px 30px;
    position: relative;
}
.fdd-logo {
    display: inline-flex;
    align-items: center;
    max-width: 210px;
}
.fdd-logo img {
    height: 64.73px;
    width: auto;
    display: block;
}
.fdd-nav-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    font-family: var(--font-body);
    font-weight: 700;
    color: #fff;
    font-size: 15px;
    letter-spacing: 0.5px;
    opacity: 0;
    transition:
        opacity 300ms ease,
        transform 300ms ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    max-width: 50%;
    text-align: center;
}
.fdd-nav-title.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.fdd-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.fdd-nav-updated {
    font-size: 12px;
    color: var(--body);
    white-space: nowrap;
}
@media (max-width: 640px) {
    .fdd-nav-updated {
        display: none;
    }
}
.updated-mobile {
    display: none;
    width: min(820px, 94%);
    margin: 10px auto 0;
    font-size: 12px;
    color: var(--muted);
}
@media (max-width: 640px) {
    .updated-mobile {
        display: block;
    }
}
.fdd-header-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -9px;
    height: 9px;
    background: var(--ink);
    transform-origin: 0 50%;
    transform: scaleX(0);
    will-change: transform;
    pointer-events: none;
}
@media (max-width: 768px) {
    .fdd-nav-title {
        display: none;
    }
}

/* ---- 3. Dashboard shell ------------------------------------------------- */
#app {
    padding-top: 75px;
}
.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
}

/* Hero */
.hero {
    text-align: center;
    padding: 64px 0 40px;
}
.eyebrow {
    font-family: var(--font-cond);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-2);
    margin: 0 0 14px;
}
.hero h1 {
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1.08;
    max-width: 24ch;
    margin: 0 auto;
}
.hero-intro {
    width: min(760px, 92%);
    margin: 22px auto 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.hero-intro p {
    margin: 0;
    font-size: 20px;
    line-height: 1.6;
    color: var(--body);
}
.kpi-line {
    width: min(820px, 94%);
    margin: 26px auto 0;
    font-size: 15px;
    color: var(--body);
    border-top: 1px solid var(--border-2);
    padding-top: 20px;
}
.kpi-line strong {
    color: var(--ink);
    font-weight: 700;
}

/* Section scaffolding */
.section {
    padding: 28px 0;
    scroll-margin-top: 90px;
}
/* Related reading */
.reading-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.reading-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.12s ease;
}
.reading-item:hover {
    background: var(--card-2);
}
.reading-item:hover .reading-title {
    color: var(--accent-2);
}
.reading-meta {
    font-family: var(--font-cond);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    font-weight: 700;
    color: var(--body);
}
.reading-title {
    color: var(--ink);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.credits-wrap {
    border-top: 1px solid var(--border);
    padding-top: 28px;
}
.credits-title {
    font-family: var(--font-cond);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
    text-align: center;
    margin: 0 0 12px;
}
.credits {
    margin: 0;
    font-size: 15px;
    line-height: 1.7;
    color: #c2c7cf;
    text-align: center;
}
.credits strong {
    font-weight: 700;
    color: var(--ink);
}
.section-head {
    margin-bottom: 18px;
}
.section-head h2 {
    font-size: 26px;
}
.section-head p {
    margin: 6px 0 0;
    font-size: 15px;
    color: var(--body);
    max-width: none;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.map-card {
    background: none;
    border: none;
    border-radius: 0;
}

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 8px 0 16px;
}
.kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
}
.kpi-label {
    font-family: var(--font-cond);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 700;
    color: var(--body);
    margin: 0 0 8px;
}
.kpi-value {
    font-family: var(--font-title);
    font-feature-settings: "tnum" 1;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1;
}
@media (max-width: 640px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kpi-value {
        font-size: 24px;
    }
}

/* Map */
.map-card {
    position: relative;
    overflow: hidden;
    padding: 0;
}
.map-frame {
    position: relative;
    width: 100%;
    height: 460px;
}
.qfi-usmap {
    display: block;
    width: 100%;
    height: 100%;
}
.qfi-usmap .land {
    fill: var(--map-land);
    stroke: var(--map-stroke);
    stroke-width: 0.7;
    stroke-linejoin: round;
}
.qfi-usmap circle {
    cursor: pointer;
    transition: fill-opacity 0.15s;
}
.map-tip {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
    background: #0f0f12;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    z-index: 5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    max-width: 300px;
}
.map-tip-h {
    font-family: var(--font-title);
    font-weight: 700;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.25;
}
.map-tip-s {
    color: var(--body);
    font-size: 12px;
    margin-top: 2px;
}
.map-tip-list {
    margin-top: 7px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.map-tip-li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 12px;
    color: var(--body);
}
.map-tip-li span:last-child {
    color: var(--ink);
    font-family: var(--font-title);
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}
.map-tip-li.more {
    color: var(--accent-2);
}
.map-legend {
    position: absolute;
    left: 16px;
    bottom: 14px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--body);
}
.map-legend .dot {
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.65;
}
@media (max-width: 600px) {
    .map-frame {
        height: 320px;
    }
}

/* Timeline (overlapping grant periods) */
.timeline-card {
    position: relative;
    overflow: hidden;
    padding: 18px 0 0;
}
.timeline-frame {
    position: relative;
    width: 100%;
}
.qfi-timeline {
    display: block;
    width: 100%;
}
.qfi-timeline rect {
    transition: stroke-width 0.12s;
}
.timeline-axis .domain {
    stroke: var(--border-2);
}
.timeline-axis .tick line {
    stroke: var(--border);
}
.timeline-axis .tick text {
    fill: var(--body);
    font-size: 11px;
    font-family: var(--font-cond);
}

/* Purpose focus — horizontal bars */
.purpose-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
}
.purpose-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
    align-items: baseline;
}
.purpose-row.clickable {
    cursor: pointer;
    padding: 7px 8px;
    margin: 0 -8px;
    border-radius: 8px;
    transition: background 0.12s ease;
}
.purpose-row.clickable:hover {
    background: var(--card-2);
}
.purpose-row.clickable:hover .purpose-name {
    color: var(--accent-2);
}
.purpose-row.clickable:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}
.purpose-name {
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}
.purpose-amt {
    font-family: var(--font-title);
    font-feature-settings: "tnum" 1;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}
.purpose-meta {
    grid-column: 1 / -1;
}
.purpose-bar {
    height: 8px;
    border-radius: 6px;
    background: var(--card-2);
    overflow: hidden;
}
.purpose-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 6px;
}
.purpose-count {
    font-size: 12px;
    color: var(--body);
    margin-top: 5px;
}

/* Side-by-side breakdown charts (purpose + schools) */
.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
.chart-title {
    font-family: var(--font-cond);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    font-weight: 700;
    color: var(--body);
    margin: 0;
    padding: 18px 22px 2px;
}
.chart-hint {
    margin: 4px 22px 10px;
    font-size: 12px;
    color: var(--muted);
}
.chart-title + .purpose-list,
.chart-hint + .purpose-list {
    padding-top: 14px;
}
/* Equal-size, independently scrolling chart bodies */
.breakdown-grid .purpose-list {
    height: 440px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}
.breakdown-grid .purpose-list::-webkit-scrollbar {
    width: 8px;
}
.breakdown-grid .purpose-list::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 8px;
}
.breakdown-grid .purpose-list::-webkit-scrollbar-track {
    background: transparent;
}
@media (max-width: 820px) {
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
}

/* Grant table */
.table-tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.table-filter {
    margin-right: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-radius: 9999px;
    border: 1px solid var(--accent);
    background: rgba(138, 21, 56, 0.15);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.table-filter[hidden] {
    display: none;
}
.table-filter:hover {
    background: rgba(138, 21, 56, 0.26);
}
.table-filter .tf-clear {
    color: var(--accent-2);
    font-weight: 700;
    white-space: nowrap;
}
.table-search {
    width: min(320px, 100%);
    background: var(--card-2);
    border: 1px solid var(--border-2);
    border-radius: 9999px;
    color: var(--ink);
    font-size: 14px;
    padding: 9px 16px;
    outline: none;
    transition: border-color 0.15s;
}
.table-search::placeholder {
    color: var(--muted);
}
.table-search:focus {
    border-color: var(--accent);
}
.table-scroll {
    max-height: 560px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
}
table.grants {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13.5px;
}
table.grants thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-2);
    color: var(--body);
    font-family: var(--font-cond);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    padding: 12px 14px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}
table.grants thead th:hover {
    color: var(--ink);
}
table.grants thead th .arrow {
    opacity: 0.5;
    font-size: 10px;
    margin-left: 4px;
}
table.grants tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--body);
}
table.grants tbody tr:hover td {
    background: var(--card-2);
}
table.grants td.school {
    color: var(--ink);
    font-weight: 600;
}
table.grants td.amt {
    font-family: var(--font-title);
    font-feature-settings: "tnum" 1;
    color: var(--ink);
    white-space: nowrap;
    text-align: right;
}
table.grants td.year {
    white-space: nowrap;
    line-height: 1.4;
}
table.grants td.year .date-to {
    color: var(--muted);
    font-size: 12px;
}
table.grants thead th.src-col {
    cursor: default;
    text-align: right;
}
table.grants thead th.src-col:hover {
    color: var(--body);
}
table.grants td.src-cell {
    text-align: right;
    white-space: nowrap;
}
.src-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 6px;
    border: 1px solid var(--border-2);
    background: transparent;
    color: var(--accent-2);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}
.src-btn:hover {
    background: rgba(184, 58, 91, 0.14);
    border-color: var(--accent-2);
    color: var(--ink);
}
.src-none {
    color: var(--muted);
}
.table-empty {
    padding: 28px;
    text-align: center;
    color: var(--body);
}

/* Loading / error states */
.state-msg {
    padding: 40px;
    text-align: center;
    color: var(--body);
}
.state-msg.err {
    color: #f87171;
}

/* ---- 4. Related visuals (FDD) — minimal image grid ---------------------- */
.rv-section {
    max-width: calc(var(--maxw) * 0.6);
    margin: 0 auto;
    padding: 44px 24px 48px;
    border-top: 1px solid var(--border);
    scroll-margin-top: 85px;
}
.rv-title {
    font-family: var(--font-cond);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
    text-align: center;
    margin: 0 0 22px;
}
.rv-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.rv-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    transition: transform 0.2s ease;
}
.rv-thumb {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: var(--card-2);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease;
}
.rv-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.rv-name {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 600;
    color: var(--body);
    text-align: center;
    width: min(28ch, 100%);
    margin: 0 auto;
    max-height: calc(1.35em * 3);
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}
.rv-tile:hover {
    transform: translateY(-3px);
}
.rv-tile:hover .rv-thumb {
    border-color: var(--accent-2);
}
.rv-tile:hover .rv-name {
    color: var(--ink);
}
@media (max-width: 900px) {
    .rv-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 560px) {
    .rv-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- 5. Footer (FDD) ---------------------------------------------------- */
.fdd-footer {
    position: relative;
    background: var(--card);
    -webkit-backdrop-filter: var(--surface-blur);
    backdrop-filter: var(--surface-blur);
    padding: 48px 24px;
    overflow: hidden;
    margin-top: 20px;
}
.fdd-footer-gradient {
    position: absolute;
    inset: 0;
    background: var(--footer-surface);
    pointer-events: none;
}
.fdd-footer-inner {
    position: relative;
    max-width: 1140px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 48px;
    flex-wrap: wrap;
}
.fdd-footer-left {
    width: min(672px, 100%);
    display: flex;
    flex-direction: column;
    gap: 22.8px;
}
.fdd-footer-logo {
    display: inline-flex;
    align-items: center;
    height: 48px;
    overflow: hidden;
    text-decoration: none;
}
.fdd-footer-logo img {
    height: 48px;
    width: auto;
    display: block;
}
.fdd-footer-description {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    line-height: 22.75px;
    color: #c7ccd3;
    white-space: normal;
}
.fdd-footer-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    padding-top: 0.7px;
}
.fdd-footer-copyright,
.fdd-footer-privacy {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: rgba(255, 255, 255, 0.7);
}
.fdd-footer-privacy {
    text-decoration: underline;
    text-underline-position: from-font;
}
.fdd-footer-privacy:hover {
    color: rgba(255, 255, 255, 0.9);
}
.fdd-footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 24px;
    flex: 1 1 240px;
    min-width: 240px;
}
.fdd-footer-ctas {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}
.fdd-footer-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 13px 25px;
    color: #d3d7dc;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    text-decoration: none;
    text-align: center;
}
.fdd-footer-pill:hover {
    background: rgba(255, 255, 255, 0.08);
}
.fdd-footer-social {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}
.fdd-footer-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 9999px;
    text-decoration: none;
}
.fdd-footer-social-link:hover {
    background: rgba(255, 255, 255, 0.08);
}
.fdd-footer-social-link img {
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
@media (max-width: 900px) {
    .fdd-footer-right {
        align-items: flex-start;
    }
}


