/*
 * Sections and template parts. One block per Figma section, one root class each.
 * Rows that span the full site width (1512 minus gutters) use the site-max token;
 * everything inside a section that is narrower uses the WordPress wide and content widths.
 */

/* ---------- Header (Figma: Header, breakpoint=desktop/mobile) ---------- */

/* Sticky glass bar (Figma glass/bar): the template-part wrapper sticks, the header inside carries the glass. */
.wp-block-template-part:has(> .kchsi-header) {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 10;
}

.kchsi-header {
	padding-inline: var(--wp--custom--gutter);
	border-bottom: var(--wp--custom--border--width) solid var(--wp--custom--color--border--default);
	background-color: var(--wp--custom--glass--bar);
	box-shadow: var(--wp--preset--shadow--button);
	-webkit-backdrop-filter: blur(var(--wp--custom--glass--blur));
	backdrop-filter: blur(var(--wp--custom--glass--blur));
}

.kchsi-header__row {
	max-width: calc(var(--wp--custom--layout--site-max) - 2 * var(--wp--custom--gutter));
	margin-inline: auto;
}

.kchsi-header__nav {
	font-weight: var(--wp--custom--weight--medium);
}

/* Current page link is brand-coloured; the login and CTA links exist for the overlay only. */
.kchsi-header .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content {
	color: var(--wp--custom--color--text--brand);
}

/* Menu button: IconButton ghost md (40 x 40, pill). */
.kchsi-header .wp-block-navigation__responsive-container-open,
.kchsi-header .wp-block-navigation__responsive-container-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--wp--custom--control--height-sm);
	height: var(--wp--custom--control--height-sm);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--custom--color--icon--default);
}

.kchsi-header .wp-block-navigation__responsive-container-open:hover,
.kchsi-header .wp-block-navigation__responsive-container-close:hover {
	background-color: var(--wp--custom--color--bg--muted);
}

/* Overlay (below 1024): navy panel, heading font links, login and CTA as buttons. */
.kchsi-header .wp-block-navigation__responsive-container.is-menu-open {
	padding: var(--wp--custom--space--xl) var(--wp--custom--gutter);
}

.kchsi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
	top: var(--wp--custom--space--md);
	right: var(--wp--custom--gutter);
	color: var(--wp--custom--color--icon--on-inverse);
}

.kchsi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close:hover {
	background-color: var(--wp--custom--color--bg--inverse-elevated);
}

.kchsi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: var(--wp--custom--space--lg);
	padding-top: var(--wp--custom--space--xxl);
}

.kchsi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-family: var(--wp--custom--font--heading);
	font-size: var(--wp--custom--type--heading-3);
	font-weight: var(--wp--custom--weight--heading-3);
	line-height: var(--wp--custom--line-height--heading-3);
	letter-spacing: var(--wp--custom--tracking--heading-3);
}

.kchsi-header .is-menu-open .kchsi-nav-login,
.kchsi-header .is-menu-open .kchsi-nav-cta {
	margin-top: var(--wp--custom--space--sm);
}

.kchsi-header .is-menu-open .kchsi-nav-login .wp-block-navigation-item__content,
.kchsi-header .is-menu-open .kchsi-nav-cta .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--wp--custom--control--height-lg);
	padding: var(--wp--custom--space--md) var(--wp--custom--space--xl);
	border-radius: var(--wp--custom--radius--pill);
	font-family: var(--wp--custom--font--body);
	font-size: var(--wp--custom--font-size--16);
	font-weight: var(--wp--custom--weight--semibold);
	line-height: var(--wp--custom--line-height--label);
	letter-spacing: var(--wp--custom--tracking--body);
	text-decoration: none;
}

.kchsi-header .is-menu-open .kchsi-nav-login .wp-block-navigation-item__content {
	color: var(--wp--custom--color--text--on-inverse);
	box-shadow: inset 0 0 0 var(--wp--custom--border--width-strong) var(--wp--custom--color--text--on-inverse);
}

.kchsi-header .is-menu-open .kchsi-nav-cta .wp-block-navigation-item__content {
	background-color: var(--wp--custom--color--status--warning);
	color: var(--wp--custom--color--text--on-brand);
}

