/**
 * Mobile tab bar and Browse sheet (inc/mobile-tabbar.php). Phones only.
 * z-index: above page content, the header (8000) and the admin card controls (9999); below the
 * Editor Picks button (10010), the basket drawer (999998), modals (999999) and the Airlock banner.
 * The Product Lens filter panel (9999) is full screen, so the bar hides while it is open.
 */

.orbit-tabbar,
.orbit-browse {
	display: none;
}

@media (max-width: 768px) {
	body.has-tabbar {
		--orbit-tabbar-h: 60px;
		--orbit-tabbar-bottom: 0px;
		/* The full iPhone inset (34px) is more than the home indicator needs under the labels. */
		--orbit-tabbar-safe: max(0px, calc(env(safe-area-inset-bottom, 0px) - 20px));
		--orbit-tabbar-space: calc(var(--orbit-tabbar-h) + var(--orbit-tabbar-safe) + var(--orbit-tabbar-bottom));
		padding-bottom: var(--orbit-tabbar-space);
	}

	/* The admin bar is docked at the bottom on this site. Core makes it scroll away at 600px
	   and below, so only tablets reserve room for it; on phones it starts above the bar. */
	body.has-tabbar #wpadminbar {
		bottom: var(--orbit-tabbar-space);
	}

	@media (min-width: 601px) {
		body.has-tabbar.admin-bar {
			--orbit-tabbar-bottom: 46px;
		}

		body.has-tabbar #wpadminbar {
			bottom: 0;
		}
	}

	.orbit-tabbar {
		position: fixed;
		right: 0;
		bottom: var(--orbit-tabbar-bottom);
		left: 0;
		z-index: 10005;
		display: grid;
		grid-template-columns: repeat(5, minmax(0, 1fr));
		padding: 0 env(safe-area-inset-right, 0px) var(--orbit-tabbar-safe) env(safe-area-inset-left, 0px);
		background: var(--wp--preset--color--white, #fff);
		border-top: 1px solid rgba(5, 56, 107, 0.12);
	}

	.orbit-tabbar__tab {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 3px;
		height: var(--orbit-tabbar-h);
		font-size: 12px;
		font-weight: 500;
		line-height: 1.2;
		text-decoration: none;
		color: #4a5568;
		-webkit-tap-highlight-color: transparent;
	}

	.orbit-tabbar__tab[aria-current="page"],
	.orbit-tabbar__tab[aria-expanded="true"] {
		color: var(--wp--preset--color--navy, #05386b);
		font-weight: 700;
	}

	.orbit-tabbar__tab[aria-current="page"] .orbit-tabbar__icon {
		fill: rgba(5, 56, 107, 0.14);
	}

	.orbit-tabbar__tab:focus-visible,
	.orbit-browse a:focus-visible,
	.orbit-browse__close:focus-visible {
		outline: 2px solid var(--wp--preset--color--navy, #05386b);
		outline-offset: -3px;
		border-radius: 8px;
	}

	.orbit-tabbar__count {
		position: absolute;
		top: 5px;
		left: calc(50% + 5px);
		display: flex;
		align-items: center;
		justify-content: center;
		min-width: 18px;
		height: 18px;
		padding: 0 4px;
		border-radius: 9px;
		background: var(--wp--preset--color--navy, #05386b);
		color: #fff;
		font-size: 11px;
		font-weight: 700;
		line-height: 1;
	}

	.orbit-tabbar__count[hidden] {
		display: none;
	}

	/* An on-screen keyboard would push the bar up over the form. */
	body.orbit-typing .orbit-tabbar {
		display: none;
	}

	body:has(.pl-filters-panel.pl-panel-open) .orbit-tabbar {
		display: none;
	}

	/* Browse sheet */
	.orbit-browse:not([hidden]) {
		position: fixed;
		top: 0;
		right: 0;
		bottom: var(--orbit-tabbar-space);
		left: 0;
		z-index: 10005;
		display: block;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 8px 20px 24px;
		background: var(--wp--preset--color--white, #fff);
		animation: orbit-browse-in 0.2s ease-out;
	}

	@keyframes orbit-browse-in {
		from {
			opacity: 0;
			transform: translateY(16px);
		}
	}

	.orbit-browse__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		min-height: 56px;
	}

	.orbit-browse__title {
		margin: 0;
		font-size: 24px;
		color: var(--wp--preset--color--navy, #05386b);
	}

	.orbit-browse__close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 48px;
		height: 48px;
		margin-right: -12px;
		padding: 0;
		border: 0;
		background: none;
		color: var(--wp--preset--color--navy, #05386b);
		cursor: pointer;
	}

	.orbit-browse__list {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.orbit-browse__list li {
		margin: 0;
		border-bottom: 1px solid rgba(5, 56, 107, 0.1);
	}

	.orbit-browse__list a {
		display: flex;
		align-items: center;
		min-height: 52px;
		font-size: 17px;
		font-weight: 600;
		text-decoration: none;
		color: var(--wp--preset--color--black, #000);
	}

	.orbit-browse__sell {
		display: flex;
		align-items: center;
		justify-content: center;
		min-height: 48px;
		margin-top: 20px;
		border: 1px solid var(--wp--preset--color--navy, #05386b);
		border-radius: 12px;
		font-weight: 600;
		text-decoration: none;
		color: var(--wp--preset--color--navy, #05386b);
	}

	html.orbit-browse-open {
		overflow: hidden;
	}

	/* The bar replaces these header controls; Store Manager and notifications stay. */
	.has-tabbar .site-header #toggle-wrap,
	.has-tabbar .header-utility-menu > .cart,
	.has-tabbar .header-utility-menu > .likes,
	.has-tabbar .header-utility-menu > .user,
	.has-tabbar #mobile-nav-menu {
		display: none;
	}

	.has-tabbar .site-header .wrap {
		grid-template-areas:
			"brand brand actions"
			"search search search";
	}

	/* Other bottom-docked elements sit above the bar. */
	.has-tabbar .ep-cta {
		bottom: var(--orbit-tabbar-space);
		padding-bottom: var(--wp--preset--spacing--tiny);
	}

	/* Raised, so its off-screen resting position is no longer off screen. */
	.has-tabbar .ep-cta:not(.is-visible),
	.has-tabbar #cmuk-likes-toast:not(.show) {
		visibility: hidden;
	}

	.has-tabbar #cmuk-likes-toast,
	.has-tabbar .cmuk-admin-floating-bar {
		bottom: calc(var(--orbit-tabbar-space) + 16px);
	}
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
	.orbit-browse:not([hidden]) {
		animation: none;
	}
}

@media print {
	.orbit-tabbar {
		display: none !important;
	}
}
