/*
Theme Name: EHRG
Theme URI: https://environmentalhealthresearch.com
Author: Environmental Health Research Group
Description: A lightweight custom theme for the Environmental Health Research Group. Renders every page through templates so the site no longer depends on a page builder. Designed to pair with the EHRG News Clippings plugin, which provides the filterable press-coverage grid.
Version: 1.6.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: ehrg
*/

:root {
	--ink: #1f2937;
	--muted: #6b7280;
	--border: #e2e5e9;
	--accent: #16603a;        /* Muted environmental green. */
	--accent-ink: #ffffff;
	--donate: #c62828;         /* Donate red. */
	--donate-hover: #a91e1e;
	--bg: #f7f8f9;
	--maxw: 1140px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

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

img { max-width: 100%; height: auto; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.skip-link {
	position: absolute;
	left: -9999px;
}
.skip-link:focus {
	left: 8px;
	top: 8px;
	background: #fff;
	padding: 8px 12px;
	z-index: 1000;
	border-radius: 6px;
}

/*
 * Visible keyboard focus indicator (WCAG 2.4.7).
 * Applies to every interactive element, including the clippings plugin's
 * buttons, filters, and links, so keyboard users always see where they are.
 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Header and navigation */
.site-header {
	background: #fff;
	border-bottom: 1px solid var(--border);
}
.site-header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	padding: 18px 20px;
	max-width: var(--maxw);
	margin: 0 auto;
}
.brand {
	font-size: 20px;
	font-weight: 700;
	color: var(--accent);
	text-decoration: none;
	line-height: 1.2;
}
.brand span { display: block; }

.main-nav {
	display: flex;
	align-items: center;
	gap: 18px;
	flex-wrap: wrap;
	font-size: 14px;
}
.main-nav ul {
	display: flex;
	align-items: center;
	gap: 18px;
	flex-wrap: wrap;
	list-style: none;
	margin: 0;
	padding: 0;
}
.main-nav a { color: var(--ink); text-decoration: none; }
.main-nav a:hover,
.main-nav .current-menu-item > a { color: var(--accent); }

.donate-btn {
	display: inline-flex;
	align-items: center;
	min-height: 44px;          /* accessible tap target */
	background: var(--donate);
	color: #fff !important;
	padding: 8px 18px;
	border-radius: 8px;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
}
.donate-btn:hover { background: var(--donate-hover); }

/*
 * Universal hamburger navigation.
 * The campaign section titles are long and are not shortened, so the primary
 * menu is collapsed behind a single toggle on every screen size and opens as a
 * dropdown panel where each title has room to wrap onto multiple lines. The
 * Donate button stays visible in the header at all times.
 */
.site-header-inner { position: relative; }

.nav-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-left: auto;          /* push the toggle and Donate to the right */
	width: 46px;
	height: 44px;               /* accessible tap target */
	padding: 0;
	font-size: 0;               /* hides the accessible "Menu" text visually */
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
}
.nav-toggle::before {
	content: "\2630";           /* hamburger icon */
	font-size: 22px;
	line-height: 1;
	color: var(--ink);
}
.nav-toggle[aria-expanded="true"]::before {
	content: "\2715";           /* close (x) icon when open */
	font-size: 19px;
}

.main-nav { gap: 14px; margin-left: 12px; }
.main-nav > ul { display: none; }   /* hide the long menu items by default */

/* Dropdown panel shown when the toggle is activated */
.main-nav.is-open > ul {
	display: flex;
	flex-direction: column;
	gap: 2px;
	position: absolute;
	top: calc(100% + 10px);
	right: 20px;
	width: min(380px, calc(100vw - 40px));
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 12px;
	box-shadow: 0 14px 36px rgba(0, 0, 0, 0.15);
	padding: 8px;
	z-index: 200;
}
.main-nav.is-open > ul li { width: 100%; }
.main-nav.is-open > ul a {
	display: block;
	padding: 11px 14px;
	border-radius: 8px;
	white-space: normal;        /* allow long titles to wrap */
	line-height: 1.35;
	font-size: 15px;
}
.main-nav.is-open > ul a:hover,
.main-nav.is-open > ul .current-menu-item > a {
	background: #eef2f0;
	color: var(--accent);
}

/* Page shell */
.site-main { padding: 34px 0 56px; }

