/*
Theme Name: Jachura Financial
Theme URI: https://jachurafinancial.com/
Author: Bedford+Co
Author URI: https://bedfordandco.net/
Description: Block theme for Jachura Financial. Navy, brass and porcelain palette sampled from the JF logo; Newsreader display with Hanken Grotesk body.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
Version: 1.3.2
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: jachura-financial
*/

/* ==========================================================================
   Tokens that theme.json cannot express. Colours always come from presets.
   ========================================================================== */
:root {
	--jf-utility-h: 2.5rem;
	--jf-rule-light: color-mix(in srgb, var(--wp--preset--color--contrast) 14%, transparent);
	--jf-rule-dark: color-mix(in srgb, var(--wp--preset--color--mist) 28%, transparent);
	--jf-accent-hover: color-mix(in srgb, var(--wp--preset--color--accent) 82%, var(--wp--preset--color--base));
	--jf-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

h1, h2, h3, .wp-block-heading {
	text-wrap: balance;
	font-optical-sizing: auto;
}

::selection {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--primary);
}

:where(a, button, summary, input, select, textarea):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

a {
	text-underline-offset: 0.2em;
	text-decoration-thickness: 1px;
	transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

/* Dark sections: headings and links follow the light text colour */
:is(.has-primary-background-color, .has-secondary-background-color) :is(h1, h2, h3, h4, h5, h6) {
	color: var(--wp--preset--color--base);
}

/* ==========================================================================
   Buttons (fill = accent, outline = currentColor)
   ========================================================================== */
.wp-block-button__link,
.wp-element-button {
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s var(--jf-ease);
}

.wp-block-button:not(.is-style-outline) .wp-block-button__link:hover {
	background-color: var(--jf-accent-hover);
	border-color: var(--jf-accent-hover);
}

/*
 * Outline hover fills the button. Text colour needs !important because the
 * editor's colour classes (.has-primary-color etc.) use !important.
 */
.wp-block-button.is-style-outline .wp-block-button__link:is(:hover, :focus-visible) {
	background-color: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base) !important;
}

:is(.has-primary-background-color, .has-secondary-background-color) .wp-block-button.is-style-outline .wp-block-button__link:is(:hover, :focus-visible) {
	background-color: var(--wp--preset--color--base);
	border-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--primary) !important;
}

/* ==========================================================================
   Shared section pieces
   ========================================================================== */
.jf-eyebrow {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--wp--preset--color--slate);
}

:where(.has-primary-background-color, .has-secondary-background-color) .jf-eyebrow {
	color: var(--wp--preset--color--accent);
}

.jf-lede {
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.55;
	max-width: 38em;
}

.jf-measure {
	max-width: 40em;
}

/* ==========================================================================
   Header (template part). The utility bar scrolls away; the main bar sticks.
   ========================================================================== */
.jf-site-header {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) - var(--jf-utility-h));
	z-index: 100;
}

.jf-utility {
	min-height: var(--jf-utility-h);
	white-space: nowrap;
	overflow: hidden;
}

.jf-utility p {
	margin: 0;
}

.jf-utility a {
	text-decoration: none;
	color: var(--wp--preset--color--surface);
}

.jf-utility a:hover {
	color: var(--wp--preset--color--accent);
}

.jf-utility__locations {
	display: none;
}

.jf-header {
	border-bottom: 1px solid var(--jf-rule-light);
}

.jf-header .wp-block-site-title {
	font-family: var(--wp--preset--font-family--display);
	font-weight: 450;
	letter-spacing: -0.01em;
	line-height: 1;
}

.jf-header .wp-block-site-title a {
	text-decoration: none;
}

.jf-header .wp-block-navigation-item__content {
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-size: 0 1px;
	background-position: 0 100%;
	background-repeat: no-repeat;
	padding-bottom: 2px;
	transition: background-size 0.3s var(--jf-ease);
}

