/* CSA Projects. Inherits the theme's fonts and text colour; one accent colour, overridable. */
.csap {
	--csap-accent: var(--wp--preset--color--primary, #0b6e69);
	--csap-accent-ink: #fff;
	--csap-line: rgba(127, 127, 127, 0.35);
	--csap-soft: rgba(127, 127, 127, 0.08);
	--csap-radius: 10px;
	--csap-error: #b3261e;
	--csap-ok: #1e6b35;
}
.csap *, .csap *::before, .csap *::after { box-sizing: border-box; }
.csap .screen-reader-text, .screen-reader-text.csap-sr {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}

/* Language switcher */
.csap-lang { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0 0 1rem; font-size: 0.9em; }
.csap-lang__item { text-decoration: underline; text-underline-offset: 0.2em; }
.csap-lang__item.is-current { font-weight: 700; text-decoration: none; }

/* Buttons and links */
.csap-button {
	display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
	min-height: 44px; padding: 0.55em 1.1em; border: 2px solid var(--csap-accent); border-radius: 999px;
	background: var(--csap-accent); color: var(--csap-accent-ink) !important; font: inherit; font-weight: 600;
	text-decoration: none !important; cursor: pointer; line-height: 1.2;
}
.csap-button:hover { filter: brightness(1.08); }
.csap-button--secondary { background: transparent; color: var(--csap-accent) !important; }
.csap-button:focus-visible, .csap a:focus-visible, .csap input:focus-visible, .csap select:focus-visible, .csap textarea:focus-visible, .csap summary:focus-visible {
	outline: 3px solid var(--csap-accent); outline-offset: 2px;
}

/* Directory: search and filters */
.csap-filters { margin: 0 0 1.25rem; }
.csap-search { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.csap-search input { flex: 1; min-width: 0; }
.csap input[type="search"], .csap input[type="text"], .csap input[type="email"], .csap input[type="date"], .csap input[type="number"], .csap select, .csap textarea {
	width: 100%; min-height: 44px; padding: 0.5em 0.7em; border: 1px solid var(--csap-line); border-radius: 8px;
	background: Canvas; color: CanvasText; font: inherit;
}
.csap textarea { min-height: 6em; resize: vertical; }
.csap-filterbox { border: 1px solid var(--csap-line); border-radius: var(--csap-radius); padding: 0.25rem 1rem; }
.csap-filterbox > summary { cursor: pointer; font-weight: 600; padding: 0.6rem 0; min-height: 44px; display: list-item; }
.csap-filtergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 0.9rem 1rem; padding: 0.5rem 0 0.25rem; }
.csap-filter label { display: block; font-size: 0.88em; font-weight: 600; margin-bottom: 0.25rem; }
.csap-filter .csap-option--small { font-weight: 400; font-size: 0.85em; margin-top: 0.35rem; }
.csap-filteractions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin: 0.75rem 0; }

.csap-resultbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 1rem; }
.csap-count { margin: 0; font-weight: 600; }

