:root {
    --bg: #f7f5f0;
    --bg-alt: #edeae3;
    --fg: #111110;
    --fg-muted: #5a5852;
    --accent: #b8001f;
    --positive: #2e5c2a;
    --border: rgba(17, 17, 16, 0.12);
    --nav-h: 64px;
    --max: 1040px;
    --serif: "DM Serif Display", Georgia, serif;
    --sans: "Instrument Sans", system-ui, sans-serif;
    --t: 0.25s ease;
}

[data-theme="dark"] {
    --bg: #0f0f0d;
    --bg-alt: #1a1a17;
    --fg: #f0ede4;
    --fg-muted: #8a877e;
    --accent: #ff5d75;
    --positive: #6faa63;
    --border: rgba(240, 237, 228, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.65;
    transition:
        background var(--t),
        color var(--t);
    -webkit-font-smoothing: antialiased;
}

nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1.5rem, 5vw, 3.5rem);
    transition: background var(--t);
}

.nav-logo {
    font-family: var(--serif);
    font-size: 1.35rem;
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    list-style: none;
}

@media (max-width: 800px) {
    .nav-links li:not(.nav-toggle-item, .nav-social-item) {
        display: none;
    }
}

.nav-links a {
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg-muted);
    text-decoration: none;
    transition: color var(--t);
}

.nav-links a:hover {
    color: var(--fg);
}

.toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-muted);
    transition:
        border-color var(--t),
        color var(--t);
    white-space: nowrap;
}

.toggle:hover {
    color: var(--fg);
    border-color: var(--fg-muted);
}

.nav-social-item a {
    display: flex;
    align-items: center;
    color: var(--fg-muted);
    border-bottom: none;
}

.nav-social-item a:hover {
    color: var(--accent);
}

section {
    padding: clamp(2.5rem, 5vw, 4.5rem) clamp(1.5rem, 5vw, 3.5rem);
}

main section:nth-child(odd) {
    background: var(--bg-alt);
    transition: background var(--t);
}

.inner {
    max-width: var(--max);
    margin: 0 auto;
}

h1,
h2,
h3 {
    font-family: var(--serif);
    font-weight: 400;
    line-height: 1.05;
    text-wrap: balance;
}

h1 {
    font-size: clamp(3rem, 7.5vw, 6rem);
    letter-spacing: -0.025em;
}

h2 {
    font-size: clamp(2.6rem, 5.5vw, 4.8rem);
    letter-spacing: -0.02em;
    margin-bottom: 2.3rem;
}

h3 {
    font-size: 1.45rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

p {
    font-size: 0.98rem;
    margin-bottom: 1.1rem;
    text-wrap: pretty;
}

li {
    text-wrap: pretty;
}

p:last-child {
    margin-bottom: 0;
}

strong {
    font-weight: 600;
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--t);
}

a:hover {
    border-bottom-color: var(--accent);
}

.muted {
    color: var(--fg-muted);
}

.lead {
    font-size: 1.1rem;
    line-height: 1.65;
    margin-bottom: 1.5rem;
    max-width: 840px;
}

.inner > p:not(.chart-title, .chart-sub, .chart-src),
.inner > blockquote {
    max-width: 840px;
}

.hero-primary {
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    margin-top: 2rem;
    max-width: 540px;
    line-height: 1.55;
}

.hero-secondary {
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    margin-top: 0.85rem;
    max-width: 540px;
    color: var(--fg-muted);
    line-height: 1.55;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2.5rem;
}

.button {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.8rem 1.6rem;
    border-radius: 3px;
    text-decoration: none;
    transition:
        opacity 0.2s,
        border-color 0.2s;
}

.button.primary {
    background: var(--accent);
    color: #fff;
    border: none;
}

.button.primary:hover {
    opacity: 0.82;
}

[data-theme="dark"] .button.primary,
[data-theme="dark"] .grant-random:hover,
[data-theme="dark"] sup.c a:hover {
    color: #111110;
}

.button.secondary {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
}

.button.secondary:hover {
    border-color: var(--fg-muted);
}

sup.c {
    font-size: 0.65em;
    vertical-align: super;
    line-height: 0;
    margin-left: 1px;
}

sup.c a {
    color: var(--accent);
    border-bottom: none;
    padding: 0 2px;
}

sup.c a:hover {
    background: var(--accent);
    color: #fff;
    border-radius: 2px;
}

.tooltip-note {
    position: relative;
    color: var(--accent);
    cursor: help;
    padding: 0 2px;
}

.tooltip-note span {
    position: absolute;
    left: 50%;
    bottom: 1.4em;
    z-index: 20;
    width: min(360px, 80vw);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(4px);
    transition:
        opacity var(--t),
        transform var(--t);
}

[data-theme="dark"] .tooltip-note span {
    background: var(--bg-alt);
}

.tooltip-note:hover span,
.tooltip-note:focus span {
    opacity: 1;
    transform: translateX(-50%);
}

.demand-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1.4rem 1.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    max-width: 900px;
}

[data-theme="dark"] .demand-list {
    background: var(--bg-alt);
}

.demand-list li {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    font-size: 0.98rem;
    line-height: 1.55;
    text-wrap: pretty;
}