.jf-header .wp-block-navigation-item__content:hover,
.jf-header .current-menu-item > .wp-block-navigation-item__content {
	background-size: 100% 1px;
}

/* Header button: hidden on phones (the hero carries the CTA). Out-ranks core's flex layout rule. */
.jf-header .wp-block-buttons.jf-header__cta {
	display: none;
}

.jf-header__cta .wp-block-button__link {
	white-space: nowrap;
}

/* The full nav needs about 1110px, so keep the overlay menu up to 1279px
   (core switches at 600px). Selectors out-rank core's by one class. */
@media (min-width: 600px) and (max-width: 1279px) {
	.jf-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.jf-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

/* Mobile overlay menu: one left-aligned list with hairline rules, logo at the bottom. */
.jf-header .wp-block-navigation__responsive-container.is-menu-open {
	padding: var(--wp--preset--spacing--32) clamp(1.5rem, 6vw, 3rem);
}

.jf-header .is-menu-open .wp-block-navigation__responsive-close,
.jf-header .is-menu-open .wp-block-navigation__responsive-dialog {
	height: 100%;
}

.jf-header .is-menu-open .wp-block-navigation__responsive-dialog {
	display: flex;
	flex-direction: column;
}

.jf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	display: flex;
	flex: 1 0 auto;
	flex-direction: column;
	align-items: stretch;
	padding-top: 3.5rem;
	padding-bottom: var(--wp--preset--spacing--24);
}

.jf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	align-items: stretch;
	width: 100%;
	gap: 0;
}

.jf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	align-items: flex-start;
	width: 100%;
	border-bottom: 1px solid var(--jf-rule-dark);
}

.jf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	width: 100%;
	padding: 1rem 0;
	background-image: none;
	text-align: left;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.625rem;
	font-weight: 350;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

.jf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content::after {
	content: "";
	flex: none;
	align-self: center;
	width: 5rem;
	height: 5rem;
	margin-top: auto;
	border-radius: 50%;
	background: url("assets/images/jf-logo.png") center / cover;
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--wp--preset--color--mist) 45%, transparent);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.jf-hero__cols {
	gap: var(--wp--preset--spacing--48);
}

.jf-hero h1 {
	text-wrap: balance;
}

.jf-hero__media {
	margin: 0;
	overflow: hidden;
	aspect-ratio: 4 / 5;
	max-width: 100%;
	background: var(--wp--preset--color--stone);
}

/*
 * Desktop: the whole hero (headline, intro, buttons, photo) fits the first
 * screen. The headline is as big as the column allows on three lines (8.6vw,
 * capped at 7rem once the layout reaches its 1200px wide size), and shrinks
 * on short screens.
 */
@media (min-width: 782px) {
	.jf-hero h1 {
		font-size: max(3.5rem, min(7rem, 8.6vw, calc((100svh - 28.5rem) / 3)));
	}

	.jf-hero__media {
		max-height: calc(100svh - var(--jf-hero-chrome, 15rem));
	}
}

/* When columns stack (below 782px), keep portraits from filling the screen. */
@media (max-width: 781px) {
	.jf-hero__media,
	.jf-cap-stacked {
		max-width: 26rem;
	}
}

.jf-hero__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	will-change: transform;
}

/* Navy hero: the portrait as supplied, uncropped, centred beside the text. */
.jf-hero.jf-hero--navy {
	padding-bottom: var(--wp--preset--spacing--64) !important;
}

.jf-hero--navy .jf-hero__cols,
.jf-hero--navy .jf-hero__cols > .wp-block-column {
	align-items: center;
	align-self: center;
}

.jf-hero--navy .jf-hero__media {
	aspect-ratio: auto;
	max-height: none;
	margin-inline: auto;
	background: none;
}

.jf-hero--navy .jf-hero__media img {
	width: auto;
	max-width: 100%;
	height: auto;
	margin-inline: auto;
	transform: none !important; /* no parallax: it would crop the photo */
	will-change: auto;
}

