/**
 * The mobile and tablet menu.
 *
 * One button, one panel. Bricks' own toggles are hidden below the breakpoint —
 * the header nests two nav elements, so it rendered two hamburgers and left
 * half the navigation behind the inner one.
 */

/* ==========================================================================
   Below the breakpoint
   ========================================================================== */

/* ==========================================================================
   The button
   ========================================================================== */

.gcn-mnav__button {
	position: absolute;
	top: 50%;
	right: var(--gcn-space-4);
	z-index: 30;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	background: var(--gcn-surface);
	border: 1px solid var(--gcn-rule);
	border-radius: var(--gcn-radius-md);
	transform: translateY(-50%);
	cursor: pointer;
}

/* In the header's own row, the button flows beside the avatar. */
.gcn-mnav__button--inline {
	position: static;
	margin-left: var(--gcn-space-2);
	transform: none;
}

.gcn-mnav__button:focus-visible {
	outline: none;
	box-shadow: var(--gcn-ring);
}

/* Three bars, drawn rather than typed. */
.gcn-mnav__bars,
.gcn-mnav__bars::before,
.gcn-mnav__bars::after {
	display: block;
	width: 1.15rem;
	height: 2px;
	background: var(--gcn-text);
	border-radius: 2px;
}

.gcn-mnav__bars {
	position: relative;
}

.gcn-mnav__bars::before,
.gcn-mnav__bars::after {
	content: "";
	position: absolute;
	left: 0;
}

.gcn-mnav__bars::before { top: -6px; }
.gcn-mnav__bars::after  { top: 6px; }

/* ==========================================================================
   The panel
   ========================================================================== */

.gcn-mnav__backdrop {
	position: fixed;
	inset: 0;
	z-index: 9998;
	background: hsl(212 40% 12% / 0.5);
	opacity: 0;
	visibility: hidden;
	transition:
		opacity var(--gcn-duration) var(--gcn-ease),
		visibility var(--gcn-duration) var(--gcn-ease);
}

.gcn-mnav__backdrop.is-open {
	opacity: 1;
	visibility: visible;
}

.gcn-mnav {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 9999;
	width: min(360px, 88vw);
	padding: var(--gcn-space-6) var(--gcn-space-5) var(--gcn-space-10);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--gcn-surface);
	box-shadow: -12px 0 40px hsl(212 40% 20% / 0.18);
	transform: translateX(100%);
	transition: transform var(--gcn-duration) var(--gcn-ease);
}

.gcn-mnav.is-open {
	transform: none;
}

/* The admin bar is fixed on a phone too; the panel starts below it. */
.admin-bar .gcn-mnav {
	top: 46px;
}

/* The page behind does not scroll while the panel is open. */
.gcn-mnav-open,
.gcn-mnav-open body {
	overflow: hidden;
}

.gcn-mnav__close {
	position: absolute;
	top: var(--gcn-space-3);
	right: var(--gcn-space-3);
	width: 2.5rem;
	height: 2.5rem;
	font-size: 1.7rem;
	line-height: 1;
	color: var(--gcn-text-muted);
	background: none;
	border: 0;
	border-radius: var(--gcn-radius-sm);
	cursor: pointer;
}

.gcn-mnav__close:hover,
.gcn-mnav__close:focus-visible {
	color: var(--gcn-text);
	background: var(--gcn-surface-sunken);
	outline: none;
}

/* ==========================================================================
   The list
   ========================================================================== */

.gcn-mnav__list {
	margin: var(--gcn-space-8) 0 0;
	padding: 0;
	list-style: none;
}

.gcn-mnav__item + .gcn-mnav__item {
	border-top: 1px solid var(--gcn-rule);
}

/* Rows are 48px so they can be hit with a thumb. */
.gcn-mnav__link,
.gcn-mnav__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gcn-space-3);
	width: 100%;
	min-height: 48px;
	padding: var(--gcn-space-3) var(--gcn-space-2);
	font-family: inherit;
	font-size: var(--gcn-text-md);
	font-weight: var(--gcn-weight-medium);
	color: var(--gcn-text);
	text-align: left;
	text-decoration: none;
	background: none;
	border: 0;
	cursor: pointer;
}

