/**
 * Pill Navigation - Mobile Dropdown
 *
 * Converts the horizontal pill navigation into a dropdown on mobile.
 * The current page is shown as the trigger with a caret to expand.
 * Progressive enhancement — no-JS users see the full list.
 *
 * @package Sierra_At_Tahoe
 */

/* Trigger is hidden by default — only shown on mobile via media query */
.pill-nav-dropdown-trigger {
	display: none;
}

@media (max-width: 782px) {

	/* Container becomes a dropdown wrapper */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown {
		position: relative;
		padding: 0;
		border-radius: 40px;
		overflow: visible;
	}

	/* Show the trigger button */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .pill-nav-dropdown-trigger {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		background-color: var(--wp--preset--color--deep-alpine);
		color: var(--wp--preset--color--snowcap-sage);
		border: none;
		border-radius: 40px;
		padding: 14px 20px 14px 24px;
		font-size: var(--wp--preset--font-size--body-medium);
		font-weight: 700;
		font-family: inherit;
		line-height: 1.33;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		touch-action: manipulation;
	}

	.pill-nav-dropdown-trigger__label {
		flex: 1;
		text-align: left;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* Caret touch target — generous 44x44px minimum for accessibility */
	.pill-nav-dropdown-trigger__caret {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		width: 44px;
		height: 44px;
		margin: -10px -8px -10px 0;
		transition: transform 0.25s ease;
	}

	.pill-nav-dropdown-trigger__caret svg {
		width: 20px;
		height: 20px;
	}

	/* Rotate caret when open */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown.is-dropdown-open
		.pill-nav-dropdown-trigger__caret {
		transform: rotate(180deg);
	}

	/*
	 * Nav list: always display:flex for animation, but hidden via
	 * visibility + opacity when closed. This allows smooth transitions.
	 */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation__container {
		display: flex;
		position: absolute;
		top: calc(100% + 8px);
		left: 0;
		right: 0;
		z-index: 10;
		flex-direction: column;
		gap: 0;
		background-color: var(--wp--preset--color--module-background);
		border-radius: 16px;
		padding: 8px;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
		/* Hidden state */
		visibility: hidden;
		opacity: 0;
		transform: translateY(-8px);
		pointer-events: none;
		transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	}

	/* Open state */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown.is-dropdown-open
		.wp-block-navigation__container {
		visibility: visible;
		opacity: 1;
		transform: translateY(0);
		pointer-events: auto;
	}

	/* Dropdown link items */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item {
		width: 100%;
	}

	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item a {
		display: block;
		border-radius: 12px;
		padding: 14px 16px;
		font-weight: 400;
		color: var(--wp--preset--color--deep-alpine);
		background: transparent;
	}

	/* Current page item in dropdown */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item.current-menu-item > a,
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item.current_page_item > a {
		font-weight: 700;
		color: var(--wp--preset--color--snowcap-sage);
		background-color: var(--wp--preset--color--deep-alpine);
	}

	/* Hover/focus states in dropdown */
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item:not(.current-menu-item):not(.current_page_item) a:hover,
	.wp-block-navigation.is-style-pill.has-mobile-dropdown .wp-block-navigation-item:not(.current-menu-item):not(.current_page_item) a:focus {
		background-color: rgba(20, 44, 45, 0.06);
	}
}
