/*
Theme Name: A. Paul Singh
Description: Custom block theme for A. Paul Singh, RSW.
Author: A. Paul Singh, RSW
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 7.4
Version: 0.38.54
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: a-paul-singh
Tags: full-site-editing, block-patterns, custom-logo, custom-menu, translation-ready
*/

/*
 * Header height. Defaults match the header pattern (85px top padding + 45px logo
 * row); assets/js/header-height.js keeps it exact when the menu wraps. The header
 * overlays the top of the page, so content reserves this much space under it.
 * Anchor jumps only need to clear the admin bar, which stays fixed.
 */
:root {
	--header-height: 8.125rem;
	scroll-padding-top: var(--wp-admin--admin-bar--height, 0px);
}

/* Anchored headings land with breathing room above them (Lenis honours scroll-margin-top too). */
:where(.wp-block-heading[id]) {
	scroll-margin-top: var(--wp--preset--spacing--50, 3rem);
}

/*
 * Root side gutters: theme.json keeps 3.333vw (48px @ 1440). On small phones, raise
 * by +1vw → 4.333vw (≤599px; independent of the 1200px header nav overlay cutover).
 * Override the CSS vars WordPress emits from theme.json so .has-global-padding,
 * image-bleed, and header Crisis/close offsets that read the vars all update.
 */
@media (max-width: 599px) {
	body {
		--wp--style--root--padding-left: 4.333vw;
		--wp--style--root--padding-right: 4.333vw;
	}
}

/*
 * Motion tokens (theme.json settings.custom.motion, output as --wp--custom--motion--*).
 * The audience is often distressed, so every animation is calm and uses these:
 * - duration--quick (200ms): small feedback such as colour changes;
 * - duration--reveal (450ms): content opening or closing (FAQ answers);
 * - duration--scroll (1100ms): smooth scrolling (Lenis, assets/js/lenis-init.js);
 * - easing--in: ease-in for hover press-in; easing--out: ease-out for release / arrive;
 *   easing--in-out for balanced enter/leave.
 * Scripts read them through assets/js/motion.js. With reduced motion every duration is
 * zero, so all motion is instant.
 */
@media (prefers-reduced-motion: reduce) {
	:root {
		--wp--custom--motion--duration--quick: 0ms;
		--wp--custom--motion--duration--reveal: 0ms;
		--wp--custom--motion--duration--scroll: 0ms;
	}
}

/*
 * Hover and focus states for buttons and links (colours: theme.json elements.button and
 * assets/css/blocks/button.css; the parts theme.json cannot express are here).
 * - Buttons fade between their colours over duration--quick.
 * - Text links keep their colour; the underline thickens from 1px to 2px over duration--quick.
 *   skip-ink is off so the line runs straight through descenders at both thicknesses
 *   (with auto, the gaps around p, g and y change size on hover).
 * - Navigation links (no underline at rest) fade to Page colour with a thin underline.
 * Durations are the motion tokens, so reduced motion makes every change instant.
 */
:where(.wp-element-button, .wp-block-button__link) {
	transition:
		background-color var(--wp--custom--motion--duration--quick) var(--wp--custom--motion--easing--out),
		color var(--wp--custom--motion--duration--quick) var(--wp--custom--motion--easing--out);
}

/* A number at rest (theme.json's underline shorthand resets it to auto), so the thickness can animate. */
a:not(.wp-element-button, .wp-block-button__link, .wp-block-navigation-item__content) {
	text-decoration-thickness: 1px;
	text-decoration-skip-ink: none;
	transition: text-decoration-thickness var(--wp--custom--motion--duration--quick) var(--wp--custom--motion--easing--out);
}

a:not(.wp-element-button, .wp-block-button__link, .wp-block-navigation-item__content):is(:hover, :focus-visible) {
	text-decoration-thickness: 2px;
}

