/*
 * RahkarTheme — Mobile bottom navigation styles.
 *
 * Loaded on every page where rahkar_bottom_nav_is_active_page() returns
 * true (i.e. everywhere except single-product). Bytes are gated by a
 * top-level media query so desktop visitors download — but never paint —
 * the rules. The download is ~3 KB minified; cheaper than splitting into
 * a separate "mobile-only" stylesheet (extra HTTP request) at this size.
 *
 * Animation model mirrors cart-modal.css:
 *   - Single `data-state` attribute drives all transitions.
 *   - transform + opacity only → GPU compositor, no layout invalidation.
 *   - Panel stays in DOM with `inert` when closed (no display:none).
 */

/* =====================================================================
 *  Visibility — show on ≤1024px only
 * ===================================================================== */
.rh-bnav,
.rh-bnav-cats,
.rh-bnav-empty,
.rh-bnav-account {
	display: none;
}

@media (max-width: 1024px) {

	/* Lift the page so the last bit of content isn't covered by the dock.
	   Uses safe-area-inset for iOS notch / home-indicator devices. */
	body {
		padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
	}

	/* ===================================================================
	 *  Dock
	 * =================================================================== */
	.rh-bnav {
		display: block;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 950;
		background: var(--wp--preset--color--base, #fff);
		border-top: 1px solid var(--wp--preset--color--border, #e2e4e9);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		box-shadow: 0 -2px 12px rgba(15, 17, 21, 0.06);
		contain: layout paint;
	}

	.rh-bnav__list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		align-items: stretch;
	}

	.rh-bnav__item {
		display: flex;
	}

	.rh-bnav__btn {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 4px;
		padding: 8px 6px 6px;
		background: transparent;
		border: 0;
		color: var(--wp--preset--color--text, #1a1d23);
		font-family: inherit;
		font-size: 11px;
		line-height: 1.4;
		text-decoration: none;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		transition: color 150ms ease;
	}
	.rh-bnav__btn:hover,
	.rh-bnav__btn:focus-visible {
		color: var(--wp--preset--color--primary, #0a66c2);
	}
	.rh-bnav__btn[aria-expanded="true"],
	.rh-bnav__btn.is-active {
		color: var(--wp--preset--color--primary, #0a66c2);
	}

	.rh-bnav__icon {
		position: relative;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
	}
	.rh-bnav__icon svg {
		width: 24px;
		height: 24px;
	}

	.rh-bnav__label {
		font-size: 11px;
		font-weight: 500;
		white-space: nowrap;
	}

	/* Cart badge.
	 *
	 * Matches the header cart badge (.rh-cart__count) in color, size, and
	 * the surrounding white ring so the three places the count appears
	 * (desktop header, mobile mini-header, bottom-nav dock) read as one
	 * design language. Kept as its own selector instead of reusing
	 * .rh-cart__count because the bottom-nav uses a different hide
	 * mechanism (`hidden` attribute vs `.is-empty` class) wired into
	 * bottom-nav.js — switching would force a JS+PHP refactor for a
	 * handful of duplicated property lines. */
	.rh-bnav__badge {
		position: absolute;
		top: -4px;
		left: -6px;
		min-width: 16px;
		height: 16px;
		padding: 0 4px;
		border-radius: 9999px;
		background: var(--wp--preset--color--primary, #0a66c2);
		color: #fff;
		font-size: 10px;
		font-weight: 700;
		line-height: 16px;
		text-align: center;
		box-shadow: 0 0 0 2px var(--wp--preset--color--base, #fff);
	}
	.rh-bnav__badge[hidden] {
		display: none;
	}

	/* ===================================================================
	 *  Categories panel (slide-up sheet)
	 * =================================================================== */
	.rh-bnav-cats {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1000;
		pointer-events: none;
	}
	.rh-bnav-cats[data-state="open"] {
		pointer-events: auto;
	}

	.rh-bnav-cats__backdrop {
		position: absolute;
		inset: 0;
		background: rgba(15, 17, 21, 0.45);
		opacity: 0;
		transition: opacity 200ms ease-out;
		cursor: pointer;
	}
	.rh-bnav-cats[data-state="open"] .rh-bnav-cats__backdrop {
		opacity: 1;
	}

	.rh-bnav-cats__panel {
		position: absolute;
		inset: 0;
		display: flex;
		flex-direction: column;
		background: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--text, #1a1d23);
		border-radius: 0;
		box-shadow: none;
		transform: translateY(100%);
		transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
		contain: layout paint;
		overflow: hidden;
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
	.rh-bnav-cats[data-state="open"] .rh-bnav-cats__panel {
		transform: translateY(0);
	}

	/* Search bar pinned above the title. Reuses the header search component
	   (.rh-search-wrap) verbatim — this wrapper only supplies the panel's
	   horizontal padding and keeps the bar from shrinking in the flex column.
	   The field's own resting dropdown stays hidden; on focus the shared JS
	   promotes it to the fullscreen mobile search (z-index 1100) over the
	   panel. */
	.rh-bnav-cats__search {
		flex: 0 0 auto;
		padding: 12px 18px;
		border-bottom: 1px solid var(--wp--preset--color--border, #e2e4e9);
	}
	.rh-bnav-cats__search .rh-search-wrap {
		max-width: none;
	}

	.rh-bnav-cats__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 14px 18px 10px;
		border-bottom: 1px solid var(--wp--preset--color--border, #e2e4e9);
	}
	.rh-bnav-cats__title {
		margin: 0;
		font-size: 15px;
		font-weight: 700;
		color: var(--wp--preset--color--primary, #0a66c2);
	}
	.rh-bnav-cats__close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		padding: 0;
		background: transparent;
		border: 0;
		color: var(--wp--preset--color--text-muted, #5b6271);
		border-radius: 9999px;
		cursor: pointer;
		transition: background 150ms ease, color 150ms ease;
	}
	.rh-bnav-cats__close:hover {
		background: var(--wp--preset--color--muted, #eceef1);
		color: var(--wp--preset--color--text, #1a1d23);
	}

	/* Body — right rail + panes (RTL: rail on the right) */
	.rh-bnav-cats__body {
		flex: 1;
		display: grid;
		grid-template-columns: 96px 1fr;
		min-height: 0;
		overflow: hidden;
	}

	/* Flat variant — no rail, single scrollable grid. Used when no top-
	   level item has children (PHP picks this layout). */
	.rh-bnav-cats__body--flat {
		grid-template-columns: 1fr;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 16px;
	}
	.rh-bnav-cats__grid--flat {
		grid-template-columns: repeat(3, 1fr);
		gap: 18px 8px;
	}

	/* Rail */
	.rh-bnav-cats__rail {
		list-style: none;
		margin: 0;
		padding: 6px 0;
		background: var(--wp--preset--color--surface, #f7f7f8);
		overflow-y: auto;
		overscroll-behavior: contain;
		border-inline-start: 1px solid var(--wp--preset--color--border, #e2e4e9);
	}
	.rh-bnav-cats__rail-btn {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 6px;
		width: 100%;
		padding: 10px 6px;
		background: transparent;
		border: 0;
		color: var(--wp--preset--color--text-muted, #5b6271);
		font-family: inherit;
		font-size: 11.5px;
		line-height: 1.3;
		text-align: center;
		cursor: pointer;
		border-inline-end: 3px solid transparent;
		transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
	}
	.rh-bnav-cats__rail-btn:hover {
		background: rgba(0, 0, 0, 0.02);
	}
	.rh-bnav-cats__rail-btn.is-active {
		background: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--primary, #0a66c2);
		border-inline-end-color: var(--wp--preset--color--primary, #0a66c2);
		font-weight: 600;
	}
	.rh-bnav-cats__rail-img {
		width: 48px;
		height: 48px;
		border-radius: 9999px;
		object-fit: cover;
		background: var(--wp--preset--color--muted, #eceef1);
	}
	.rh-bnav-cats__rail-label {
		display: block;
		max-width: 80px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* Panes */
	.rh-bnav-cats__panes {
		position: relative;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 14px 16px 24px;
	}
	.rh-bnav-cats__pane {
		display: none;
	}
	.rh-bnav-cats__pane.is-active {
		display: block;
	}

	.rh-bnav-cats__all {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 4px;
		padding: 8px 4px;
		margin: 0 0 12px;
		font-size: 13px;
		font-weight: 600;
		color: var(--wp--preset--color--primary, #0a66c2);
		text-decoration: none;
		border-bottom: 1px solid var(--wp--preset--color--border, #e2e4e9);
	}
	.rh-bnav-cats__all:hover {
		color: var(--wp--preset--color--primary-dark, #074a8d);
	}
	.rh-bnav-cats__all svg {
		flex: 0 0 auto;
	}

	.rh-bnav-cats__pane-title {
		margin: 0 0 12px;
		font-size: 13px;
		font-weight: 700;
		color: var(--wp--preset--color--text, #1a1d23);
		text-align: center;
	}

	.rh-bnav-cats__grid {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 14px 6px;
	}

	.rh-bnav-cats__cell-link {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 6px;
		text-decoration: none;
		color: var(--wp--preset--color--text, #1a1d23);
	}
	.rh-bnav-cats__cell-img {
		width: 72px;
		height: 72px;
		border-radius: 12px;
		object-fit: cover;
		background: var(--wp--preset--color--surface, #f7f7f8);
		display: flex;
		align-items: center;
		justify-content: center;
		color: var(--wp--preset--color--text-muted, #5b6271);
	}
	.rh-bnav-cats__cell-label {
		font-size: 12px;
		line-height: 1.4;
		text-align: center;
		max-width: 88px;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.rh-bnav-cats__empty {
		padding: 32px 20px;
		text-align: center;
		color: var(--wp--preset--color--text-muted, #5b6271);
	}
	.rh-bnav-cats__empty-link {
		display: inline-block;
		margin-top: 10px;
		color: var(--wp--preset--color--primary, #0a66c2);
		font-weight: 600;
		text-decoration: none;
	}

	/* ===================================================================
	 *  Cart-empty sheet
	 * =================================================================== */
	.rh-bnav-empty {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1010;
		pointer-events: none;
	}
	.rh-bnav-empty[data-state="open"] {
		pointer-events: auto;
	}
	.rh-bnav-empty__backdrop {
		position: absolute;
		inset: 0;
		background: rgba(15, 17, 21, 0.45);
		opacity: 0;
		transition: opacity 200ms ease-out;
		cursor: pointer;
	}
	.rh-bnav-empty[data-state="open"] .rh-bnav-empty__backdrop {
		opacity: 1;
	}
	.rh-bnav-empty__panel {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 8px;
		padding: 18px 22px calc(22px + env(safe-area-inset-bottom, 0px));
		background: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--text, #1a1d23);
		border-radius: 18px 18px 0 0;
		box-shadow: 0 -8px 32px rgba(15, 17, 21, 0.18);
		transform: translateY(100%);
		transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
	}
	.rh-bnav-empty[data-state="open"] .rh-bnav-empty__panel {
		transform: translateY(0);
	}
	.rh-bnav-empty__handle {
		width: 36px;
		height: 4px;
		border-radius: 2px;
		background: var(--wp--preset--color--border, #e2e4e9);
		margin: 0 0 8px;
	}
	.rh-bnav-empty__icon {
		color: var(--wp--preset--color--text-muted, #5b6271);
		margin: 4px 0 4px;
	}
	.rh-bnav-empty__title {
		margin: 0;
		font-size: 16px;
		font-weight: 700;
	}
	.rh-bnav-empty__text {
		margin: 0;
		font-size: 13px;
		color: var(--wp--preset--color--text-muted, #5b6271);
		text-align: center;
	}
	.rh-bnav-empty__actions {
		width: 100%;
		display: flex;
		gap: 8px;
		margin-top: 14px;
	}
	.rh-bnav-empty__btn {
		flex: 1;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 44px;
		padding: 0 16px;
		border: 0;
		border-radius: 10px;
		font-family: inherit;
		font-size: 14px;
		font-weight: 600;
		text-decoration: none;
		cursor: pointer;
	}
	.rh-bnav-empty__btn--primary {
		background: var(--wp--preset--color--primary, #0a66c2);
		color: #fff;
	}
	.rh-bnav-empty__btn--primary:hover {
		background: var(--wp--preset--color--primary-dark, #074a8d);
		color: #fff;
	}

	/* ===================================================================
	 *  Account-menu sheet (logged-in)
	 *  Slide-up bottom sheet; same data-state mechanics as the others.
	 * =================================================================== */
	.rh-bnav-account {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1010;
		pointer-events: none;
	}
	.rh-bnav-account[data-state="open"] {
		pointer-events: auto;
	}
	.rh-bnav-account__backdrop {
		position: absolute;
		inset: 0;
		background: rgba(15, 17, 21, 0.45);
		opacity: 0;
		transition: opacity 200ms ease-out;
		cursor: pointer;
	}
	.rh-bnav-account[data-state="open"] .rh-bnav-account__backdrop {
		opacity: 1;
	}
	.rh-bnav-account__panel {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		max-height: 82vh;
		padding-bottom: env(safe-area-inset-bottom, 0px);
		background: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--text, #1a1d23);
		border-radius: 18px 18px 0 0;
		box-shadow: 0 -8px 32px rgba(15, 17, 21, 0.18);
		transform: translateY(100%);
		transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
	}
	.rh-bnav-account[data-state="open"] .rh-bnav-account__panel {
		transform: translateY(0);
	}
	.rh-bnav-account__handle {
		flex: 0 0 auto;
		width: 36px;
		height: 4px;
		border-radius: 2px;
		background: var(--wp--preset--color--border, #e2e4e9);
		margin: 8px auto 4px;
	}
	.rh-bnav-account__head {
		flex: 0 0 auto;
		display: flex;
		align-items: center;
		gap: 10px;
		padding: 8px 18px 12px;
		border-bottom: 1px solid var(--wp--preset--color--border, #e2e4e9);
	}
	.rh-bnav-account__avatar {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		border-radius: 50%;
		background: var(--wp--preset--color--surface, #f7f7f8);
		color: var(--wp--preset--color--primary, #0a66c2);
		flex: 0 0 auto;
	}
	.rh-bnav-account__name {
		flex: 1 1 auto;
		font-size: 15px;
		font-weight: 700;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.rh-bnav-account__close {
		flex: 0 0 auto;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 34px;
		height: 34px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: var(--wp--preset--color--surface, #f7f7f8);
		color: var(--wp--preset--color--text-muted, #5b6271);
		cursor: pointer;
	}
	.rh-bnav-account__nav {
		flex: 1 1 auto;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
	.rh-bnav-account__list {
		list-style: none;
		margin: 0;
		padding: 6px 0 10px;
	}
	.rh-bnav-account__link {
		display: flex;
		align-items: center;
		gap: 12px;
		padding: 13px 18px;
		color: var(--wp--preset--color--text, #1a1d23);
		text-decoration: none;
	}
	.rh-bnav-account__link:active {
		background: var(--wp--preset--color--surface, #f7f7f8);
	}
	.rh-bnav-account__icon {
		display: inline-flex;
		flex: 0 0 auto;
		color: var(--wp--preset--color--primary, #0a66c2);
	}
	.rh-bnav-account__icon svg {
		width: 22px;
		height: 22px;
	}
	.rh-bnav-account__label {
		flex: 1 1 auto;
		font-size: 14px;
		font-weight: 500;
	}
	.rh-bnav-account__badge {
		flex: 0 0 auto;
		min-width: 20px;
		height: 20px;
		padding: 0 6px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		border-radius: 10px;
		background: var(--wp--preset--color--accent, #e23744);
		color: #fff;
		font-size: 11px;
		font-weight: 700;
	}
	/* Chevron points to the inline-start in RTL (toward the row's leading
	   edge), matching the my-account list. */
	.rh-bnav-account__chev {
		flex: 0 0 auto;
		color: var(--wp--preset--color--text-muted, #9aa0ab);
	}
	.rh-bnav-account__item.is-logout {
		border-top: 1px solid var(--wp--preset--color--border, #e2e4e9);
		margin-top: 6px;
	}
	.rh-bnav-account__item.is-logout .rh-bnav-account__icon,
	.rh-bnav-account__item.is-logout .rh-bnav-account__label {
		color: var(--wp--preset--color--accent, #e23744);
	}

	/* When the dock is open, prevent body scroll behind it. JS toggles
	   .rh-bnav-lock on <html>. */
	html.rh-bnav-lock,
	html.rh-bnav-lock body {
		overflow: hidden;
		touch-action: none;
	}
}

/* Reduce-motion: skip slide animations */
@media (prefers-reduced-motion: reduce) {
	.rh-bnav-cats__panel,
	.rh-bnav-cats__backdrop,
	.rh-bnav-empty__panel,
	.rh-bnav-empty__backdrop,
	.rh-bnav-account__panel,
	.rh-bnav-account__backdrop,
	.rh-bnav__btn {
		transition: none !important;
	}
}
