/**
 * Accessible Navigation Styles
 *
 * Functional defaults for the W3C ARIA disclosure navigation pattern.
 * Adapt colors, spacing, and breakpoints in your child theme to match
 * the host theme's design — these are not finished designs.
 *
 * Note: visibility of submenus is controlled by the [hidden] attribute
 * via JavaScript. Do not override [hidden] with display rules — doing
 * so will break the toggle behavior.
 */

/* ----- Top-level menu ----- */

.main-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.main-menu > li,
.sub-menu li {
	position: relative;
}

.main-menu > li > a,
.main-menu > li > .menu-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.5rem 0.75rem;
	font: inherit;
	color: inherit;
	text-decoration: none;
}

/* ----- Toggle button reset ----- */

.menu-toggle {
	background: none;
	border: 0;
	cursor: pointer;
}

.menu-toggle:hover,
.main-menu > li > a:hover {
	text-decoration: underline;
}

/* CSS-only chevron indicator that rotates when expanded. */
.menu-toggle-icon {
	display: inline-block;
	width: 0.5em;
	height: 0.5em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-25%);
	transition: transform 0.2s ease;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon {
	transform: rotate(-135deg) translateY(0);
}

/* ----- Submenus ----- */

.sub-menu {
	list-style: none;
	margin: 0;
	padding: 0.25rem 0;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 220px;
	background: #fff;
	border: 1px solid #ccc;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	z-index: 100;
}

.sub-menu li {
	margin: 0;
}

.sub-menu a {
	display: block;
	padding: 0.5rem 1rem;
	color: inherit;
	text-decoration: none;
}

.sub-menu a:hover {
	background: #f5f5f5;
	text-decoration: underline;
}

/* Nested submenus (third level): fly out to the side */
.sub-menu .sub-menu {
	top: 0;
	left: 100%;
	margin-left: 0.25rem;
}

.sub-menu > li > a,
.sub-menu > li > .menu-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.25rem;
	padding: 0.5rem 1rem;
	font: inherit;
	color: inherit;
	text-decoration: none;
	width: 100%;
	box-sizing: border-box;
	text-align: inherit;
}

.sub-menu > li > .menu-toggle:hover {
	text-decoration: underline;
}

/* ----- Focus indicators ----- */

.main-menu :focus-visible,
.sub-menu :focus-visible {
	outline: 2px solid #06f;
	outline-offset: 2px;
	border-radius: 2px;
}

/* ----- Optional parent link ----- */

.menu-parent-link {
	margin-left: 0.25rem;
	font-size: 0.875em;
	opacity: 0.85;
}

/* ----- Screen reader only utility ----- */

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* ----- Mobile / narrow viewport ----- */

@media (max-width: 768px) {
	.main-menu {
		flex-direction: column;
		gap: 0;
	}

	.main-menu > li {
		width: 100%;
	}

	.main-menu > li > a,
	.main-menu > li > .menu-toggle,
	.sub-menu > li > a,
	.sub-menu > li > .menu-toggle {
		width: 100%;
		justify-content: space-between;
	}

	.sub-menu {
		position: static;
		border: 0;
		box-shadow: none;
		padding-left: 1rem;
	}
}