.wp-block-navigation a.wp-block-navigation-item__content {
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.35em;
	transition:
		color var(--wp--custom--motion--duration--quick) var(--wp--custom--motion--easing--out),
		text-decoration-color var(--wp--custom--motion--duration--quick) var(--wp--custom--motion--easing--out);
}

.wp-block-navigation a.wp-block-navigation-item__content:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--page);
	text-decoration-color: currentColor;
}

/*
 * Header laid over the top of the page (scrolls away with it). Positioned against
 * .wp-site-blocks, which already sits below the admin bar through the html margin,
 * so no admin bar offset is needed.
 */
.wp-site-blocks {
	position: relative;
}

.wp-site-blocks > header.wp-block-template-part {
	position: absolute;
	top: 0;
	inset-inline: 0;
	z-index: 100;
}

/*
 * Header chrome stays fully clear on every breakpoint (closed mobile included) so
 * the first-section hero shows through. No fill, gradient, texture, or noise.
 * The open mobile nav overlay keeps its own Mid Green panel in
 * assets/css/blocks/navigation.css — that is the menu panel, not this bar.
 */
.wp-site-blocks > header.wp-block-template-part,
.wp-site-blocks > header.wp-block-template-part > .wp-block-group.has-section-style-dark-gray {
	background: none;
	background-color: transparent;
	background-image: none;
	--section-bg-color: transparent;
	--section-bg-image: none;
	--section-texture-opacity: 0;
	--section-noise-opacity: 0;
}

.wp-site-blocks > header.wp-block-template-part > .wp-block-group.has-section-style-dark-gray::before,
.wp-site-blocks > header.wp-block-template-part > .wp-block-group.has-section-style-dark-gray::after {
	content: none;
	opacity: 0;
	background-image: none;
}

/* Content starts below the header, unless it opens with a Section (section-styles.css adds the offset there). */
.wp-site-blocks > header.wp-block-template-part + main {
	margin-block-start: 0;
	padding-top: var(--header-height);
}

.wp-site-blocks > header.wp-block-template-part + main:has(> .wp-block-post-content:first-child > .has-section-padding:first-child, > .has-section-padding:first-child) {
	padding-top: 0;
}

/*
 * Core lets the admin bar scroll away below 600px. The fixed Crisis tab sits just
 * under the admin bar, so keep the bar fixed there to keep that offset correct.
 */
@media screen and (max-width: 600px) {
	html body.admin-bar #wpadminbar {
		position: fixed;
	}
}

/*
 * Links inside a block with an editor-set text colour follow that colour instead of
 * the global link colour. Editor-set link colours (.wp-elements-* a) still win.
 */
.has-text-color :where(a:not(.wp-element-button)) {
	color: inherit;
}

/*
 * Headings never hyphenate by default (zero specificity, so any block can still opt in).
 * overflow-wrap is the fallback so a long word cannot clip on narrow screens.
 */
:where(h1, h2, h3, h4, h5, h6) {
	overflow-wrap: break-word;
	hyphens: none;
}

/*
 * H1 Medium size preset (theme.json slug heading-1-medium): line-height 1, same token
 * as the H1 Smaller block style (custom.line-height.none). Class specificity beats the
 * h1 element rule (0.9) without touching other size presets. style.css is an editor style too.
 */
.has-heading-1-medium-font-size {
	line-height: var(--wp--custom--line-height--none);
}

/*
 * Nested elements inside titles (span, em, strong, a, mark, display:block wrappers,
 * etc.) must not carry their own line-height into the heading's line boxes.
 * theme.json sets body line-height 1.5 and heading/h1 line-heights on the heading
 * elements only; descendants that form their own boxes can expand/compound spacing
 * on multi-line titles. Force descendants to line-height: 1 so they cannot compound.
 * Covers h1–h6, .wp-block-heading, and .wp-block-post-title (including nested nodes
 * inside an H1 Medium heading). :where(*) keeps subject specificity at zero so block
 * styles can override. style.css is an editor style too (front + editor).
 */
