/*
Theme Name:   ReCODE+ Resource Library
Theme URI:    https://recode.plus
Description:  Lightweight theme for recode.plus, styled after the Apollo Health portal style guide. Pairs with the ReCODE+ Resource Library plugin, which supplies the directory itself.
Version:      1.2.0
Requires at least: 6.3
Requires PHP: 7.4
Author:       Apollo Health
Text Domain:  recode-plus
License:      Proprietary
*/

/* ---------- Tokens (Figma › Style Guide) ---------- */

:root {
	--primary: #13374b;        /* Primary - Light */
	--on-primary: #ffffff;
	--action: #0b7ba5;         /* Secondary - Light / Action text */
	--on-action: #ffffff;
	--tertiary: #5e7655;       /* Tertiary - Light */
	--heading: #13374b;        /* Header - Light */
	--text: #373232;           /* Body Text - Light */
	--muted: #4a4a4a;          /* Neutral 2 - Light (the guide's #828282 is too faint for body-size text) */
	--surface: #ffffff;        /* Primary Background - Light */
	--surface-2: #f1f1f1;      /* Neutral 5 - Light */
	--portal-bg: #d0e1e7;      /* Portal Background PBG1 */
	--line: #e0e0e0;           /* Neutral 4 - Light */
	--field-line: #bdbdbd;     /* Neutral 3 - Light */
	--track: #e0e0e0;
	--focus: #13374b;
	--mark: #fff1c7;
	--card-shadow: 0 2px 8px rgba(19, 55, 75, 0.12);

	--logo-re: #708c66;
	--logo-code: #1f516d;

	--font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--wrap: 72rem;
	--gutter: clamp(1rem, 4vw, 2rem);

	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--primary: #3188b8;    /* Primary - Dark */
		--on-primary: #0d0d0d;
		--action: #1baeec;     /* Action - Dark */
		--on-action: #0d0d0d;
		--tertiary: #8bad7f;
		--heading: #ffffff;
		--text: #ffffff;       /* Body Text - Dark */
		--muted: #bdbdbd;
		--surface: #1b1b1b;    /* Neutral 5 - Dark */
		--surface-2: #2c2c2c;  /* Neutral 4 - Dark */
		--portal-bg: #0d0d0d;  /* Primary Background - Dark */
		--line: #2c2c2c;
		--field-line: #4a4a4a;
		--track: #2c2c2c;
		--focus: #1baeec;
		--mark: #5b4a1f;
		--card-shadow: 0 0 0 1px #2c2c2c;

		--logo-re: #ffffff;
		--logo-code: #ffffff;

		color-scheme: dark;
	}
}

/* ---------- Base ---------- */

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

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

body {
	margin: 0;
	background: var(--surface);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: 1.125rem; /* 18px: one step above the portal's 17px, for older readers */
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

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

a {
	color: var(--action);
	text-underline-offset: 0.2em;
}

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

h1,
h2,
h3 {
	color: var(--heading);
	line-height: 1.2;
	letter-spacing: 0.01em;
}

.screen-reader-text,
.skip-link:not(:focus) {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.skip-link:focus {
	position: fixed;
	top: 1rem;
	left: 1rem;
	z-index: 100;
	padding: 0.75rem 1.25rem;
	background: var(--surface);
	color: var(--heading);
	border-radius: 6px;
	box-shadow: var(--card-shadow);
}

/* ---------- Header ---------- */

.site-header {
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	padding-top: env(safe-area-inset-top, 0px);
}

.site-header-inner {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 0.9rem var(--gutter);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 2rem;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.85rem;
	text-decoration: none;
}

.logo {
	display: block;
	height: 1.6rem;
	width: auto;
}

.logo-re { fill: var(--logo-re); }
.logo-code { fill: var(--logo-code); }

.brand-sub {
	padding-left: 0.85rem;
	border-left: 1px solid var(--field-line);
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--heading);
	line-height: 1.6rem;
}

@media (max-width: 30rem) {
	.logo {
		height: 1.25rem;
	}

	.brand {
		gap: 0.6rem;
	}

	.brand-sub {
		padding-left: 0.6rem;
		font-size: 0.95rem;
		line-height: 1.25rem;
		white-space: nowrap;
	}
}

.custom-logo {
	max-height: 2.5rem;
	width: auto;
}

.site-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.5rem;
}

.site-nav a {
	font-size: 1rem;
	font-weight: 600;
	color: var(--heading);
	text-decoration: none;
}

.site-nav a:hover {
	color: var(--action);
}

.site-nav .nav-button {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
	padding: 0 1.1rem;
	color: var(--on-primary);
	background: var(--primary);
	border-radius: 6px;
}

.site-nav .nav-button:hover {
	color: var(--on-primary);
	filter: brightness(1.15);
}

/* ---------- Home: welcome ---------- */