/* Below 1024: only the logo and the menu button. Two classes, so it beats the flex layout's
   display: flex from core (body .is-layout-flex). */
@media (max-width: 1023px) {
	.kchsi-header .kchsi-header__actions {
		display: none;
	}
}

/* From 1024: the navigation is inline and the overlay machinery is off.
   Mirrors the core rules that apply from 600 pixels to containers that are not hidden-by-default. */
@media (min-width: 1024px) {
	.kchsi-header .wp-block-navigation__responsive-container-open.always-shown {
		display: none;
	}

	.kchsi-header .wp-block-navigation__responsive-container.hidden-by-default:not(.is-menu-open) {
		display: block;
		position: relative;
		width: 100%;
		z-index: auto;
		background-color: inherit;
	}

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

	.kchsi-header .kchsi-nav-login,
	.kchsi-header .kchsi-nav-cta {
		display: none;
	}
}

/* ---------- Footer (Figma: Footer, breakpoint=desktop/mobile) ---------- */

.kchsi-footer {
	padding-inline: var(--wp--custom--gutter);
}

.kchsi-footer__inner {
	max-width: calc(var(--wp--custom--layout--site-max) - 2 * var(--wp--custom--gutter));
	margin-inline: auto;
}

.kchsi-footer__brand {
	max-width: var(--wp--custom--layout--footer-brand);
}

.kchsi-footer__column {
	min-width: 0;
}

.kchsi-footer a {
	color: inherit;
}

.kchsi-footer .wp-block-navigation a:hover,
.kchsi-footer .wp-block-navigation a:focus-visible {
	color: var(--wp--custom--color--text--brand-on-inverse);
}

.kchsi-footer__bottom {
	padding-top: var(--wp--custom--space--lg);
	border-top: var(--wp--custom--border--width) solid var(--wp--custom--color--bg--inverse-elevated);
}

@media (max-width: 767px) {
	.kchsi-footer__columns {
		flex-direction: column;
		gap: var(--wp--custom--space--lg);
	}

	.kchsi-footer__bottom {
		flex-direction: column;
		align-items: flex-start;
		gap: var(--wp--custom--space--md);
	}
}

/* Compact footer (Figma Footer size=compact): course, test and login pages. One row: copyright,
   the two legal links, the KCHSI logo. No site navigation. */
.kchsi-footer--compact .kchsi-footer__bottom {
	padding-top: 0;
	border-top: 0;
}

.kchsi-footer__legal .wp-block-navigation a {
	color: var(--wp--custom--color--text--on-inverse-muted);
	font-size: var(--wp--custom--font-size--14);
}

/* ---------- Ambient layer (Figma: ambient, orbs and grid) ----------
   Decorative, no markup: soft accent orbs as radial gradients on ::before (cheaper than filter: blur),
   the faint grid with a radial fade on ::after. Orb positions are set per section with
   --kchsi-orb-a / --kchsi-orb-b / --kchsi-orb-c (x y). Each orb holds its colour to 30% of the radius
   and fades out by 75%, which reads like Figma's blurred disc. The CTA uses the -strong set. */
.kchsi-ambient {
	--kchsi-orb-teal: var(--wp--custom--ambient--teal);
	--kchsi-orb-amber: var(--wp--custom--ambient--amber);
	--kchsi-orb-coral: var(--wp--custom--ambient--coral);
	position: relative;
	isolation: isolate;
	overflow: hidden;
}

.kchsi-ambient::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background:
		radial-gradient(circle var(--wp--custom--ambient--orb) at var(--kchsi-orb-a, 75% 25%), var(--kchsi-orb-teal) 0 30%, transparent 75%),
		radial-gradient(circle var(--wp--custom--ambient--orb-small) at var(--kchsi-orb-b, 90% 75%), var(--kchsi-orb-amber) 0 30%, transparent 75%),
		radial-gradient(circle var(--wp--custom--ambient--orb-small) at var(--kchsi-orb-c, 5% 85%), var(--kchsi-orb-coral) 0 30%, transparent 75%);
}

