/**
 * Platform navigation.
 *
 * The menu is only platforms, so it shows marks instead of words: the name
 * slides open next to its mark for the platform you are on and for whichever
 * one is under the cursor, and folds away again when you leave.
 *
 * On phones the same marks ride in a scrollable strip on the header bar, in
 * whatever room is left between the toggle and the cart. The toggle stays: the
 * list it opens spells the names out, which the strip deliberately does not.
 */

.sgds-platform-item > a {
	display: flex;
	align-items: center;
}

.sgds-platform-icon {
	display: block;
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
}

.sgds-platform-icon svg {
	display: block;
	width: 100%;
	height: 100%;
	fill: currentColor;
}

/**
 * The 0fr/1fr grid animates to exactly the width of the word — a max-width
 * guess would either clip a long name or coast through empty space at the end
 * of the transition. The name never leaves the document, so it is read out
 * whether or not it is currently on screen.
 */
.sgds-platform-name {
	display: grid;
	grid-template-columns: 0fr;
	margin-left: 0;
	opacity: 0;
	transition:
		grid-template-columns 300ms cubic-bezier( 0.4, 0, 0.2, 1 ),
		margin-left 300ms cubic-bezier( 0.4, 0, 0.2, 1 ),
		opacity 200ms ease;
}

.sgds-platform-name > span {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
}

.sgds-platform-item:hover > a .sgds-platform-name,
.sgds-platform-item:focus-within > a .sgds-platform-name,
.sgds-platform-item.current-menu-item > a .sgds-platform-name {
	grid-template-columns: 1fr;
	margin-left: 8px;
	opacity: 1;
}

.sgds-platform-item.current-menu-item > a {
	font-weight: 600;
}

/* A mark needs far less room around it than a word did. */
#site-navigation .sgds-platform-item > a {
	padding-left: 11px;
	padding-right: 11px;
}

@media ( prefers-reduced-motion: reduce ) {

	.sgds-platform-name {
		transition: none;
	}
}

