/*
 * Church Plugins 2026: global base CSS (loaded on every page, keep it small).
 * Layer order is declared in tokens.css: reset, tokens, base, components, sections, utilities.
 * Everything here is layered. Unlayered CSS (WP core blocks, plugins, theme.json global
 * styles) beats ANY layer for the same property; see CLAUDE.md "CSS conventions".
 */

/* ---------- reset ---------- */
@layer reset {
	*, *::before, *::after { box-sizing: border-box; }
	html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
	body { margin: 0; min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
	h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin-block: 0; }
	ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }
	img, video, canvas, svg { max-width: 100%; }
	img, video { height: auto; }
	picture, video { display: block; }
	input, button, textarea, select { font: inherit; color: inherit; }
	p, li, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
	h1, h2, h3, h4 { text-wrap: balance; }
	:target { scroll-margin-block: 96px; }

	@media (prefers-reduced-motion: reduce) {
		*, *::before, *::after {
			animation-duration: 0.01ms !important;
			animation-iteration-count: 1 !important;
			transition-duration: 0.01ms !important;
			scroll-behavior: auto !important;
		}
	}
}

/* ---------- base: bare elements ---------- */
@layer base {
	body {
		font-family: var(--cp-font-body);
		font-size: var(--cp-text-base);
		line-height: 1.5;
		color: var(--cp-charcoal);
		background: var(--cp-white);
	}

	h1, h2, h3, h4, h5, h6 {
		font-family: var(--cp-font-head);
		font-weight: 600;
		line-height: 1.25;
		color: inherit;
		letter-spacing: -0.01em;
	}
	h1 { font-size: var(--cp-text-xxl); font-weight: 700; line-height: 1.15; }
	h2 { font-size: var(--cp-text-xl); font-weight: 700; line-height: 1.2; }
	h3 { font-size: var(--cp-text-lg); }
	h4 { font-size: var(--cp-text-md); }
	h5, h6 { font-size: var(--cp-text-base); }

	small { font-size: var(--cp-text-sm); }
	strong, b { font-weight: 700; }

	a {
		color: var(--cp-teal-ink);
		text-decoration: underline;
		text-decoration-thickness: 1px;
		text-underline-offset: 0.18em;
	}
	a:hover { color: var(--cp-charcoal); text-decoration-thickness: 2px; }

	/* One visible 2px focus ring everywhere. On dark sections it flips to white (see .cp-on-dark). */
	:focus-visible {
		outline: var(--cp-focus);
		outline-offset: var(--cp-focus-offset);
		border-radius: 4px;
	}

	hr { border: 0; border-top: 1px solid var(--cp-line); margin-block: var(--cp-s4); }
	::selection { background: color-mix(in srgb, var(--cp-teal) 45%, transparent); color: var(--cp-charcoal); }

	table { border-collapse: collapse; width: 100%; }
	th, td { text-align: start; padding: var(--cp-s1) var(--cp-s2); border-bottom: 1px solid var(--cp-line); }

	/* FAQ / disclosure base: <details> needs no JS. Use .cp-faq on the wrapper or .cp-details on each. */
	:where(.cp-faq) details, details.cp-details {
		border-bottom: 1px solid var(--cp-line);
	}
	:where(.cp-faq) summary, .cp-details > summary {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--cp-s2);
		min-height: var(--cp-tap);
		padding-block: var(--cp-s2);
		cursor: pointer;
		list-style: none;
		font: 600 var(--cp-text-md)/1.4 var(--cp-font-head);
	}
	:where(.cp-faq) summary::-webkit-details-marker, .cp-details > summary::-webkit-details-marker { display: none; }
	:where(.cp-faq) summary::after, .cp-details > summary::after {
		content: "+";
		flex: none;
		display: grid;
		place-items: center;
		width: 32px;
		height: 32px;
		border-radius: 50%;
		background: var(--cp-grey);
		color: var(--cp-teal-ink);
		font: 600 22px/1 var(--cp-font-body);
	}
	:where(.cp-faq) details[open] > summary::after, .cp-details[open] > summary::after { content: "\2212"; }
	:where(.cp-faq) details > :not(summary), .cp-details > :not(summary) { padding-block-end: var(--cp-s3); color: var(--cp-grey-2); }

	/* WordPress accessibility helpers */
	.screen-reader-text, .cp-sr-only {
		border: 0; clip-path: inset(50%); height: 1px; width: 1px; margin: -1px;
		overflow: hidden; padding: 0; position: absolute !important; word-wrap: normal !important;
	}
	.skip-link.screen-reader-text:focus {
		clip-path: none; height: auto; width: auto; margin: 0; z-index: 100000;
		top: 8px; left: 8px; padding: 12px 16px;
		background: var(--cp-white); color: var(--cp-charcoal); font-weight: 600;
	}
}