.kchsi-ambient--grid::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background-image:
		linear-gradient(to right, var(--wp--custom--ambient--grid-line) var(--wp--custom--border--width), transparent var(--wp--custom--border--width)),
		linear-gradient(to bottom, var(--wp--custom--ambient--grid-line) var(--wp--custom--border--width), transparent var(--wp--custom--border--width));
	background-size: var(--wp--custom--ambient--grid-cell) var(--wp--custom--ambient--grid-cell);
	-webkit-mask-image: radial-gradient(ellipse at 50% 40%, black, transparent 70%);
	mask-image: radial-gradient(ellipse at 50% 40%, black, transparent 70%);
}


/* Shared ambient (template page-ambient: About, Contact, FAQ). The orbs sit on <main>, one at the start
   and two at the end, so they run across section edges instead of restarting in every section. The
   sections go transparent and drop their own orbs; the page header keeps its grid as the accent.
   The end orbs use the -strong set because the CTA glass panel sits on them. */
.kchsi-page-ambient {
	--kchsi-orb-amber: var(--wp--custom--ambient--amber-strong);
	--kchsi-orb-coral: var(--wp--custom--ambient--coral-strong);
	--kchsi-orb-a: 85% 0%;
	--kchsi-orb-b: 70% 95%;
	--kchsi-orb-c: 15% 100%;
}

.kchsi-page-ambient .wp-block-post-content > .alignfull.has-background {
	background-color: transparent !important; /* beats the !important on WordPress's has-*-background-color */
}

.kchsi-page-ambient .wp-block-post-content > .kchsi-ambient::before {
	content: none;
}

/* ---------- Hero (Figma: Section/Hero) ---------- */

.kchsi-hero {
	--kchsi-orb-a: 80% 20%;
	--kchsi-orb-b: 95% 70%;
	--kchsi-orb-c: 0% 90%;
	min-height: var(--wp--custom--section-min--hero);
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.kchsi-hero__copy {
	flex: 1 1 0;
	min-width: 0;
}

/* Vertical video (9:16) in a glass shell, centred in the media column; the lesson chip overlaps its
   left edge near the top, the certificate chip its right edge near the bottom (Figma Section/Hero). */
.kchsi-hero__media {
	position: relative;
	display: flex;
	justify-content: center;
	flex: 0 0 var(--wp--custom--layout--hero-media);
	max-width: 100%;
	padding-block: var(--wp--custom--space--xl);
}

.kchsi-hero__shell {
	width: calc(var(--wp--custom--layout--hero-video) + 2 * var(--wp--custom--space--sm));
	max-width: 100%;
	padding: var(--wp--custom--space--sm);
	border: var(--wp--custom--border--width) solid var(--wp--custom--glass--edge);
	border-radius: var(--wp--custom--radius--card);
	background-color: var(--wp--custom--glass--fill);
	box-shadow: var(--wp--preset--shadow--card-hover);
}

.kchsi-hero__media .kchsi-float--lesson {
	top: 15%;
	right: calc(50% + var(--wp--custom--layout--hero-video) / 2 - var(--wp--custom--spacing--18));
}

.kchsi-hero__media .kchsi-float--certificate {
	bottom: 15%;
	left: calc(50% + var(--wp--custom--layout--hero-video) / 2 - var(--wp--custom--spacing--18));
}

@media (max-width: 1023px) {
	.kchsi-hero__container {
		flex-direction: column;
		align-items: stretch;
	}

	.kchsi-hero__media {
		flex-basis: auto;
	}
}

/* On phones the chips sit at the screen edges and overlap the video. */
@media (max-width: 767px) {
	.kchsi-hero__media .kchsi-float--lesson {
		right: auto;
		left: 0;
	}

	.kchsi-hero__media .kchsi-float--certificate {
		left: auto;
		right: 0;
	}
}

/* ---------- Marquee (Figma: Section/Marquee) ---------- */

.kchsi-marquee {
	overflow: hidden;
}

.kchsi-marquee__track {
	width: max-content;
	color: var(--wp--custom--color--text--brand-on-inverse);
	font-weight: var(--wp--custom--weight--medium);
	line-height: var(--wp--custom--line-height--label);
}

.kchsi-marquee__set {
	flex: none;
	padding-right: var(--wp--custom--space--xxl);
}

.kchsi-marquee__item {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--custom--space--xxl);
	margin: 0;
	white-space: nowrap;
}