@media (min-width: 782px) {
	.jf-hero--navy .jf-hero__media img {
		max-height: max(24rem, min(40rem, calc(100svh - var(--jf-hero-chrome, 15rem))));
	}
}

.jf-hero--navy .jf-hero__media figcaption {
	margin: var(--wp--preset--spacing--16) 0 0;
	text-align: center;
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
}

.jf-hero--navy .jf-lede {
	max-width: 32rem;
}

/* ==========================================================================
   Intro statement
   ========================================================================== */
.jf-intro__body {
	max-width: 36rem;
}

/* ==========================================================================
   Signature: the 4-step process (scroll-linked when JS runs)
   Without JS, or with reduced motion, every step is shown complete.
   ========================================================================== */
.jf-process__grid {
	display: grid;
	gap: var(--wp--preset--spacing--64);
}

.jf-process__steps {
	--jf-progress: 1;
	position: relative;
	padding-left: clamp(2.5rem, 6vw, 5rem);
}

.jf-process__steps::before,
.jf-process__steps::after {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 2px;
}

.jf-process__steps::before {
	background: var(--jf-rule-dark);
}

.jf-process__steps::after {
	background: var(--wp--preset--color--accent);
	transform-origin: top;
	transform: scaleY(var(--jf-progress));
}

.jf-process__step {
	position: relative;
	padding-block: var(--wp--preset--spacing--48);
}

.jf-process__step:first-child {
	padding-top: 0;
}

.jf-process__step:last-child {
	padding-bottom: 0;
}

/* Marker on the line, aligned with the numeral */
.jf-process__step::before {
	content: "";
	position: absolute;
	left: calc(-1 * clamp(2.5rem, 6vw, 5rem) - 7px);
	top: calc(var(--wp--preset--spacing--48) + 0.9em);
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	border: 2px solid var(--wp--preset--color--accent);
	transition: background-color 0.4s ease;
}

.jf-process__step:first-child::before {
	top: 0.9em;
}

.jf-process__num {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--numeral);
	font-weight: 300;
	line-height: 0.85;
	letter-spacing: -0.04em;
	font-variant-numeric: lining-nums;
	color: var(--wp--preset--color--accent);
	margin: 0;
}

.jf-process__title {
	margin-top: var(--wp--preset--spacing--16);
}

.jf-process__step.is-active::before,
.jf-process:not(.jf-process--live) .jf-process__step::before {
	background: var(--wp--preset--color--accent);
}

@media (prefers-reduced-motion: no-preference) {
	.jf-process--live .jf-process__step > * {
		transition: opacity 0.6s ease-out, transform 0.6s var(--jf-ease), color 0.6s ease-out;
	}

	.jf-process--live .jf-process__step:not(.is-active) > * {
		opacity: 0.28;
		transform: translateY(16px);
	}

	.jf-process--live .jf-process__step:not(.is-active) .jf-process__num {
		color: var(--wp--preset--color--mist);
	}
}

/* ==========================================================================
   Numbered index (services). Real <ol>, numbers from CSS counters.
   ========================================================================== */
.jf-index {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: jf-index;
	border-top: 1px solid var(--jf-rule-light);
}

.jf-index li {
	counter-increment: jf-index;
	display: grid;
	grid-template-columns: 3rem 1fr;
	align-items: baseline;
	padding-block: var(--wp--preset--spacing--16);
	border-bottom: 1px solid var(--jf-rule-light);
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.375rem, 1.15rem + 0.8vw, 1.875rem);
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--primary);
	break-inside: avoid;
}

.jf-index li::before {
	content: counter(jf-index, decimal-leading-zero);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.1em;
	color: var(--wp--preset--color--slate);
	font-variant-numeric: tabular-nums;
}

.jf-index--large li {
	font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.75rem);
	padding-block: var(--wp--preset--spacing--24);
	grid-template-columns: 4rem 1fr;
}