:is( h1, h2, h3, h4, h5, h6, .wp-block-heading, .wp-block-post-title ) :where( * ) {
	line-height: 1;
}

/*
 * Decorative columns that only make sense side by side (Alcohol counselling steps).
 * 781px is where core Columns stack; display: none also takes them out of the
 * accessibility tree, which is fine as the content is decorative.
 */
@media (max-width: 781px) {
	.wp-block-column.desktop-only-steps {
		display: none;
	}
}

/*
 * Narrow phones: right-aligned hero content becomes left-aligned.
 * Only .section-hero, only ≤639px. !important where core layout / inline styles win.
 * Does not change opacity/transform — hero-title.js stagger is unaffected.
 */
@media (max-width: 639px) {
	/* Text: class + inline text-align:right. */
	.section-hero .has-text-align-right,
	.section-hero [style*="text-align:right"],
	.section-hero [style*="text-align: right"] {
		text-align: left !important;
	}

	/*
	 * Flex / buttons / groups / rows / stacks justified to the right
	 * (core is-content-justification-right → justify-content: flex-end).
	 */
	.section-hero .is-content-justification-right,
	.section-hero .items-justified-right,
	.section-hero .is-layout-flex[class*="is-content-justification-right"],
	.section-hero .wp-block-buttons.is-content-justification-right,
	.section-hero .wp-block-group.is-content-justification-right,
	.section-hero [style*="justify-content:flex-end"],
	.section-hero [style*="justify-content: flex-end"],
	.section-hero [style*="justify-content:right"],
	.section-hero [style*="justify-content: right"],
	.section-hero [style*="justify-content:end"],
	.section-hero [style*="justify-content: end"] {
		justify-content: flex-start !important;
	}

	/* Explicit cross-axis pack-to-end (inline); do not remap vertical justify. */
	.section-hero [style*="align-items:flex-end"],
	.section-hero [style*="align-items: flex-end"],
	.section-hero [style*="align-items:end"],
	.section-hero [style*="align-items: end"] {
		align-items: flex-start !important;
	}

	/* Classic alignright float / margin-left:auto push. */
	.section-hero .alignright {
		float: none !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
		margin-inline: 0 !important;
	}

	.section-hero .alignright[style*="margin-left"],
	.section-hero [style*="margin-left:auto"],
	.section-hero [style*="margin-left: auto"],
	.section-hero [style*="margin-inline-start:auto"],
	.section-hero [style*="margin-inline-start: auto"] {
		margin-left: 0 !important;
		margin-inline-start: 0 !important;
	}
}

/*
 * <mark> UA default is bright yellow. Theme content uses mark only for inline
 * colour (has-inline-color) / weight — never as a highlighter. Kill the yellow
 * so leftover mark wrappers do not paint a debug flash. An intentional inline
 * background-color on a mark still wins over this rule.
 */
mark {
	background-color: transparent;
}

/* Figma "body - Bold": bold text inside body copy. theme.json cannot target inline elements. */
:where(p, li) :is(strong, b) {
	font-weight: var(--wp--custom--font-weight--medium);
}

/*
 * Header menu current page (Figma "Menu"): Page colour. The Navigation block has
 * no "current item" colour setting; its default link colour is set on the block.
 */
header.wp-block-template-part .wp-block-navigation :is(.current-menu-item > .wp-block-navigation-item__content, .wp-block-navigation-item__content[aria-current="page"]) {
	color: var(--wp--preset--color--page);
}

/* Footer sits flush against the content above (template parts have no spacing controls). */
.wp-site-blocks > footer.wp-block-template-part {
	margin-block-start: 0;
}

/* Figma "list" item spacing (List items have no block gap setting). */
:where(.wp-block-list) > li + li {
	margin-block-start: var(--wp--custom--paragraph-spacing--list);
}