/* Lucide "asterisk" separator, 16 px, in the current colour. */
.kchsi-marquee__item::after {
	content: "";
	flex: none;
	width: var(--wp--custom--spacing--4);
	height: var(--wp--custom--spacing--4);
	background-color: currentColor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M18.07 8.5 5.94 15.5M5.94 8.5l12.13 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Grid containers ----------
   These groups use the default (flow) layout in the editor but are CSS grids here; the flow layout's
   block-gap margin would offset every item after the first, so the grid gap replaces it. */
.kchsi-bento__row > *,
.kchsi-steps__list > *,
.kchsi-why__grid > * {
	margin-block: 0;
}

/* ---------- Topics (Figma: Section/Topics, bento of Card/Bento) ---------- */

.kchsi-topics {
	--kchsi-orb-a: 0% 30%;
	--kchsi-orb-b: 100% 80%;
	--kchsi-orb-c: 50% 110%;
}

/* Two rows: wide + narrow, then the mirror (kchsi-bento__row--flip). One column below 1024. */
.kchsi-bento__row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--wp--custom--layout--bento-narrow);
	gap: var(--wp--custom--grid-gap);
}

.kchsi-bento__row--flip {
	grid-template-columns: var(--wp--custom--layout--bento-narrow) minmax(0, 1fr);
}

@media (max-width: 1023px) {
	.kchsi-bento__row,
	.kchsi-bento__row--flip {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ---------- Steps (Figma: Section/Steps, timeline) ----------
   The track runs through the centres of the number discs; --kchsi-progress (0 to 1) fills it (motion.js).
   Horizontal from 1024, vertical below. */
.kchsi-steps__list {
	position: relative;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--wp--custom--grid-gap);
	--kchsi-progress: 0;
	--kchsi-disc-center: calc(var(--wp--custom--space--lg) + var(--wp--custom--layout--step-number) / 2);
}

.kchsi-steps__list::before,
.kchsi-steps__list::after {
	content: "";
	position: absolute;
	top: var(--kchsi-disc-center);
	left: calc(100% / 8);
	right: calc(100% / 8);
	height: var(--wp--custom--border--width-strong);
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--wp--custom--color--border--strong);
	z-index: 0;
}

.kchsi-steps__list::after {
	background-color: var(--wp--custom--color--bg--brand);
	box-shadow: var(--wp--preset--shadow--glow-soft-brand);
	transform: scaleX(var(--kchsi-progress));
	transform-origin: left center;
	transition: transform var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--ease--out);
}

.kchsi-steps__list > .kchsi-step {
	z-index: 1;
}

@media (max-width: 1023px) {
	.kchsi-steps__list {
		grid-template-columns: minmax(0, 1fr);
	}

	.kchsi-steps__list::before,
	.kchsi-steps__list::after {
		top: var(--kchsi-disc-center);
		bottom: var(--kchsi-disc-center);
		left: calc(var(--kchsi-disc-center) - var(--wp--custom--border--width));
		right: auto;
		width: var(--wp--custom--border--width-strong);
		height: auto;
	}

	.kchsi-steps__list::after {
		transform: scaleY(var(--kchsi-progress));
		transform-origin: center top;
	}
}

/* ---------- Lessons (Figma: Section/Lessons) ---------- */

.kchsi-lessons__head-row .kchsi-head {
	flex: 1 1 var(--wp--custom--layout--content-width);
}

/* Promo keeps its row on tablet as a full-width card under the two lessons (Figma wrap). */
@media (min-width: 768px) and (max-width: 1023px) {
	.kchsi-lessons__grid > .is-style-card-promo {
		grid-column: 1 / -1;
	}
}

/* ---------- Why (Figma: Section/Why, head left, 2 x 2 grid right) ---------- */

.kchsi-why__head {
	flex: 0 0 var(--wp--custom--layout--why-head);
	max-width: 100%;
}

.kchsi-why__grid {
	flex: 1 1 0;
	min-width: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--custom--grid-gap);
}