.gcn-mnav__link:hover,
.gcn-mnav__toggle:hover {
	color: var(--gcn-brand-strong);
}

.gcn-mnav__chev {
	flex: 0 0 auto;
	width: 0.55rem;
	height: 0.55rem;
	border-right: 2px solid var(--gcn-text-faint);
	border-bottom: 2px solid var(--gcn-text-faint);
	transform: rotate(45deg);
	transition: transform var(--gcn-duration) var(--gcn-ease);
}

.gcn-mnav__item.is-open .gcn-mnav__chev {
	transform: rotate(-135deg);
}

.gcn-mnav__sub {
	margin: 0 0 var(--gcn-space-3);
	padding: 0 0 0 var(--gcn-space-3);
	list-style: none;
	border-left: 2px solid var(--gcn-brand-border);
}

.gcn-mnav__sublink {
	display: block;
	min-height: 44px;
	padding: var(--gcn-space-2) var(--gcn-space-3);
	font-size: var(--gcn-text-sm);
	line-height: 1.5;
	color: var(--gcn-text-soft);
	text-decoration: none;
}

.gcn-mnav__sublink:hover,
.gcn-mnav__sublink:focus-visible {
	color: var(--gcn-brand-strong);
	background: var(--gcn-brand-soft);
	border-radius: var(--gcn-radius-sm);
}

/* ==========================================================================
   Add listing, and the account
   ========================================================================== */

.gcn-mnav__extras {
	margin-top: var(--gcn-space-6);
	padding-top: var(--gcn-space-5);
	border-top: 1px solid var(--gcn-rule);
}

.gcn-mnav__cta,
.gcn-mnav__signin {
	display: block;
	padding: 0.85em 1.2em;
	font-size: var(--gcn-text-md);
	font-weight: var(--gcn-weight-semibold);
	color: var(--gcn-brand-contrast);
	text-align: center;
	text-decoration: none;
	background: var(--gcn-brand);
	border-radius: var(--gcn-radius-md);
}

.gcn-mnav__cta:hover,
.gcn-mnav__signin:hover {
	color: var(--gcn-brand-contrast);
	background: var(--gcn-brand-strong);
}

.gcn-mnav__account {
	margin: var(--gcn-space-4) 0 0;
	padding: 0;
	list-style: none;
}

/* ==========================================================================
   Breakpoints

   Last in the file on purpose: these override the base rules above, and a
   media query carries no extra specificity to do it with.
   ========================================================================== */

@media (max-width: 991px) {

	/* Bricks' own toggles, and the panels they open. */
	.gcn-mnav-on #brx-header .brxe-toggle,
	.gcn-mnav-on #brx-header .brx-toggle-div {
		display: none !important;
	}

	/*
	 * The header keeps the logo, the avatar and nothing else: the Add listing
	 * button was overlapping the avatar on a phone, and it is in the panel.
	 */
	.gcn-mnav-on #brx-header .gcn-addmenu,
	.gcn-mnav-on #brx-header a[href*="/add-a-listing"] {
		display: none !important;
	}

	.gcn-mnav__button {
		display: inline-flex;
	}

	/*
	 * The desktop links. Everything except the row of header actions — the
	 * location switcher, the avatar, the menu button — which is the item the
	 * button lives in, or one holding the header's action wrapper.
	 */
	.gcn-mnav-on #brx-header .brx-nav-nested-items > li:not( .gcn-mnav-host ):not( :has( .nav-links-wrapper ) ) {
		display: none !important;
	}

	/*
	 * Bricks stacks this wrapper on a phone, which is right when it holds a
	 * column of links and wrong now that it holds the avatar and the menu
	 * button: those belong side by side on one row.
	 */
	.gcn-mnav-on #brx-header .nav-links-wrapper {
		flex-direction: row;
		align-items: center;
		gap: var(--gcn-space-2);
	}
}

@media (min-width: 992px) {

	.gcn-mnav__button,
	.gcn-mnav,
	.gcn-mnav__backdrop {
		display: none !important;
	}
}