.welcome {
	/* Faceted background in very pale blues (mostly white), after the apollohealthco.com hero. White stays the base. */
	--welcome-texture: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 720" preserveAspectRatio="none"%3E%3Cpolygon fill="%23F9FCFD" points="0,0 860,0 0,470"/%3E%3Cpolygon fill="%23F7FBFC" points="980,0 1440,0 1440,340"/%3E%3Cpolygon fill="%23F4F9FA" points="0,560 1440,300 1440,420 0,690"/%3E%3Cpolygon fill="%23F1F6F8" points="0,720 0,690 1440,420 1440,720"/%3E%3Cpolygon fill="%23ECF3F6" points="520,720 1440,470 1440,720"/%3E%3C/svg%3E');
	background-color: var(--surface);
	background-image: var(--welcome-texture);
	background-repeat: no-repeat;
	background-size: 100% 100%;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .welcome {
		--welcome-texture: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 720" preserveAspectRatio="none"%3E%3Cpolygon fill="%23161C1F" points="0,0 860,0 0,470"/%3E%3Cpolygon fill="%23141B1E" points="980,0 1440,0 1440,340"/%3E%3Cpolygon fill="%23152025" points="0,560 1440,300 1440,420 0,690"/%3E%3Cpolygon fill="%2317252B" points="0,720 0,690 1440,420 1440,720"/%3E%3Cpolygon fill="%231A2B32" points="520,720 1440,470 1440,720"/%3E%3C/svg%3E');
	}
}

:root[data-theme="dark"] .welcome {
	--welcome-texture: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 720" preserveAspectRatio="none"%3E%3Cpolygon fill="%23161C1F" points="0,0 860,0 0,470"/%3E%3Cpolygon fill="%23141B1E" points="980,0 1440,0 1440,340"/%3E%3Cpolygon fill="%23152025" points="0,560 1440,300 1440,420 0,690"/%3E%3Cpolygon fill="%2317252B" points="0,720 0,690 1440,420 1440,720"/%3E%3Cpolygon fill="%231A2B32" points="520,720 1440,470 1440,720"/%3E%3C/svg%3E');
}

/* Photo framed like the home page video: white border and a soft shadow. */
.welcome-photo img {
	border: 6px solid var(--surface);
	box-shadow: 0 10px 30px -12px rgba(19, 55, 75, 0.35);
	border-radius: 14px;
}

.welcome-grid {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 1.5rem var(--gutter) clamp(2rem, 4vw, 3rem);
	display: grid;
	gap: 1.5rem;
}

.welcome-photo img {
	display: block;
	width: 100%;
	height: clamp(10rem, 42vw, 15rem);
	object-fit: cover;
	object-position: 40% 65%;
	border-radius: 10px;
}

.welcome-inner {
	max-width: 40rem;
}

.welcome h1 {
	font-size: clamp(2rem, 4.5vw, 2.6rem);
	font-weight: 700;
	margin: 0 0 0.6rem;
	text-wrap: balance;
}

.welcome-lede {
	font-size: clamp(1.2rem, 2vw, 1.35rem);
	line-height: 1.45;
	color: var(--tertiary);
	font-weight: 500;
	margin: 0 0 1.25rem;
}

.welcome-body > :first-child {
	margin-top: 0;
}

.welcome-body p {
	margin: 0 0 1em;
}

.welcome-body strong {
	color: var(--heading);
}

@media (min-width: 60rem) {
	.welcome-grid {
		grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
		align-items: center;
		gap: 3rem;
		padding-top: 2.5rem;
	}

	.welcome-photo {
		order: 2;
	}

	.welcome-photo img {
		height: auto;
		aspect-ratio: 1 / 1;
		object-position: 42% 60%;
	}
}

/* ---------- Library band (portal background) ---------- */

.library-band {
	background: var(--portal-bg);
	padding-top: clamp(1.5rem, 4vw, 2.5rem);
}

/* ---------- Generic page ---------- */

.page-main {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 2rem var(--gutter) 4rem;
}

.page-main .entry {
	max-width: 42rem;
}

.page-main h1 {
	font-size: clamp(2rem, 5vw, 2.6rem);
	margin: 0 0 1.5rem;
}

/* ---------- Footer ---------- */

.site-footer {
	background: #13374b;
	color: #ffffff;
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

.site-footer a {
	color: #ffffff;
	text-decoration: underline;
}

.site-footer-inner {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 2.25rem var(--gutter) 2.5rem;
	display: grid;
	gap: 1.25rem;
	font-size: 1rem;
}

.site-footer p {
	margin: 0;
}

.footer-title {
	font-size: 1.15rem;
	font-weight: 700;
	margin-bottom: 0.35rem !important;
}

.footer-help p:not(.footer-title) {
	max-width: 42rem;
	color: #e1e1e1;
}

.footer-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
}

.footer-legal {
	padding-top: 1.25rem;
	border-top: 1px solid rgba(255, 255, 255, 0.2);
	font-size: 0.9rem;
	color: #bdbdbd;
}

.footer-legal a {
	color: #bdbdbd;
}

.admin-notice-inline {
	max-width: var(--wrap);
	margin: 0 auto 1rem;
	padding: 1rem var(--gutter);
	background: #fff1c7;
	color: #373232;
	border-radius: 10px;
}