@media (max-width: 1023px) {
	.kchsi-why__container {
		flex-direction: column;
		align-items: stretch;
	}

	.kchsi-why__head {
		flex-basis: auto;
	}
}

@media (max-width: 767px) {
	.kchsi-why__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ---------- Backers (Figma: Section/Backers, glass stats over soft orbs) ---------- */

.kchsi-backers {
	--kchsi-orb-a: 80% 20%;
	--kchsi-orb-b: 95% 85%;
	--kchsi-orb-c: -10% -10%;
}

.kchsi-backers__copy {
	flex: 1 1 0;
	min-width: 0;
}

.kchsi-backers__stats {
	flex: 0 0 var(--wp--custom--layout--stats-width);
	max-width: 100%;
}

@media (max-width: 1023px) {
	.kchsi-backers {
		--kchsi-orb-a: 70% 80%;
		--kchsi-orb-b: 100% 100%;
	}

	.kchsi-backers__container {
		flex-direction: column;
		align-items: stretch;
	}

	.kchsi-backers__stats {
		flex-basis: auto;
	}
}

/* ---------- CTA (Figma: Section/CTA, light glass panel over orbs) ---------- */

.kchsi-cta {
	--kchsi-orb-teal: var(--wp--custom--ambient--teal-strong);
	--kchsi-orb-amber: var(--wp--custom--ambient--amber-strong);
	--kchsi-orb-coral: var(--wp--custom--ambient--coral-strong);
	--kchsi-orb-a: 25% 30%;
	--kchsi-orb-b: 65% 70%;
	--kchsi-orb-c: 45% 0%;
	min-height: var(--wp--custom--section-min--cta);
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.kchsi-cta__panel {
	padding: var(--wp--custom--space--xxl) var(--wp--custom--space--xl);
}

.kchsi-cta__panel .wp-block-heading {
	max-width: var(--wp--custom--layout--content-width);
	margin-inline: auto;
	font-size: var(--wp--custom--type--heading-1);
	line-height: var(--wp--custom--line-height--heading-1);
	letter-spacing: var(--wp--custom--tracking--heading-1);
}

/* ---------- Page header, Content, Contact (inner pages) ---------- */

.kchsi-page-header {
	--kchsi-orb-a: 80% 0%;
	--kchsi-orb-b: 100% 60%;
	--kchsi-orb-c: -20% -20%;
}

.kchsi-page-header__head {
	max-width: var(--wp--custom--layout--content-width);
}

.kchsi-contact {
	--kchsi-orb-a: 85% 15%;
	--kchsi-orb-b: 45% 85%;
	--kchsi-orb-c: -20% -20%;
}

.kchsi-contact__details {
	flex: 0 0 var(--wp--custom--layout--contact-details);
	max-width: 100%;
}

/* Title at heading-3 under the page h1, then the detail rows with room between them
   (.kchsi-detail zeroes its margins, so the column gap does the spacing). */
.kchsi-contact__direct {
	display: flex;
	flex-direction: column;
	gap: var(--wp--custom--space--md);
}

.kchsi-contact__title {
	margin-bottom: var(--wp--custom--space--sm);
	font-size: var(--wp--custom--type--heading-3);
	line-height: var(--wp--custom--line-height--heading-3);
	letter-spacing: var(--wp--custom--tracking--heading-3);
}

.kchsi-contact__form {
	flex: 1 1 0;
	min-width: 0;
	padding: var(--wp--custom--space--xl);
}

@media (max-width: 1023px) {
	.kchsi-contact__container {
		flex-direction: column;
		align-items: stretch;
	}

	.kchsi-contact__details {
		flex-basis: auto;
	}
}

@media (max-width: 767px) {
	.kchsi-contact__form {
		padding: var(--wp--custom--space--lg);
	}
}

/* ---------- About topics (Figma: Section/AboutTopics, photo then six Card/Benefit) ---------- */

.kchsi-about__container > * {
	margin-block: 0;
}

.kchsi-about__media {
	aspect-ratio: auto;
	height: var(--wp--custom--layout--about-media);
}

.kchsi-about__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--custom--grid-gap);
}

.kchsi-about__grid > * {
	margin-block: 0;
}

@media (max-width: 767px) {
	.kchsi-about__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}
