/**
 * Topbar — a band of one line against the header.
 *
 * Not `.myc-topbar`. That is the site's own header, three rows of it, built by
 * the theme; this is a block a shopkeeper places in content. They are
 * neighbours on screen and nothing else, and the two class names are one letter
 * of prefix apart, so it is worth saying once here.
 */
.ps-topbar {
	position: relative;
	isolation: isolate;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	min-height: 44px;
	padding: var(--ps-space-2) var(--ps-space-5);
	background: var(--ps-topbar-bg, var(--ps-color-brand-600));
	color: var(--ps-topbar-text, var(--ps-color-text));
	text-align: center;

	/*
	 * Out to both edges of the page, from inside one that is centred at 1440px
	 * with 24px of padding.
	 *
	 * Built on `--ps-viewport`, measured by catalog-interface.js, rather than on
	 * `100vw`. The unit is meant to include the vertical scrollbar — which would
	 * put this band fifteen pixels past the document on Windows and scroll the
	 * whole site sideways — but measured in Chrome on the shop's own machine it
	 * came back excluding it. Either way one assumption is wrong, and
	 * `documentElement.clientWidth` is the page in both.
	 *
	 * `100vw` stays as the fallback for the frame before the script runs, where
	 * being a few pixels out costs nothing.
	 */
	width: var(--ps-viewport, 100vw);
	margin-inline: calc(50% - var(--ps-viewport, 100vw) / 2);
}

/*
 * Flush against the header. The page pads 64px above its first block and the
 * section inside it adds 8; a band whose whole purpose is to sit under the
 * header cannot have either, so a page that opens with one stops padding.
 *
 * `:has()` because the padding belongs to the page and the decision belongs to
 * the block. Where it is unsupported the band sits lower — further from the
 * header than intended, and nothing else.
 */
.myc-page:has(> :first-child > .ps-topbar:first-child),
.myc-page:has(> .ps-topbar:first-child) {
	padding-top: 0;
}

.myc-featured-section:has(> .ps-topbar:first-child) {
	padding-top: 0;
}

.ps-topbar__image {
	position: absolute;
	inset: 0;
	z-index: -1;
	background-image: var(--ps-cover-image);
	background-position: var(--ps-cover-focus, 50% 50%);
	background-size: cover;
	background-repeat: no-repeat;
}

.ps-topbar__image::after {
	position: absolute;
	inset: 0;
	background: rgb(8 16 28 / var(--ps-cover-dim, 45%));
	content: "";
}

.ps-topbar__text {
	max-width: var(--ps-content-discovery, 1360px);
	margin: 0;
	color: inherit;
	font-family: var(--ps-font-display);
	font-size: clamp(12px, 1.1vw, 14px);
	font-weight: 700;
	letter-spacing: .08em;
	line-height: 1.3;
	text-transform: uppercase;
}

a.ps-topbar__text {
	text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
	a.ps-topbar__text:hover {
		text-decoration: underline;
	}
}

.myc-app-body a.ps-topbar__text:focus-visible {
	outline: 2px solid currentcolor;
	outline-offset: 3px;
}

/*
 * Fixed under the header on desktop, and gone with the page below it.
 *
 * A sticky band is a second row of chrome, which a laptop has the height to
 * spare for and a phone does not: there the header already keeps three rows on
 * screen, and a fourth would take a fifth of a small screen for one sentence.
 * So on a phone and a tablet it scrolls away like any other content, which is
 * what the shop asked for.
 *
 * `--myc-header-height` is measured at runtime by catalog-interface.js, because
 * the header grows with the announcement strip and the social row.
 */
@media (min-width: 1081px) {
	.ps-topbar {
		position: sticky;
		top: var(--myc-header-height, 76px);
		/* Under the header, over the page. The header is 999. */
		z-index: 998;
	}
}
