/*
 * Site chrome — the header bar's layout, the skip link, the current-page and
 * focus states for the nav links and the mini cart, and the footer columns.
 *
 * Builds on the header and mini-cart rules in assets/css/cart.css rather than
 * redeclaring them: this file adds the bar's flex row (so the menu and the cart
 * pill sit on one line inside the nav), the keyboard states, and the
 * current-page treatment. Every value comes from assets/css/design-tokens.css,
 * so a [data-theme="dark"] remap of the role tokens recolours the whole bar.
 *
 * Mobile-first: the bar is a wrapping row that works with no JavaScript at all.
 * assets/js/nav-toggle.js then adds .hcr-nav-js, which turns that row into a
 * disclosure below 48em — the SAME single menu, collapsed behind a labelled
 * button, never a second copy of it in the DOM. Above 48em the button is gone
 * and the row is back, so the inline nav and a drawer are never both visible.
 */

/* ------------------------------------------------------------ skip link --- */

.hcr-skip-link {
	position: absolute;
	left: var(--space-2);
	top: var(--space-2);
	z-index: 100;
	padding: var(--space-2) var(--space-4);
	background: var(--color-primary-700);
	border-radius: var(--radius-md);
	color: var(--color-on-primary);
	font-family: var(--font-body);
	font-size: var(--text-sm);
	font-weight: var(--weight-medium);
	text-decoration: none;
	transform: translateY(-200%);
	transition: transform var(--duration-fast) var(--ease-default);
}

.hcr-skip-link:focus {
	transform: translateY(0);
	outline: 3px solid var(--color-accent-400);
	outline-offset: 2px;
}

/* ------------------------------------------------------------- the bar --- */

.hcr-site-header__nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-3) var(--space-6);
}

.hcr-site-header__nav > ul {
	flex: 1 1 auto;
}

/*
 * Current page: the copper underline from cart.css plus a weight change, so the
 * active tab is not signalled by colour alone.
 */
.hcr-site-header__nav .current-menu-item > a,
.hcr-site-header__nav a[aria-current='page'] {
	border-bottom-color: var(--color-primary-600);
	color: var(--color-primary-700);
	font-weight: var(--weight-medium);
}

/* The cart pill is a link, not a menu item, so it gets its own current state. */
.hcr-mini-cart--current {
	background: var(--color-primary-50);
	border-color: var(--color-primary-600);
	color: var(--color-primary-700);
}

/* ------------------------------------------------------ keyboard states --- */

.hcr-skip-link:focus-visible,
.hcr-site-header__brand a:focus-visible,
.hcr-site-header__nav a:focus-visible,
.hcr-mini-cart:focus-visible {
	outline: 3px solid var(--color-primary-600);
	outline-offset: 2px;
	border-radius: var(--radius-sm);
}

/*
 * The card media link is decorative (the title link is the real one), so it is
 * taken out of the tab order in the card component. Keep it out of the focus
 * ring styling too.
 */
.hcr-site-header__nav a:focus,
.hcr-mini-cart:focus {
	outline-color: var(--color-primary-600);
}

@media (min-width: 48em) {
	.hcr-site-header__nav {
		justify-content: flex-end;
		gap: var(--space-4) var(--space-8);
	}
}

/* ------------------------------------------------------------- the footer --- */

.hcr-site-footer {
	margin-top: var(--space-section);
	background: var(--color-surface-dark);
	color: var(--color-neutral-200);
	font-family: var(--font-body);
}

.hcr-site-footer__inner {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-8);
	padding-block: var(--space-12);
}

.hcr-site-footer__brand {
	margin: 0 0 var(--space-3);
	color: var(--color-neutral-50);
	font-family: var(--font-heading);
	font-size: var(--text-lg);
	font-weight: var(--weight-bold);
	letter-spacing: var(--letter-tight);
}

.hcr-site-footer__blurb {
	max-width: 34ch;
	margin: 0;
	color: var(--color-neutral-300);
	font-size: var(--text-sm);
	line-height: var(--leading-normal);
}

.hcr-site-footer__heading {
	margin: 0 0 var(--space-4);
	color: var(--color-neutral-50);
	font-family: var(--font-heading);
	font-size: var(--text-sm);
	font-weight: var(--weight-semibold);
	letter-spacing: var(--letter-wide);
	text-transform: uppercase;
}

