/*
 * Vendix parts: the theme header and footer (drawn only when no Vendix or
 * Elementor layout replaces them) and the back to top button.
 *
 * This file also loads when the base styles are off, so every token has a fallback.
 */

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

.site-header {
	position: relative;
	z-index: 100;
	border-block-end: 1px solid var(--vt-border, #e5e7eb);
	background-color: #ffffff;
}

.site-header-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: 72px;
	padding-block: 0.75rem;
}

.site-branding {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.site-branding .custom-logo-link {
	display: block;
}

.site-branding .custom-logo {
	display: block;
	width: auto;
	max-height: 60px;
}

.site-title {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.2;
}

.site-title a {
	color: var(--vt-heading, #1f2328);
	text-decoration: none;
}

.site-description {
	margin: 0;
	color: var(--vt-muted, #6b7280);
	font-size: 0.875rem;
}

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

/*
 * The menu row of the Vendix design system typography (--vendix-type-menu-*),
 * read as base.css reads the text and heading rows: the size resolved for the
 * device here, every value with the theme's own (inherited) value as fallback.
 */
:root {
	--vt-type-menu-size: var(--vendix-type-menu-size);
}

@media (max-width: 1024px) {
	:root {
		--vt-type-menu-size: var(--vendix-type-menu-size-tablet, var(--vendix-type-menu-size));
	}
}

@media (max-width: 767px) {
	:root {
		--vt-type-menu-size: var(--vendix-type-menu-size-mobile, var(--vendix-type-menu-size-tablet, var(--vendix-type-menu-size)));
	}
}

.site-navigation ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-navigation a {
	display: block;
	padding: 0.5rem 0.875rem;
	color: var(--vt-heading, #1f2328);
	font-family: var(--vendix-type-menu-family, inherit);
	font-size: var(--vt-type-menu-size, inherit);
	font-weight: var(--vendix-type-menu-weight, inherit);
	line-height: var(--vendix-type-menu-line-height, inherit);
	letter-spacing: var(--vendix-type-menu-letter-spacing, inherit);
	text-transform: var(--vendix-type-menu-transform, inherit);
	text-decoration: none;
}

.site-navigation a:hover,
.site-navigation .current-menu-item > a,
.site-navigation .current-menu-ancestor > a {
	color: var(--vt-accent, #1f6feb);
}

.vt-menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--vt-border, #e5e7eb);
	border-radius: var(--vt-radius, 4px);
	background-color: transparent;
	color: var(--vt-heading, #1f2328);
	cursor: pointer;
}

.vt-menu-toggle:hover,
.vt-menu-toggle:focus {
	background-color: var(--vt-surface, #f6f7f9);
	color: var(--vt-heading, #1f2328);
}

/* Three lines: the span is the middle one, ::before and ::after the others. */
.vt-menu-toggle-icon,
.vt-menu-toggle-icon::before,
.vt-menu-toggle-icon::after {
	display: block;
	width: 20px;
	height: 2px;
	border-radius: 2px;
	background-color: currentColor;
	transition: transform 0.2s, background-color 0.2s;
}

.vt-menu-toggle-icon {
	position: relative;
}

.vt-menu-toggle-icon::before,
.vt-menu-toggle-icon::after {
	content: "";
	position: absolute;
	left: 0;
}

.vt-menu-toggle-icon::before {
	top: -6px;
}

.vt-menu-toggle-icon::after {
	top: 6px;
}

.vt-menu-toggle[aria-expanded="true"] .vt-menu-toggle-icon {
	background-color: transparent;
}

.vt-menu-toggle[aria-expanded="true"] .vt-menu-toggle-icon::before {
	transform: translateY(6px) rotate(45deg);
}

.vt-menu-toggle[aria-expanded="true"] .vt-menu-toggle-icon::after {
	transform: translateY(-6px) rotate(-45deg);
}

/* Desktop: a row with dropdowns on hover and keyboard focus. */
@media (min-width: 1025px) {
	.site-navigation > ul {
		display: flex;
		flex-wrap: wrap;
	}

	.site-navigation li {
		position: relative;
	}

	.site-navigation .menu-item-has-children > a::after {
		content: "";
		display: inline-block;
		width: 0.4em;
		height: 0.4em;
		margin-inline-start: 0.4em;
		/* Physical sides: the arrow points down in both reading directions. */
		border-bottom: 1.5px solid currentColor;
		border-right: 1.5px solid currentColor;
		transform: translateY(-0.15em) rotate(45deg);
	}

	.site-navigation .sub-menu {
		position: absolute;
		top: 100%;
		inset-inline-start: 0;
		z-index: 10;
		display: none;
		min-width: 200px;
		padding-block: 0.375rem;
		border: 1px solid var(--vt-border, #e5e7eb);
		border-radius: var(--vt-radius, 4px);
		background-color: #ffffff;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
	}

	.site-navigation .sub-menu .sub-menu {
		top: -0.375rem;
		inset-inline-start: 100%;
	}

	/*
	 * A dropdown that would leave the window (theme.js adds vt-submenu-flip): the
	 * first level lines up with the end edge of its item, deeper levels open on
	 * the other side of their parent.
	 */
	.site-navigation .vt-submenu-flip > .sub-menu {
		inset-inline-start: auto;
		inset-inline-end: 0;
	}

	.site-navigation .sub-menu .vt-submenu-flip > .sub-menu {
		inset-inline-end: 100%;
	}

	.site-navigation li:hover > .sub-menu,
	.site-navigation li:focus-within > .sub-menu {
		display: block;
	}
}

/* Tablet and phone: the toggle opens the menu as a list under the header. */
@media (max-width: 1024px) {
	.vt-menu-toggle {
		display: inline-flex;
	}

	.site-navigation {
		display: none;
		flex-basis: 100%;
		padding-block-end: 0.5rem;
	}

	.site-navigation.is-open {
		display: block;
	}

	.site-navigation li {
		border-block-start: 1px solid var(--vt-border, #e5e7eb);
	}

	.site-navigation a {
		padding-inline: 0;
	}

	.site-navigation .sub-menu {
		padding-inline-start: 1rem;
	}
}

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

/*
 * A region printed in the header row right after the logo
 * (vendix_theme/header_after_branding) with the class vt-header-slot, such as
 * the news area beside the logo or a plugin's banner.
 *
 * Tablet and phone: a row of its own under the logo and the menu toggle. The
 * keyboard still reaches it before the toggle: the page order follows the
 * desktop layout (logo, slot, then the menu row).
 */
@media (max-width: 1024px) {
	.site-header-inner > .vt-header-slot {
		flex-basis: 100%;
		order: 5;
	}
}

/* Desktop: at the end of the logo row; the menu moves to a row of its own below. */
@media (min-width: 1025px) {
	.site-header-inner > .vt-header-slot {
		margin-inline-start: auto;
	}

	.vt-header-slot ~ .site-navigation {
		flex-basis: 100%;
		order: 10;
	}
}

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

/*
 * The parts printed at the end of the header row (vendix_theme/header_actions),
 * such as the store items and the icons of plugins, stand together in one group
 * (template-parts/header.php).
 */
.vt-header-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
}

/*
 * Tablet and phone: the logo or site title takes the room that the menu toggle
 * and the header actions leave, but never less than 6rem, so it stays readable.
 * When the row has no room for that, the actions move to a row of their own
 * below it, at its end.
 */
@media (max-width: 1024px) {
	.site-branding {
		flex: 1 1 0%;
		min-width: 6rem;
	}

	.vt-header-actions {
		margin-inline-start: auto;
	}
}

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

.site-footer {
	border-block-start: 1px solid var(--vt-border, #e5e7eb);
	color: var(--vt-muted, #6b7280);
	font-size: 0.875rem;
}

.site-footer-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding-block: 1.5rem;
}

.footer-navigation ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.footer-navigation a {
	color: inherit;
	text-decoration: none;
}

.footer-navigation a:hover {
	color: var(--vt-accent, #1f6feb);
}

.site-info p:last-child {
	margin-block-end: 0;
}

@media (max-width: 767px) {
	.site-footer-inner {
		flex-direction: column;
		text-align: center;
	}

	.footer-navigation ul {
		justify-content: center;
	}
}

/* Back to top --------------------------------------------------------- */

/*
 * Plugins with fixed parts at the bottom of the window, such as a sticky add to
 * cart bar, lift the button above them with --vt-back-to-top-offset, its
 * distance from the bottom edge, set on <html> or <body>.
 */
.vt-back-to-top {
	position: fixed;
	inset-block-end: var(--vt-back-to-top-offset, 24px);
	inset-inline-end: 24px;
	z-index: 999;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--vt-accent, #1f6feb);
	color: #ffffff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	transition: opacity 0.2s, transform 0.2s;
}

.vt-back-to-top:hover,
.vt-back-to-top:focus {
	background-color: var(--vt-accent, #1f6feb);
	color: #ffffff;
	transform: translateY(-2px);
}

.vt-back-to-top[hidden] {
	display: none;
}

/* Out of the way while the phone menu is open (theme.js adds vt-menu-open to <html>). */
.vt-menu-open .vt-back-to-top {
	visibility: hidden;
}