@media ( max-width: 790px ) {

	/*
	 * Whatever the logo, the toggle and the cart leave — and it scrolls. The
	 * basis is zero, not auto: ten marks are wider than a phone, and an auto
	 * basis would size the strip to that and push the cart onto its own line.
	 */
	#sgds-platform-strip {
		flex: 1 1 0%;
		min-width: 0;
	}

	/* One line: toggle, the strip, and the cart against the right edge. */
	#mobile-header .menu-bar-items {
		flex: 0 0 auto;
		margin-left: auto;
	}

	#sgds-platform-strip > ul {
		display: flex;
		flex-wrap: nowrap;
		margin: 0;
		padding: 0;
		list-style: none;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	#sgds-platform-strip > ul::-webkit-scrollbar {
		display: none;
	}

	#sgds-platform-strip li {
		flex: 0 0 auto;
	}

	/*
	 * The mark is 22px, so without a minimum the whole tap target was 22px
	 * tall on a 74px bar — fine for a cursor, too small for a thumb, and the
	 * one thing on this bar being tapped over and over. The height is on the
	 * link rather than the icon so the marks stay where they are.
	 */
	#sgds-platform-strip a {
		display: flex;
		align-items: center;
		min-height: 44px;
		padding: 0 9px;
		line-height: inherit;
		color: inherit;
		text-decoration: none;
	}

	/* The word is what the toggle's list is for; here the mark stands alone. */
	#sgds-platform-strip .sgds-platform-name {
		display: none;
	}

	#sgds-platform-strip .sgds-platform-icon {
		width: 22px;
		height: 22px;
	}

	/*
	 * The house keeps a little air after it, but no rule: a line drawn here
	 * sits inside the scroller and slides out of sight with the first swipe.
	 * The only divider on this bar is the cart's, which cannot scroll away.
	 */
	#sgds-platform-strip .sgds-home-item {
		margin-right: 5px;
		padding-right: 4px;
	}

	#sgds-platform-strip .current-menu-item a {
		opacity: 1;
	}

	#sgds-platform-strip li:not( .current-menu-item ) a {
		opacity: 0.6;
	}

	/*
	 * The toggle keeps only its bars, but it still has to be hittable with a
	 * thumb: 18px either side of a 15px glyph makes a target around 50px
	 * wide, which is past the 44px everyone quotes. The strip gives up those
	 * few pixels and scrolls a little sooner, which costs it nothing.
	 */
	#mobile-header .menu-toggle {
		padding: 0 18px;
	}

	/* Ten names stacked at full navigation height is most of a phone screen. */
	#mobile-header .main-nav > ul > li > a {
		line-height: 44px;
	}

	/*
	 * The cart closes the bar, and GeneratePress was sizing it off the bar's
	 * 15px font: a 1em box holding a 25-unit viewBox whose artwork stops at
	 * 19.5, which put the glyph on screen at under 12px next to 22px marks.
	 * Sizing the box in pixels puts the two on the same optical footing —
	 * 25px of box draws 21.8 x 19.5 of cart against 22 x 22 of platform mark.
	 */
	#mobile-header .menu-bar-items .gp-icon.shopping-cart svg {
		width: 25px;
		height: 25px;
		top: 0;
	}

	/*
	 * The mark is an inline box on the anchor's 74px line, so it sits on the
	 * baseline and rides high; GP's .125em nudge is the correction, and it is
	 * sized for a 15px icon, not this one. Aligning to the middle of the line
	 * instead lands it within a pixel of the strip whatever size it is, and
	 * leaves the anchor's own height — the tap target — alone.
	 *
	 * The marks dim to 0.6 unless you are on them; the cart is an action, not
	 * a place, so it stays at full strength.
	 */
	#mobile-header .menu-bar-items .gp-icon.shopping-cart {
		vertical-align: middle;
		opacity: 1;
	}

	/*
	 * The bar's one divider: the cart is not a platform, and the strip scrolls
	 * right up against it. It lives here rather than inside the strip because
	 * the strip's own content moves — a rule drawn between the marks is gone
	 * as soon as you swipe, while this one is always on screen. Drawn as a
	 * pseudo-element so it keeps the height of an icon rather than the height
	 * of the bar, and so the auto margin that holds the cart to the right edge
	 * is left alone.
	 */
	/*
	 * No padding of its own: the divider is drawn at this edge and the link's
	 * own padding is what holds the glyph off it, so the two cannot drift.
	 */
	#mobile-header .menu-bar-items {
		position: relative;
		padding-left: 0;
	}

	/*
	 * GeneratePress gives the cart 20px either side, which left a hole between
	 * the divider and the glyph. 13px closes most of it while keeping the tap
	 * target the same width as the toggle at the other end of the bar — both
	 * come to roughly 50px, which is what a thumb needs.
	 */
	#mobile-header .menu-bar-items .menu-bar-item > a {
		position: relative;
		padding-left: 13px;
		padding-right: 13px;
	}

	/*
	 * The count rides on the cart's shoulder rather than sitting beside it:
	 * inline, a three-digit quantity is wider than the icon and reads as a
	 * price. A pill, not the theme's fixed circle — "500" does not fit in
	 * 1.7em — and a white ring so it stays legible over the glyph.
	 */
	#mobile-header .menu-bar-items .cart-contents > span.number-of-items {
		position: absolute;
		top: calc( 50% - 21px );
		right: 9px;
		width: auto;
		min-width: 1.5em;
		height: auto;
		margin: 0;
		padding: 0 5px;
		border-radius: 999px;
		box-shadow: 0 0 0 2px #fff;
		font-size: 10px;
		line-height: 1.6;
	}

	#mobile-header .menu-bar-items::before {
		content: "";
		position: absolute;
		left: 0;
		top: 50%;
		width: 1px;
		height: 24px;
		transform: translateY( -50% );
		background: rgba( 0, 0, 0, 0.12 );
	}
}