/* ==========================================================================
   Cards (GWP features and benefits)
   ========================================================================== */
.jf-cards {
	display: grid;
	gap: var(--wp--preset--spacing--24);
}

.jf-card {
	border-top: 2px solid var(--wp--preset--color--primary);
	transition: transform 0.3s var(--jf-ease), box-shadow 0.3s var(--jf-ease);
}

.jf-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 18px 40px -24px color-mix(in srgb, var(--wp--preset--color--primary) 45%, transparent);
}

/* ==========================================================================
   Video
   ========================================================================== */
.jf-video video {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	height: auto;
	background: var(--wp--preset--color--primary);
}

.jf-poster-link img {
	transition: transform 0.6s var(--jf-ease);
}

.jf-poster-link {
	overflow: hidden;
}

.jf-poster-link:hover img {
	transform: scale(1.03);
}

/* ==========================================================================
   Offices / contact
   ========================================================================== */
.jf-office p {
	margin-block: 0;
}

.jf-office h3 {
	margin-bottom: var(--wp--preset--spacing--16);
}

/* ==========================================================================
   Embeds (Elfsight). Reserve space so the widget does not shift the layout.
   ========================================================================== */
.jf-embed {
	min-height: 32rem;
}

/* A centred intro line keeps its narrow measure, so centre the box too. */
.jf-lede.has-text-align-center {
	margin-inline: auto !important;
}

/* ==========================================================================
   Footer and compliance block (full contrast, never de-emphasised)
   ========================================================================== */
.jf-footer a {
	color: inherit;
}

.jf-footer a:hover {
	color: var(--wp--preset--color--accent);
}

.jf-footer__nav a {
	text-decoration: none;
}

.jf-compliance {
	border-top: 1px solid var(--jf-rule-dark);
}

.jf-compliance p {
	margin-block: 0;
	color: var(--wp--preset--color--surface);
}

.jf-compliance__disclosures p + p {
	margin-top: var(--wp--preset--spacing--16);
}

.jf-footer__bottom {
	border-top: 1px solid var(--jf-rule-dark);
}

.jf-footer__bottom p {
	margin: 0;
}

/* ==========================================================================
   Scroll reveal (JS adds .is-pending only to content below the first screen)
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
	.jf-reveal {
		transition: opacity 0.7s ease-out, transform 0.7s var(--jf-ease);
	}

	.jf-reveal.is-pending {
		opacity: 0;
		transform: translateY(28px);
	}
}

/* ==========================================================================
   Breakpoints (mobile first)
   ========================================================================== */
@media (min-width: 600px) {
	.jf-header .wp-block-buttons.jf-header__cta {
		display: flex;
	}

	.jf-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 782px) {
	.jf-utility__locations {
		display: block;
	}

	.jf-index--large {
		columns: 2;
		column-gap: var(--wp--preset--spacing--64);
	}

	.jf-index--large li:first-child {
		border-top: 0;
	}
}

@media (min-width: 1024px) {
	.jf-process__grid {
		grid-template-columns: 5fr 7fr;
		gap: var(--wp--preset--spacing--96);
		align-items: start;
	}

	.jf-process__intro {
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + 9rem);
	}

	.jf-process__step {
		min-height: 42vh;
	}

	.jf-cards--3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Reduced motion: no transforms anywhere */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		scroll-behavior: auto;
	}

	.jf-hero__media img {
		transform: none;
		will-change: auto;
	}

	.jf-card:hover,
	.jf-poster-link:hover img {
		transform: none;
	}
}

/* Header, main and footer sit flush: sections carry their own spacing. */
.wp-site-blocks > * {
	margin-block-start: 0;
}

/* Footer logo: a hairline ring so the navy circle reads on deep navy. */
.jf-footer .wp-block-site-logo img {
	border-radius: 50%;
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--wp--preset--color--mist) 45%, transparent);
}
