/**
 * Component: breadcrumb bar.
 *
 * Light bar with a hairline border, small text, current page bold,
 * chevron separators drawn in CSS. Mobile (proposal, TODO: no mobile frame):
 * one line that scrolls sideways and starts scrolled to the current page.
 * Values come from assets/css/tokens.css.
 *
 * @package cartrack
 */

.breadcrumb {
	border-bottom: 1px solid var(--breadcrumb-border);
	background-color: var(--breadcrumb-bg);
	color: var(--breadcrumb-text);
	font-family: var(--font-body);
	font-size: var(--breadcrumb-font-size);
	line-height: var(--line-height-snug);
}

/*
 * RTL scroller + LTR list: the browser's initial scroll position is the
 * right-hand end, so the current page is visible without JS.
 */
.breadcrumb__scroller {
	direction: rtl;
	overflow-x: auto;
	scrollbar-width: none;
}

.breadcrumb__scroller::-webkit-scrollbar {
	display: none;
}

.breadcrumb__list {
	direction: ltr;
	display: flex;
	align-items: center;
	width: max-content;
	min-width: 100%;
	min-height: var(--breadcrumb-height);
	margin: 0;
	/* The bar is full-bleed; the crumbs start at the container's edge, in line with the header logo (frame). */
	padding: 0 max(var(--container-gutter), calc((100% - var(--container-max)) / 2));
	list-style: none;
}

.breadcrumb__item {
	display: flex;
	align-items: center;
	white-space: nowrap;
}

/* Chevron separator. */
.breadcrumb__item + .breadcrumb__item::before {
	content: "";
	flex: none;
	width: var(--breadcrumb-separator-size);
	height: var(--breadcrumb-separator-size);
	margin-inline: var(--breadcrumb-gap);
	background-color: var(--breadcrumb-separator);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.breadcrumb__link {
	color: inherit;
	text-decoration: none;
}

/* TODO: verify hover state in Figma (no hover frame supplied). */
.breadcrumb__link:hover {
	color: var(--breadcrumb-link-hover);
	text-decoration: underline;
}

.breadcrumb__link:focus-visible {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 2px;
}

.breadcrumb__current {
	color: var(--breadcrumb-current);
	font-weight: var(--font-weight-bold);
}

/* Desktop: the whole trail fits; no scrolling. */
@media (min-width: 48em) { /* --bp-md */
	.breadcrumb__scroller {
		direction: ltr;
		overflow-x: visible;
	}

	.breadcrumb__list {
		flex-wrap: wrap;
		width: auto;
		row-gap: var(--space-2xs);
		padding-block: var(--space-2xs);
	}

	.breadcrumb__item {
		white-space: normal;
	}
}