.demand-list .dn {
    font-family: var(--serif);
    color: var(--accent);
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    min-width: 1.5rem;
}

.grants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.grant-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.4rem 1.5rem;
    background: var(--bg);
    transition:
        border-color var(--t),
        background var(--t);
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] .grant-card {
    background: var(--bg-alt);
}

.grant-card:hover {
    border-color: var(--fg-muted);
}

.grant-card a {
    border-bottom: none;
}

.grant-card a:hover .grant-title {
    color: var(--accent);
}

.grant-amount {
    font-family: var(--serif);
    font-size: 1.65rem;
    color: var(--accent);
    display: block;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.grant-title {
    font-size: 0.94rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.6rem;
    color: var(--fg);
    transition: color var(--t);
}

.grant-meta {
    font-size: 0.76rem;
    color: var(--fg-muted);
}

.grant-note {
    font-size: 0.82rem;
    color: var(--fg-muted);
    margin-top: auto;
    min-height: 6.4rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
    line-height: 1.45;
    margin-bottom: 0;
}

.grant-card.static {
    border-color: var(--accent);
}

.grant-card.static .grant-amount {
    font-size: 1.1rem;
    font-family: var(--sans);
    color: var(--fg);
}

#grants-loading {
    color: var(--fg-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
}

.grants-disclaimer {
    margin-top: 2rem;
    font-size: 0.88rem;
    color: var(--fg-muted);
}

.grant-browser {
    margin-top: 2rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    padding: 1.25rem;
}

[data-theme="dark"] .grant-browser {
    background: var(--bg-alt);
}

.grant-browser-title {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

.grant-tools {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

@media (max-width: 720px) {
    .grant-tools {
        grid-template-columns: 1fr;
    }
}

.grant-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: 0.9rem;
    padding: 0.7rem 0.85rem;
}

[data-theme="dark"] .grant-search-input {
    background: var(--bg-alt);
}

.grant-search-input:focus {
    outline: 1px solid var(--accent);
    border-color: var(--accent);
}

.grant-random {
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.grant-random:hover {
    background: var(--accent);
    color: #fff;
}

.grant-count {
    color: var(--fg-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.grant-results {
    display: flex;
    flex-direction: column;
    max-height: 520px;
    overflow: auto;
    border-top: 1px solid var(--border);
}

.grant-result {
    display: grid;
    grid-template-columns: minmax(96px, 130px) 1fr;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
}

.grant-result:hover {
    border-bottom-color: var(--accent);
}

@media (max-width: 640px) {
    .grant-result {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

.grant-result-amount {
    color: var(--accent);
    font-family: var(--serif);
    font-size: 1.1rem;
    line-height: 1.15;
}

.grant-result-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grant-result-title {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.grant-result-meta {
    color: var(--fg-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

.grant-empty {
    padding-top: 1rem;
}

.compare-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
    margin-top: 2rem;
}

.compare-item {
    border-left: 3px solid var(--border);
    padding-left: 1.5rem;
    transition: border-color var(--t);
}

.compare-item:hover {
    border-left-color: var(--accent);
}

.ci-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.compare-item h3 {
    margin-bottom: 0.75rem;
    font-size: 1.35rem;
}

.compare-item p {
    margin-bottom: 0;
    font-size: 0.98rem;
}

.ci-normie {
    font-size: 0.95rem;
    color: var(--fg-muted);
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px dashed var(--border);
}

.chart-wrap {
    margin: 2.5rem 0 1.5rem;
    padding: 2rem 1.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
}

[data-theme="dark"] .chart-wrap {
    background: var(--bg-alt);
}

.chart-title {
    font-family: var(--serif);
    font-size: 1.35rem;
    text-align: center;
    margin-bottom: 0.2rem;
}

.chart-sub {
    font-size: 0.82rem;
    color: var(--fg-muted);
    text-align: center;
    margin-bottom: 1.75rem;
}

.chart-svg {
    width: 100%;
    max-width: 560px;
    display: block;
    margin: 0 auto;
}

.chart-src {
    font-size: 0.72rem;
    color: var(--fg-muted);
    text-align: center;
    margin-top: 1rem;
}

.chart-src a {
    color: var(--fg-muted);
}

.chart-src a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

blockquote {
    border-left: 2px solid var(--accent);
    padding: 0.5rem 1.5rem;
    margin: 2rem 0;
    font-family: var(--sans);
    font-style: normal;
    font-size: 1.08rem;
    font-weight: 500;
    color: var(--fg);
    line-height: 1.55;
}

blockquote cite {
    display: block;
    font-style: normal;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--fg-muted);
    margin-top: 0.65rem;
    letter-spacing: 0.04em;
}

ul.plain {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.25rem 0;
}

ul.plain li {
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.98rem;
}

ul.plain li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 600;
}

footer {
    padding: 2.5rem clamp(1.5rem, 5vw, 3.5rem);
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

footer p {
    font-size: 0.78rem;
    color: var(--fg-muted);
    margin: 0;
}

footer a {
    color: var(--fg-muted);
    border-bottom: none;
}

footer a:hover {
    color: var(--accent);
}

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition:
        opacity 0.5s ease,
        transform 0.5s ease;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}
