/*
 * Phone tab bar (app navigation). Markup: Armenius_Engine_Pwa_Tabbar::render().
 *
 * Up to 760 px only. pwa-tabbar.js toggles on <html>:
 *   .armenius-tabbar-on    the bar is on this page (also set inline right after the markup);
 *   .armenius-tabbar-away  browser tab scrolled down: the bar slides away;
 *   .armenius-tabbar-kb    a text field is focused or search results are open: the bar hides.
 *
 * Stacking: drawers 650/660 (admin bar: 100050/100060) stop ABOVE the bar instead of
 * covering it; bar 670; push prompt raised to 700 like the install banner. In the
 * installed app #page is a stacking context at z-index 2 (pwa-appnav.css) and the bar
 * sits outside it, so it stays above the page there too.
 *
 * Bottom-fixed pieces sit above the bar by --armenius-tabbar-space and stay there while
 * the bar slides away: live chat button and panel, cookie notice, staff bug-report toast.
 *
 * Nothing may change while the page scrolls except the bar's own transform: a custom
 * property changed on :root restyles the whole page (24 ms on a category page in 1.145.0),
 * which made the slide stutter mid-scroll on phones.
 */

.armenius-tabbar {
	display: none;
}

@media (max-width: 760px) {
	:root.armenius-tabbar-on {
		--armenius-tabbar-h: 56px;
		/* Tabs plus the 1 px top border plus the home-indicator inset. */
		--armenius-tabbar-space: calc(var(--armenius-tabbar-h) + 1px + env(safe-area-inset-bottom, 0px));
		/* Kept for anything that used it in 1.145.0; constant now. */
		--armenius-tabbar-offset: var(--armenius-tabbar-space);
	}

	.armenius-tabbar {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 670;
		display: grid;
		grid-template-columns: repeat(5, minmax(0, 1fr));
		margin: 0;
		padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
		background: #fff;
		border-top: 1px solid var(--color-border, #ddd);
		box-shadow: 0 -2px 10px rgb(0 0 0 / 0.05);
		font-family: var(--font-body, "Open Sans", system-ui, sans-serif);
		transform: translate3d(0, 0, 0);
		visibility: visible;
		transition:
			transform 0.22s ease,
			visibility 0s linear 0s;
		-webkit-tap-highlight-color: transparent;
	}

	:root.armenius-tabbar-away .armenius-tabbar {
		transform: translate3d(0, calc(100% + 12px), 0);
		visibility: hidden;
		transition:
			transform 0.22s ease,
			visibility 0s linear 0.22s;
	}

	/* Keyboard up or results open: gone at once, so it never rides on the keyboard. */
	:root.armenius-tabbar-kb .armenius-tabbar {
		transform: translate3d(0, calc(100% + 12px), 0);
		visibility: hidden;
		transition: none;
	}

	.armenius-tabbar .armenius-tabbar__tab {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 2px;
		width: 100%;
		min-width: 0;
		height: var(--armenius-tabbar-h, 56px);
		margin: 0;
		padding: 0 2px;
		color: #6b6b6b;
		font: 600 11px/1.15 var(--font-body, "Open Sans", system-ui, sans-serif);
		letter-spacing: 0.01em;
		text-decoration: none;
		white-space: nowrap;
		background: none;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		cursor: pointer;
		-webkit-appearance: none;
		appearance: none;
		touch-action: manipulation;
		-webkit-user-select: none;
		user-select: none;
	}

	.armenius-tabbar .armenius-tabbar__tab:hover,
	.armenius-tabbar .armenius-tabbar__tab:focus,
	.armenius-tabbar .armenius-tabbar__tab:visited,
	.armenius-tabbar .armenius-tabbar__tab:active {
		color: #6b6b6b;
		text-decoration: none;
		background: none;
		box-shadow: none;
	}

	.armenius-tabbar .armenius-tabbar__tab:focus-visible {
		outline: 2px solid var(--color-dark-2, #2e2e2e);
		outline-offset: -4px;
	}

	.armenius-tabbar .armenius-tabbar__tab.is-active,
	.armenius-tabbar .armenius-tabbar__tab.is-active:hover,
	.armenius-tabbar .armenius-tabbar__tab.is-active:focus {
		color: var(--color-dark-2, #2e2e2e);
		font-weight: 700;
	}

	/* 3 px accent line over the active tab (square, like the rest of the theme). */
	.armenius-tabbar .armenius-tabbar__tab.is-active::before {
		content: "";
		position: absolute;
		top: -1px;
		left: 26%;
		right: 26%;
		height: 3px;
		background: var(--color-accent, #fc0);
	}

	.armenius-tabbar__icon {
		position: relative;
		display: block;
		flex: none;
		width: 26px;
		height: 26px;
	}

	.armenius-tabbar .armenius-tabbar__svg {
		display: block;
		width: 26px;
		height: 26px;
		fill: currentColor;
	}

	.armenius-tabbar__label {
		display: block;
		max-width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	/* Cart count: same class as the header badge, so cart fragments refresh it too. */
	.armenius-tabbar .store-header__cart-badge {
		position: absolute;
		top: -4px;
		left: 18px;
		right: auto;
		display: block;
		min-width: 18px;
		height: 18px;
		padding: 0 5px;
		border-radius: 9px;
		background: var(--color-accent, #fc0);
		color: var(--color-dark-2, #2e2e2e);
		font: 700 11px/18px var(--font-body, "Open Sans", system-ui, sans-serif);
		letter-spacing: 0;
		text-align: center;
		box-shadow: 0 0 0 2px #fff;
		box-sizing: border-box;
	}

	.armenius-tabbar__tab[data-count="0"] .store-header__cart-badge {
		display: none;
	}

	/* Page end clears the bar; the footer colour runs behind it. */
	:root.armenius-tabbar-on .site-footer {
		padding-bottom: var(--armenius-tabbar-space);
	}

	/* Drawers stop above the bar, so it stays tappable while they are open. */
	:root.armenius-tabbar-on .store-header__cats-drawer,
	:root.armenius-tabbar-on .store-header__cats-drawer-backdrop,
	:root.armenius-tabbar-on .store-header__cart-drawer,
	:root.armenius-tabbar-on .store-header__cart-drawer-backdrop,
	:root.armenius-tabbar-on .armenius-archive__leaf-filters-drawer,
	:root.armenius-tabbar-on .armenius-archive__leaf-filters-drawer-backdrop {
		bottom: var(--armenius-tabbar-space);
		min-height: 0;
	}

	/* Bottom sheets that belong above the bar. */
	:root.armenius-tabbar-on .armenius-push-prompt {
		z-index: 700;
	}

	/* Bottom-fixed pieces sit above the bar and do not move when it slides. */
	:root.armenius-tabbar-on body .armenius-livechat {
		bottom: calc(12px + var(--armenius-tabbar-space));
	}

	:root.armenius-tabbar-on body .armenius-livechat__panel {
		bottom: calc(84px + var(--armenius-tabbar-space));
	}

	:root.armenius-tabbar-on .armenius-cookie-banner {
		bottom: calc(10px + var(--armenius-tabbar-space));
	}

	:root.armenius-tabbar-on #armenius-bug-toast {
		bottom: calc(16px + var(--armenius-tabbar-space));
	}
}

/* 320 px phones: "Κατηγορίες" needs 62 of the 64 px a tab gets. */
@media (max-width: 360px) {
	.armenius-tabbar .armenius-tabbar__tab {
		padding: 0;
		font-size: 10.5px;
		letter-spacing: -0.02em;
	}
}

@media (prefers-reduced-motion: reduce) {
	.armenius-tabbar,
	:root.armenius-tabbar-away .armenius-tabbar {
		transition: none;
	}
}

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