/* Sila — Header (Figma 78:555) */

.sila-header {
	background-color: var(--sila-ink);
	color: var(--sila-cream);
}

/* Sticky. The element is the only child of Bricks' #brx-header wrapper, so
   the wrapper is what sticks (the template's own "Sticky header" setting is
   position: fixed and would cover the hero). Anchors land below the bar via
   scroll-padding-top: header.js sets --sila-header-height to the bar's
   measured height, the values here match the default geometry. */
:root {
	--sila-header-top: var(--wp-admin--admin-bar--height, 0px);
	--sila-header-height: 120px;
}

.sila-frontend > #brx-header:has(> .sila-header) {
	position: sticky;
	top: var(--sila-header-top);
	z-index: 998;
}

html:has(> .sila-frontend > #brx-header > .sila-header) {
	scroll-padding-top: calc(var(--sila-header-top) + var(--sila-header-height));
}

/* The admin bar scrolls away at this width. */
@media (max-width: 600px) {
	:root {
		--sila-header-top: 0px;
	}
}

/* Desktop: mirrored around the logo. Equal side columns keep the logo
   centred, each link group hugs it with the same gaps whatever its item
   count, and the favorites button sits apart at the far right edge. */
.sila-header__bar {
	--sila-header-gap: clamp(32px, calc(80 * var(--u)), 80px);
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	column-gap: var(--sila-header-gap);
	max-width: calc(var(--sila-container) + 2 * var(--sila-gutter));
	margin-inline: auto;
	padding: 24px var(--sila-gutter);
}

.sila-header__group {
	display: flex;
	align-items: center;
	gap: var(--sila-header-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.sila-header__group--left {
	justify-content: flex-end;
}

.sila-header__item {
	margin: 0;
}

/* Third column: right links, then the favorites button. */
.sila-header__end {
	display: flex;
	align-items: center;
	gap: 24px;
	min-width: 0;
}

.sila-header__favorites {
	flex: none;
	margin-left: auto;
	line-height: 0;
}

/* Livya Favorites Button (plugin element): outlined circle like the mobile
   toggle, sand badge with the count (written by embed.js). */
.sila-header .livya-favorites-button {
	position: relative;
	display: inline-grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 1px solid var(--sila-cream);
	border-radius: 50%;
	background-color: transparent;
	color: var(--sila-cream);
	cursor: pointer;
	transition: background-color 0.3s var(--sila-ease), color 0.3s var(--sila-ease), border-color 0.3s var(--sila-ease);
}

.sila-header .livya-favorites-button:hover,
.sila-header .livya-favorites-button:focus-visible {
	border-color: var(--sila-sand);
	background-color: var(--sila-sand);
	color: var(--sila-ink);
}

.sila-header .livya-favorites-button:focus-visible {
	outline: 2px solid var(--sila-sand);
	outline-offset: 3px;
}

.sila-header .livya-favorites-button__icon svg {
	display: block;
	width: 22px;
	height: 22px;
}

.sila-header .livya-favorites-count {
	top: -5px;
	right: -5px;
	min-width: 22px;
	height: 22px;
	padding: 0 5px;
	border: 2px solid var(--sila-ink);
	font-family: var(--sila-font-sans);
	font-size: 12px;
	line-height: 1;
	letter-spacing: 0;
}

/* favorites.js: the badge pops when a favorite is added. */
.sila-header .livya-favorites-button.is-bumped .livya-favorites-count {
	animation: sila-favorites-bump 0.6s var(--sila-ease-out);
}

@keyframes sila-favorites-bump {
	30% {
		transform: scale(1.35);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sila-header .livya-favorites-button.is-bumped .livya-favorites-count {
		animation: none;
	}
}

.sila-header__link {
	display: inline-flex;
	align-items: center;
	padding: 12px 8px;
	border-bottom: 1px solid transparent;
	color: var(--sila-cream);
	font-family: var(--sila-font-sans);
	font-size: 16px;
	line-height: 16px;
	letter-spacing: 1px;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	position: relative;
}

/* Underline (Figma: 1px cream bottom border on the active item) sweeps in
   from the left on hover and out to the right. */
.sila-header__link::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 1px;
	background-color: currentColor;
	transform: scaleX(0);
	transform-origin: 100% 50%;
	transition: transform var(--sila-hover-duration) var(--sila-ease);
}

.sila-header__link:hover::after,
.sila-header__link:focus-visible::after,
.sila-header__link.is-active::after {
	transform: scaleX(1);
	transform-origin: 0 50%;
}

.sila-header__logo {
	display: block;
	line-height: 0;
}

.sila-header__logo-img {
	display: block;
	width: 195.65px;
	height: 71.57px;
	max-width: none;
}

.sila-header__toggle,
.sila-header__panel {
	display: none;
}

/* Tablet + mobile: logo left, toggle right, links in a drop panel */
@media (max-width: 1023px) {
	:root {
		--sila-header-height: 80px;
	}

	.sila-header__bar {
		display: flex;
		justify-content: space-between;
		padding: 16px 20px;
	}

	.sila-header__group {
		display: none;
	}

	/* Favorites button + toggle, together on the right. */
	.sila-header__end {
		margin-left: auto;
	}

	.sila-header__end + .sila-header__toggle {
		margin-left: 12px;
	}

	.sila-header__logo-img {
		width: 131px;
		height: 48px;
	}

	.sila-header__toggle {
		display: inline-flex;
		flex-direction: column;
		justify-content: center;
		gap: 8px;
		width: 48px;
		height: 48px;
		padding: 12px;
		border: 1px solid var(--sila-cream);
		border-radius: 42px;
		background: transparent;
		cursor: pointer;
	}

	/* Explicit width: Safari doesn't stretch flex items inside a <button> (the bars were 0 wide on iPhone) */
	.sila-header__toggle-bar {
		display: block;
		flex: none;
		width: 100%;
		height: 1px;
		background-color: var(--sila-cream);
		transition: transform 0.25s ease;
	}

	/* The visually hidden label is the button's first span, so the top bar
	   is the second-to-last one, not :first-of-type. */
	.sila-header__toggle[aria-expanded="true"] .sila-header__toggle-bar:nth-last-of-type(2) {
		transform: translateY(4.5px) rotate(45deg);
	}

	.sila-header__toggle[aria-expanded="true"] .sila-header__toggle-bar:last-of-type {
		transform: translateY(-4.5px) rotate(-45deg);
	}

	/* The header is sticky: the panel scrolls itself on short screens. */
	.sila-header__panel:not([hidden]) {
		display: block;
		max-height: calc(100dvh - var(--sila-header-top) - var(--sila-header-height));
		padding: 8px 20px 32px;
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.sila-header__panel-list {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 16px;
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.sila-header__panel-list .sila-header__cta {
		margin-top: 8px;
	}
}