/* Breadcrumbs (single posts) */
.breadcrumbs { font-size: 13px; color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs .breadcrumbs-sep { margin: 0 4px; color: #cbd5e1; }
.breadcrumbs [aria-current="page"] { color: var(--ink); }

.page-header { margin-bottom: 22px; }
.page-title { font-size: 30px; margin: 0 0 8px; line-height: 1.2; }
.page-intro { color: var(--muted); max-width: 74ch; }

.entry-content { max-width: 74ch; }
.entry-content h2 { font-size: 22px; margin: 1.6em 0 0.5em; }
.entry-content h3 { font-size: 18px; margin: 1.4em 0 0.4em; }
.entry-content p { margin: 0 0 1em; }
.entry-content ul, .entry-content ol { margin: 0 0 1em; padding-left: 1.4em; }
.entry-content img { border-radius: 8px; }

/* Full width content (for the clippings grid on campaign pages) */
.entry-content .ehrg-clippings { max-width: none; }

/* Responsive video embeds (converted from raw YouTube URLs in content) */
.ehrg-video {
	position: relative;
	width: 100%;
	max-width: 720px;
	margin: 1.5em 0;
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 8px;
	overflow: hidden;
}
.ehrg-video iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* 404 page */
.error-404 { max-width: 640px; }
.error-404-search { margin: 16px 0 8px; }
.error-404-search input[type="search"] {
	min-height: 44px;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-size: 15px;
}
.error-404-links { list-style: none; padding: 0; margin: 0; }
.error-404-links li { margin: 8px 0; }
.error-404-links a { font-weight: 600; }

/* Homepage */
.home-hero {
	text-align: center;
	padding: 20px 0 8px;
}
.home-hero h1 { font-size: 32px; margin: 0 0 10px; }
.home-hero p { color: var(--muted); max-width: 60ch; margin: 0 auto; }

.campaign-cards {
	display: grid;
	gap: 22px;
	grid-template-columns: repeat(3, 1fr);
	margin: 34px 0 10px;
}
@media (max-width: 860px) { .campaign-cards { grid-template-columns: 1fr; max-width: 520px; margin-left: auto; margin-right: auto; } }

.campaign-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	text-decoration: none;
	color: inherit;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.campaign-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.08); transform: translateY(-3px); }
.campaign-card-media { aspect-ratio: 16 / 10; background: #eef2f0; overflow: hidden; }
.campaign-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.campaign-card-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.campaign-card-title { font-size: 18px; font-weight: 700; color: var(--accent); margin: 0; line-height: 1.3; }
.campaign-card-desc { color: var(--muted); font-size: 14px; margin: 0; }
.campaign-card-cta { margin-top: auto; padding-top: 6px; font-weight: 600; color: var(--accent); font-size: 14px; }

/* Single clipping */
.clipping-single { max-width: 820px; margin: 0 auto; }
.clipping-single .clipping-media { margin: 0 0 20px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.clipping-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.clipping-badge { background: #eef2f0; color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.clipping-date { color: var(--muted); font-size: 13px; }
.clipping-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.btn {
	display: inline-block; padding: 9px 16px; border-radius: 8px;
	background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.btn:hover { opacity: 0.92; color: #fff; }
.btn--secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn--secondary:hover { background: #f3f6f4; color: var(--accent); }
.back-link { display: inline-block; margin-top: 10px; font-size: 14px; }

/* Footer */
.site-footer {
	border-top: 1px solid var(--border);
	background: #fff;
	padding: 26px 0;
	margin-top: 40px;
}
.site-footer-inner {
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	color: var(--muted);
	font-size: 13px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/*
 * Beaver Themer page-heading override.
 * The site still has a Beaver Themer "Page Heading" layout that renders the page
 * title as a full-width blue gradient banner. Until that Themer layout is removed,
 * these rules restyle it to match the theme: no banner, dark title, left aligned
 * in the content column. Safe to delete once Beaver Themer is fully removed.
 */
.fl-row-bg-gradient:has(.fl-heading) .fl-row-content-wrap {
	background-image: none !important;
	background-color: transparent !important;
	padding-top: 34px !important;
	padding-bottom: 6px !important;
}
.fl-heading,
.fl-heading .fl-heading-text {
	color: var(--ink) !important;
	font-size: 32px !important;
	line-height: 1.2 !important;
	font-weight: 700 !important;
	text-align: left !important;
}
