:root {
    --color-bg: #faf8f3;
    --color-surface: #ffffff;
    --color-text: #20241f;
    --color-text-muted: #6d6a5f;
    --color-border: #e6e1d3;
    --color-primary: #0f5c47;
    --color-primary-dark: #0a3f31;
    --color-accent-open: #b5892f;
    --font-heading: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --radius: 8px;
    --header-height: 3.75rem;
    /* Financial breakdown chart — validated categorical palette (adjacent-pair CVD-safe) */
    --fin-slot-1: #1f9d63;
    --fin-slot-2: #8a5cc4;
    --fin-slot-3: #d1653a;
    --fin-slot-4: #2f7fb8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

h1, h2, h3, .site-header__brand {
    font-family: var(--font-heading);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

a { color: var(--color-primary-dark); }

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 40;
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
}
.site-header__brand {
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--color-text);
}
.site-header__nav a {
    text-decoration: none;
    margin-left: 1rem;
    color: var(--color-text-muted);
}

main.container { padding-top: 2rem; padding-bottom: 3rem; }

h1 { margin-bottom: 0.25rem; }
.lede { color: var(--color-text-muted); max-width: 70ch; margin-top: 0; }

.sidebar-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    margin-top: 1.5rem;
}
.sidebar-layout__sidebar {
    flex: 0 0 280px;
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    max-height: calc(100vh - var(--header-height) - 3rem);
    overflow-y: auto;
}
.sidebar-layout__main {
    flex: 1;
    min-width: 0;
}
.sidebar-layout__main .results-count { margin-top: 0; }

@media (max-width: 900px) {
    .sidebar-layout { flex-direction: column; }
    .sidebar-layout__sidebar { position: static; width: 100%; max-height: none; }
}