/* ---------- components: buttons (global because every page has one) ---------- */
@layer components {
	.cp-btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: var(--cp-s1);
		min-height: var(--cp-btn-h);
		padding: 0 var(--cp-s3);
		border: 2px solid transparent;
		border-radius: var(--cp-radius-pill);
		background: var(--cp-teal);
		color: var(--cp-charcoal);
		font: 600 var(--cp-text-base)/1.2 var(--cp-font-head);
		text-align: center;
		text-decoration: none;
		cursor: pointer;
		transition: background-color var(--cp-ease), color var(--cp-ease), border-color var(--cp-ease);
	}
	.cp-btn:hover { background: var(--cp-charcoal); color: var(--cp-white); }
	.cp-btn--secondary { background: transparent; border-color: var(--cp-charcoal); color: var(--cp-charcoal); }
	.cp-btn--secondary:hover { background: var(--cp-charcoal); color: var(--cp-white); }
	.cp-btn--block { display: flex; width: 100%; }
	@media (max-width: 599px) {
		.cp-btn:not(.cp-btn--inline) { display: flex; width: 100%; }
	}

	/* Text link with arrow: the secondary action next to a primary button. */
	.cp-link {
		display: inline-flex;
		align-items: center;
		min-height: var(--cp-tap);
		font: 600 var(--cp-text-base)/1.4 var(--cp-font-head);
		color: var(--cp-teal-ink);
	}
	.cp-link::after { content: "\00a0\2192"; }

	/* Core button block: theme.json styles colours (unlayered); we add the tap height. */
	.wp-element-button, .wp-block-button__link {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: var(--cp-btn-h);
		text-decoration: none;
	}
}

/* ---------- utilities: keep tiny ---------- */
@layer utilities {
	.cp-container { width: 100%; max-width: calc(var(--cp-maxw) + 2 * var(--cp-gutter)); margin-inline: auto; padding-inline: var(--cp-gutter); }
	.cp-container--prose { max-width: calc(var(--cp-prose) + 2 * var(--cp-gutter)); }
	.cp-section { padding-block: var(--cp-s8); }
	@media (min-width: 782px) { .cp-section { padding-block: var(--cp-s12); } }
	.cp-section--grey { background: var(--cp-grey); }
	.cp-on-dark { background: var(--cp-charcoal); color: var(--cp-white); --cp-focus: 2px solid var(--cp-white); }
	.cp-on-dark a:not(.cp-btn) { color: var(--cp-teal); }
	.cp-stack > * + * { margin-block-start: var(--cp-stack-gap, var(--cp-s2)); }
	.cp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cp-s2) var(--cp-s3); }
	.cp-muted { color: var(--cp-grey-2); }
	.cp-center { text-align: center; }
	.cp-eyebrow { font: 600 var(--cp-text-sm)/1.4 var(--cp-font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--cp-teal-ink); }
}

/* ---------- unlayered on purpose: beats WP core layout CSS ---------- */
/* Core's constrained layout sets max-width: content-size on every direct child (unlayered),
   which overrides our reset for raw <img> tags in legacy content (680px wide on a 390 phone). */
.is-layout-constrained > img,
.is-layout-constrained > p > img { max-width: min(100%, var(--wp--style--global--content-size, 680px)); height: auto; }