.hcr-site-footer__links {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--text-sm);
}

.hcr-site-footer__links a {
	color: var(--color-neutral-200);
	text-decoration: none;
	transition: color var(--duration-fast) var(--ease-default);
}

.hcr-site-footer__links a:hover,
.hcr-site-footer__links a:focus-visible {
	color: var(--color-accent-300);
	text-decoration: underline;
}

.hcr-site-footer__links a:focus-visible {
	outline: 3px solid var(--color-accent-300);
	outline-offset: 2px;
	border-radius: var(--radius-sm);
}

.hcr-site-footer__bar {
	border-top: var(--border-width) solid var(--color-neutral-700);
	padding-block: var(--space-5);
}

.hcr-site-footer__copy {
	margin: 0;
	color: var(--color-neutral-400);
	font-size: var(--text-xs);
}

@media (min-width: 48em) {
	.hcr-site-footer__inner {
		grid-template-columns: 1.4fr 1fr 1fr;
		gap: var(--space-12);
		padding-block: var(--space-16);
	}
}

/* ------------------------------------------------------- nav disclosure --- */

/*
 * The small-screen toggle. It is hidden until assets/js/nav-toggle.js adds
 * .hcr-nav-js to the nav, so a scriptless page keeps the wrapping row above and
 * never hides a link behind a button that cannot open. There is one menu in the
 * DOM either way: the button collapses that list, it does not duplicate it.
 */
.hcr-nav-toggle {
	display: none;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-2) var(--space-3);
	background: var(--color-bg);
	border: var(--border-width) solid var(--color-border);
	border-radius: var(--radius-full);
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: var(--text-sm);
	font-weight: var(--weight-medium);
	cursor: pointer;
	transition:
		background var(--duration-fast) var(--ease-default),
		border-color var(--duration-fast) var(--ease-default);
}

.hcr-nav-js .hcr-nav-toggle {
	display: inline-flex;
}

.hcr-nav-toggle:hover {
	background: var(--color-surface);
	border-color: var(--color-primary-600);
	color: var(--color-primary-700);
}

.hcr-nav-toggle:focus-visible {
	outline: 3px solid var(--color-primary-600);
	outline-offset: 2px;
}

/* Two bars that become a cross once the menu is open. */
.hcr-nav-toggle__bars,
.hcr-nav-toggle__bars::after {
	display: block;
	width: 1.125rem;
	height: 2px;
	background: currentColor;
	border-radius: var(--radius-full);
	transition: transform var(--duration-fast) var(--ease-default);
}

.hcr-nav-toggle__bars {
	position: relative;
	margin-block: 0.3125rem;
}

.hcr-nav-toggle__bars::after {
	content: '';
	position: absolute;
	top: 0.3125rem;
	left: 0;
}

.hcr-nav-js--open .hcr-nav-toggle__bars {
	transform: translateY(0.15625rem) rotate(45deg);
}

.hcr-nav-js--open .hcr-nav-toggle__bars::after {
	transform: translateY(-0.3125rem) rotate(-90deg);
}

/* Collapsed: the single menu is out of the flow and out of the tab order. */
.hcr-nav-js:not(.hcr-nav-js--open) .hcr-site-header__menu {
	display: none;
}

.hcr-nav-js--open .hcr-site-header__menu {
	flex: 1 0 100%;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-1);
	padding-top: var(--space-3);
}

.hcr-nav-js--open .hcr-site-header__menu a {
	display: block;
	width: 100%;
	padding-block: var(--space-2);
}

/* From the tablet breakpoint up the bar is a plain row again: no button, and
 * the menu is always visible whatever the toggle's last state was. */
@media (min-width: 48em) {
	.hcr-nav-js .hcr-nav-toggle {
		display: none;
	}

	.hcr-nav-js .hcr-site-header__menu,
	.hcr-nav-js:not(.hcr-nav-js--open) .hcr-site-header__menu {
		display: flex;
		flex: 1 1 auto;
		flex-direction: row;
		align-items: center;
		padding-top: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hcr-skip-link,
	.hcr-nav-toggle,
	.hcr-nav-toggle__bars,
	.hcr-nav-toggle__bars::after,
	.hcr-site-header__nav a,
	.hcr-site-footer__links a {
		transition: none;
	}
}
