/**
 * BBX theme stylesheet. The only CSS file the theme ships.
 *
 * Design tokens: theme.json presets are the source of truth; the --bbx-*
 * properties below bridge them (with static fallbacks) so templates and
 * future option phases reference one stable namespace.
 */

:root {
	--bbx-color-background: var( --wp--preset--color--background, #ffffff );
	--bbx-color-text: var( --wp--preset--color--text, #1a1a1a );
	--bbx-color-accent: var( --wp--preset--color--accent, #2563eb );
	--bbx-font-body: var( --wp--preset--font-family--body, sans-serif );
	--bbx-font-heading: var( --wp--preset--font-family--heading, sans-serif );
	--bbx-layout-content-width: 42rem;
	--bbx-layout-site-width: 72rem;
	--bbx-space: clamp( 1rem, 2.5vw, 1.5rem );
	--bbx-nav-breakpoint: 48em; /* documented; media queries below mirror it */
}

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

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

body {
	margin: 0;
	background: var( --bbx-color-background );
	color: var( --bbx-color-text );
	font-family: var( --bbx-font-body );
	font-size: 1rem;
	line-height: 1.6;
	-webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5, h6 {
	font-family: var( --bbx-font-heading );
	line-height: 1.2;
	margin: 1.5em 0 0.5em;
}

h1 { font-size: clamp( 1.75rem, 4vw, 2.25rem ); }
h2 { font-size: clamp( 1.375rem, 3vw, 1.75rem ); }
h3 { font-size: clamp( 1.125rem, 2.5vw, 1.375rem ); }

a {
	color: var( --bbx-color-accent );
}

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

/* ------------------------------------------------------------ Skip link */

.bbx-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var( --bbx-color-text );
	color: var( --bbx-color-background );
	padding: 0.5rem 1rem;
	z-index: 100;
}

.bbx-skip-link:focus {
	left: 0;
}

/* ----------------------------------------------------------- Page frame */

.bbx-page {
	min-height: 100dvh;
	display: grid;
	grid-template-rows: auto 1fr auto;
	/* Full-bleed breakouts use 100vw, which includes the scrollbar gutter;
	   clip the stray horizontal overflow at the page frame. */
	overflow-x: clip;
}

#bbx-content {
	width: min( 100% - calc( var( --bbx-space ) * 2 ), var( --bbx-layout-content-width ) );
	margin-inline: auto;
	padding-block: calc( var( --bbx-space ) * 2 );
}

/*
 * Beaver Builder layouts manage their own width. On builder-made singular
 * content, break only the entry content region out to full-bleed so the
 * entry chrome (title, meta) stays on the content column. Themer content
 * layouts replace the template wholesale, so they get the full-bleed main.
 */
.fl-builder .bbx-entry-content {
	width: 100vw;
	margin-inline: calc( 50% - 50vw );
}

.fl-builder.fl-theme-builder-archive #bbx-content,
.fl-builder.fl-theme-builder-singular #bbx-content,
.fl-builder.fl-theme-builder-404 #bbx-content {
	width: 100%;
	max-width: none;
	padding-block: 0;
}

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

.bbx-header {
	border-bottom: 1px solid color-mix( in srgb, var( --bbx-color-text ) 12%, transparent );
}

.bbx-header-inner {
	width: min( 100% - calc( var( --bbx-space ) * 2 ), var( --bbx-layout-site-width ) );
	margin-inline: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var( --bbx-space );
	padding-block: 1rem;
}

.bbx-branding {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.bbx-site-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
}

.bbx-site-title a {
	color: inherit;
	text-decoration: none;
}

/* ------------------------------------------------------------------ Nav */

.bbx-nav-toggle {
	display: none;
	background: none;
	border: 1px solid color-mix( in srgb, var( --bbx-color-text ) 25%, transparent );
	border-radius: 4px;
	padding: 0.5rem 0.75rem;
	font: inherit;
	color: inherit;
	cursor: pointer;
}

.bbx-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.bbx-nav > div > ul,
.bbx-nav > ul {
	display: flex;
	gap: 1.25rem;
}

.bbx-nav a {
	color: inherit;
	text-decoration: none;
}

.bbx-nav a:hover,
.bbx-nav a:focus {
	color: var( --bbx-color-accent );
}

/* -------------------------------------------- Disclosure submenus */

.bbx-nav .menu-item-has-children {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.bbx-submenu-toggle {
	background: none;
	border: 0;
	padding: 0.25rem;
	color: inherit;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
}

.bbx-submenu-toggle svg {
	transition: transform 0.15s ease;
}

.bbx-submenu-toggle[aria-expanded='true'] svg {
	transform: rotate( 180deg );
}

/* aria-expanded on the toggle is the single source of truth. */
.bbx-nav .sub-menu {
	display: none;
}

.bbx-nav .bbx-submenu-toggle[aria-expanded='true'] ~ .sub-menu {
	display: block;
}

@media ( min-width: 48.01em ) {
	.bbx-nav .sub-menu {
		position: absolute;
		top: 100%;
		left: 0;
		min-width: 12rem;
		background: var( --bbx-color-background );
		border: 1px solid color-mix( in srgb, var( --bbx-color-text ) 12%, transparent );
		border-radius: 6px;
		box-shadow: 0 8px 24px color-mix( in srgb, var( --bbx-color-text ) 10%, transparent );
		padding: 0.5rem;
		z-index: 10;
	}

	/* Third level and deeper flies out to the side. */
	.bbx-nav .sub-menu .sub-menu {
		top: 0;
		left: 100%;
	}

	.bbx-nav .sub-menu a {
		display: block;
		padding: 0.375rem 0.5rem;
	}
}

@media ( max-width: 48em ) {
	.bbx-nav-toggle {
		display: block;
	}

	.bbx-nav {
		display: none;
		width: 100%;
	}

	.bbx-nav.is-open {
		display: block;
	}

	.bbx-nav > div > ul,
	.bbx-nav > ul {
		flex-direction: column;
		gap: 0.75rem;
		padding-block: 0.75rem;
	}

	.bbx-nav .menu-item-has-children {
		flex-wrap: wrap;
	}

	/* Submenus expand inline within the panel. */
	.bbx-nav .bbx-submenu-toggle[aria-expanded='true'] ~ .sub-menu {
		width: 100%;
		padding-left: 1rem;
	}

	.bbx-header-inner {
		flex-wrap: wrap;
	}
}

/* ---------------------------------------------------------------- Entry */

.bbx-entry + .bbx-entry {
	margin-top: calc( var( --bbx-space ) * 2.5 );
}

.bbx-entry-title {
	margin-top: 0;
}

.bbx-entry-title a {
	color: inherit;
	text-decoration: none;
}

.bbx-entry-title a:hover,
.bbx-entry-title a:focus {
	color: var( --bbx-color-accent );
}

.bbx-entry-meta {
	font-size: 0.875rem;
	opacity: 0.75;
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

.bbx-entry-footer {
	margin-top: var( --bbx-space );
	font-size: 0.875rem;
	opacity: 0.75;
}

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

.bbx-footer {
	border-top: 1px solid color-mix( in srgb, var( --bbx-color-text ) 12%, transparent );
}

.bbx-footer-inner {
	width: min( 100% - calc( var( --bbx-space ) * 2 ), var( --bbx-layout-site-width ) );
	margin-inline: auto;
	padding-block: 1.5rem;
	font-size: 0.875rem;
	opacity: 0.8;
	display: flex;
	justify-content: space-between;
	gap: var( --bbx-space );
	flex-wrap: wrap;
}

/* ----------------------------------------------------------- Pagination */

.bbx-pagination {
	margin-top: calc( var( --bbx-space ) * 2 );
	display: flex;
	gap: 1rem;
}