/* Cards */
.csap-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1.25rem; }
.csap-card { display: flex; flex-direction: column; border: 1px solid var(--csap-line); border-radius: var(--csap-radius); overflow: hidden; background: var(--csap-soft); margin: 0; position: relative; }
.csap-card__img { aspect-ratio: 16 / 9; overflow: hidden; background: var(--csap-soft); }
.csap-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; margin: 0; }
.csap-card__img--topic img { object-fit: cover; }
.csap-card__img--empty { display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--csap-accent) 14%, transparent); }
.csap-card__img--empty span { font-size: 2.6rem; font-weight: 700; color: var(--csap-accent); opacity: 0.7; }
.csap-card__body { padding: 0.9rem 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.csap-card__body p { margin: 0; }
.csap-card__title { margin: 0.1rem 0 0; font-size: 1.1rem; line-height: 1.3; }
.csap-card__title a { text-decoration: none; color: inherit; }
.csap-card__title a::after { content: ""; position: absolute; inset: 0; }
.csap-card__title a:hover { text-decoration: underline; }
.csap-card__org { font-size: 0.9em; font-weight: 600; opacity: 0.85; }
.csap-card__aim { font-size: 0.92em; }
.csap-card__where { font-size: 0.85em; opacity: 0.85; }

/* Badges and chips */
.csap-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.5rem; }
.csap-card .csap-badges { margin: 0; }
.csap-badge, .csap-chip {
	display: inline-block; padding: 0.15em 0.6em; border-radius: 999px; font-size: 0.78rem; line-height: 1.5; font-weight: 600;
	border: 1px solid var(--csap-line);
}
.csap-badge--active, .csap-badge--periodically_active { background: #dff3e4; color: #14532d; border-color: #b7e0c2; }
.csap-badge--not_started { background: #e5eefc; color: #1e3a8a; border-color: #c3d4f5; }
.csap-badge--on_hold { background: #fdf1d8; color: #7a4b00; border-color: #f0d9a6; }
.csap-badge--completed, .csap-badge--abandoned { background: #ececec; color: #3a3a3a; border-color: #d4d4d4; }
.csap-badge--imported { background: transparent; border-style: dashed; }
.csap-badge--africa { background: color-mix(in srgb, var(--csap-accent) 15%, transparent); }
.csap-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.csap-chip { font-weight: 500; background: transparent; }

/* Pagination */
.csap-pages ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; margin: 1.5rem 0 0; }
.csap-pages a, .csap-pages span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 0.6rem; border: 1px solid var(--csap-line); border-radius: 8px; text-decoration: none; }
.csap-pages [aria-current] { background: var(--csap-accent); color: var(--csap-accent-ink); border-color: var(--csap-accent); font-weight: 700; }
.csap-pages__gap { align-self: center; padding: 0 0.25rem; }
.csap-empty { padding: 1.5rem; border: 1px dashed var(--csap-line); border-radius: var(--csap-radius); }

/* Single project */
.csap-aim { font-size: 1.2em; line-height: 1.5; }
.csap-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 1.5rem; }
.csap-details { display: grid; gap: 0; margin: 0 0 1.5rem; border-top: 1px solid var(--csap-line); }
.csap-details > div { display: grid; grid-template-columns: minmax(8rem, 1fr) 2.5fr; gap: 0.5rem 1rem; padding: 0.65rem 0; border-bottom: 1px solid var(--csap-line); }
.csap-details dt { font-weight: 600; margin: 0; }
.csap-details dd { margin: 0; }
@media (max-width: 560px) { .csap-details > div { grid-template-columns: 1fr; } }
.csap-source { font-size: 0.88em; opacity: 0.85; border-top: 1px solid var(--csap-line); padding-top: 0.75rem; margin-top: 2rem; }
.csap-source p { margin: 0.3rem 0; }
.csap-figure img { width: 100%; height: auto; border-radius: var(--csap-radius); }
.csap-figure figcaption { font-size: 0.85em; opacity: 0.8; }

/* Form */
.csap-section { border: 1px solid var(--csap-line); border-radius: var(--csap-radius); padding: 0.75rem 1.1rem 1rem; margin: 0 0 1.25rem; }
.csap-section > legend { font-weight: 700; font-size: 1.1em; padding: 0 0.4rem; }
.csap-field { margin: 0.9rem 0; }
.csap-field > fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.csap-label { display: block; font-weight: 600; margin-bottom: 0.2rem; padding: 0; }
.csap-help { margin: 0 0 0.4rem; font-size: 0.88em; opacity: 0.85; }
.csap-req { color: var(--csap-error); }
.csap-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 0.15rem 1rem; }
.csap-options--long { max-height: 17rem; overflow: auto; border: 1px solid var(--csap-line); border-radius: 8px; padding: 0.4rem 0.7rem; }
.csap-optfilter { margin-bottom: 0.4rem; }
.csap-option { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.3rem 0; min-height: 36px; font-weight: 400; cursor: pointer; }
.csap-option input { width: 1.15rem; height: 1.15rem; margin: 0.15rem 0 0; flex: none; }
.csap-option[hidden] { display: none; }
.csap-field.has-error input, .csap-field.has-error select, .csap-field.has-error textarea, .csap-field.has-error .csap-options { border-color: var(--csap-error); border-width: 2px; }
.csap-error { color: var(--csap-error); font-weight: 600; font-size: 0.9em; margin: 0.3rem 0 0; }
.csap-notice { border-radius: var(--csap-radius); padding: 0.9rem 1.1rem; margin: 0 0 1.25rem; border: 2px solid; }
.csap-notice--error { border-color: var(--csap-error); }
.csap-notice--error a { color: inherit; }
.csap-notice--ok { border-color: var(--csap-ok); }
.csap-notice h2 { margin-top: 0; }
.csap-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.csap-agree { margin: 1.25rem 0; }

/* Admin meta box */
.csap-admin .csap-section { background: #fff; }
.csap-admin .csap-options--long { background: #fff; }