.filters {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.filters__heading {
    margin: 0 0 1rem;
    font-size: 1.05rem;
}
.filters__row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}
.filters__row select,
.filters__row input,
.filters__row button {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.filters__search { flex: none; }
.filters__row button {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    cursor: pointer;
    font-weight: 600;
}
.filters__row button:hover { background: var(--color-primary-dark); }
.filters__clear {
    align-self: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
}

.results-count { color: var(--color-text-muted); font-size: 0.9rem; }

.cause-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 0.5rem 0 1rem;
    padding: 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.cause-legend li { display: flex; align-items: center; gap: 0.4rem; }
.cause-legend__dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cause-legend__dot--environment { background: #1f6b3f; }
.cause-legend__dot--social { background: #a4472b; }
.cause-legend__dot--governance { background: #3b5166; }

.table-scroll { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }

.org-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.org-table th, .org-table td {
    text-align: left;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.org-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); }
.org-table tr:last-child td { border-bottom: none; }
.org-table tr:hover { background: #f6f2e7; }

.org-table__name a { text-decoration: none; font-weight: 600; color: var(--color-text); display: flex; align-items: center; gap: 0.5rem; }
.org-table__logo { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; }
.org-table__tagline { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.15rem; }

.sdg-badges { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.sdg-badge-wrapper { position: relative; }
.sdg-badge {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
}
.sdg-badge:focus { outline: 2px solid var(--color-text); outline-offset: 2px; }

.sdg-popover {
    position: absolute;
    z-index: 20;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    background: var(--color-text);
    color: #fff;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease;
}
.sdg-badge-wrapper:hover .sdg-popover,
.sdg-badge-wrapper:focus-within .sdg-popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Flip/shift variants applied by sdg-popover.js when the default position would clip */
.sdg-popover--below { bottom: auto; top: calc(100% + 8px); }
.sdg-popover--align-left { left: 0; transform: none; }
.sdg-popover--align-right { left: auto; right: 0; transform: none; }
.sdg-popover__title { margin: 0 0 0.5rem; font-size: 0.85rem; font-weight: 600; }
.sdg-popover__actions { display: flex; flex-direction: column; gap: 0.4rem; }
.sdg-popover__actions a { color: #cfe8dd; font-size: 0.8rem; text-decoration: underline; }
.sdg-popover__actions a:hover { color: #fff; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.25rem;
    white-space: nowrap;
}
.badge--project { background: #e5efe8; color: var(--color-primary-dark); }
.badge--open { background: #f6ecd8; color: var(--color-accent-open); }
.badge--test { background: #fff3cd; color: #7a5c00; }
.badge--cause { margin: 0 0.25rem 0.25rem 0; white-space: normal; max-width: 100%; }
.badge--cause-environment { background: #e3f0e6; color: #1f6b3f; }
.badge--cause-social { background: #f7e6da; color: #a4472b; }
.badge--cause-governance { background: #e8ecf1; color: #3b5166; }

.text-muted { color: var(--color-text-muted); font-size: 0.85rem; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.pagination a { text-decoration: none; }
.pagination__status { color: var(--color-text-muted); font-size: 0.9rem; }

.empty-state { padding: 2rem; text-align: center; color: var(--color-text-muted); background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius); }

.site-footer { border-top: 1px solid var(--color-border); padding: 1.5rem 0; color: var(--color-text-muted); font-size: 0.85rem; }

/* Feedback widget */

#feedback-widget { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 50; max-width: calc(100vw - 2rem); }

#feedback-widget__toggle {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.7rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-width: 280px;
}
#feedback-widget__toggle:hover { background: var(--color-primary-dark); }

.feedback-panel {
    margin-top: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.1rem;
    width: 300px;
    max-width: calc(100vw - 2rem);
    box-shadow: 0 8px 28px rgba(0,0,0,0.22);
}
.feedback-panel label { display: block; margin-bottom: 0.7rem; font-size: 0.85rem; }
.feedback-panel select,
.feedback-panel textarea,
.feedback-panel input[type="email"] {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}
.feedback-panel .btn { width: 100%; text-align: center; }
.feedback-panel__success { color: var(--color-primary-dark); font-weight: 600; font-size: 0.85rem; }
.feedback-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* About page */

.about-toc {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.about-toc a { text-decoration: none; font-size: 0.9rem; }

.placeholder-note { color: var(--color-text-muted); font-style: italic; background: #fff8e6; border: 1px dashed #e0c068; border-radius: 6px; padding: 0.75rem 1rem; }

.glossary dt { font-weight: 700; margin-top: 1rem; }
.glossary dd { margin: 0.25rem 0 0; color: var(--color-text-muted); }

/* Organisation profile page */

.back-link { display: inline-block; margin-bottom: 1rem; font-size: 0.9rem; text-decoration: none; color: var(--color-text-muted); }

.org-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    flex-wrap: wrap;
}
.org-header__logo { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; }
.org-header__body { flex: 1; min-width: 0; }
.org-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}
.org-header__top h1 { margin: 0; min-width: 0; }
.org-header__actions { flex-shrink: 0; }

.org-header__grid {
    display: grid;
    grid-template-columns: minmax(200px, 300px) 1fr;
    gap: 0.5rem 2rem;
}
.org-header__facts { display: flex; flex-direction: column; gap: 0.65rem; min-width: 0; }
.org-header__meta { margin: 0; font-size: 0.9rem; color: var(--color-text-muted); }
.org-header__mission { margin: 0; max-width: 65ch; }
.org-header__causes { margin: 0; }

@media (max-width: 760px) {
    .org-header { flex-direction: column; }
    .org-header__grid { grid-template-columns: 1fr; }
    .org-header__top { flex-direction: column; align-items: stretch; }
    .org-header__actions { text-align: center; }
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--secondary { background: transparent; color: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn--small { padding: 0.3rem 0.6rem; font-size: 0.8rem; white-space: nowrap; }

.org-section { margin: 2rem 0; }
.org-section h2 { border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; }

.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.project-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.project-card h3 { margin-top: 0; }
.project-card__funds { font-size: 0.9rem; }
.project-card--open { max-width: 480px; }

.fin-years { display: flex; flex-direction: column; gap: 1.5rem; }
.fin-year {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.fin-year__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.fin-year__year { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; }
.fin-year__total { color: var(--color-text-muted); font-size: 0.9rem; }
.fin-year__header .btn--small { margin-left: auto; }

.fin-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--color-bg);
    margin-bottom: 0.9rem;
}
.fin-bar__segment { height: 100%; }
.fin-bar__segment:not(:last-child) { border-right: 2px solid var(--color-surface); }
.fin-bar__segment--programs { background: var(--fin-slot-1); }

.fin-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.fin-legend__dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.4rem; }
.fin-legend__dot--programs { background: var(--fin-slot-1); }

.report-list { list-style: none; padding: 0; }
.report-list li { padding: 0.4rem 0; }
.report-list-more { margin-top: 0.5rem; font-size: 0.85rem; }
.report-list-more summary { cursor: pointer; }

.financial-source-note { margin-top: 0.75rem; }

.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.media-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; }
.media-card h3 { margin-top: 0; }
.media-card__video { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 6px; }
.media-card__video iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
