/**
 * ShopFlow Mobile UX — shell primitives.
 *
 * Every value here reads a custom property declared by Frontend\Tokens. There
 * are no literal colours and no literal radii below, which is what lets one
 * stylesheet serve four surface treatments, dark mode and RTL without a build
 * step. Layout uses logical properties throughout, so RTL needs no second file.
 */

/* ------------------------------------------------------------------ base */

.shopflow-region,
.shopflow-region *,
.shopflow-region *::before,
.shopflow-region *::after {
	box-sizing: border-box;
}

.shopflow-region {
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

.shopflow-region button,
.shopflow-region a {
	font: inherit;
	color: inherit;
	text-decoration: none;
}

.shopflow-region :focus-visible {
	outline: 2px solid var(--shopflow-accent);
	outline-offset: 2px;
	border-radius: var(--shopflow-radius-sm);
}

/* Fixed regions are hidden until the runtime has measured them, so a slow
   connection never shows a bar in the wrong place. */
.shopflow-region[data-shopflow-ready="false"].shopflow-region--float {
	opacity: 0;
}

.shopflow-region[data-shopflow-ready="true"] {
	opacity: 1;
	transition: opacity var(--shopflow-duration-fast) var(--shopflow-ease);
}

/* ----------------------------------------------------------------- icons */

.shopflow-icon {
	inline-size: var(--shopflow-icon-size);
	block-size: var(--shopflow-icon-size);
	fill: none;
	stroke: var(--shopflow-icon-color, currentColor);
	stroke-width: var(--shopflow-icon-stroke, 1.7);
	stroke-linecap: round;
	stroke-linejoin: round;
	flex: none;
	display: block;
}

/* The solid set fills rather than strokes, so thickness does not apply. */
.shopflow-style-solid .shopflow-icon,
.shopflow-icon--solid {
	fill: var(--shopflow-icon-color, currentColor);
	stroke: none;
}

/*
 * An icon shape wraps the glyph rather than resizing it, so switching shape on
 * does not change how large the icon reads.
 */
.shopflow-icons-shaped .shopflow-nav__icon,
.shopflow-icons-shaped .shopflow-header__action .shopflow-icon,
.shopflow-icons-shaped .shopflow-fab__icon > .shopflow-icon {
	box-sizing: content-box;
	padding: var(--shopflow-icon-pad, 8px);
	border-radius: var(--shopflow-icon-radius, 0);
	background: var(--shopflow-icon-bg);
}

.shopflow-icons-shaped .shopflow-nav__item.is-current .shopflow-nav__icon,
.shopflow-icons-shaped .shopflow-header__action:active .shopflow-icon {
	color: var(--shopflow-icon-active);
}

/* The pill marker draws its own shape, so the two must not stack. */
.shopflow-icons-shaped .shopflow-nav--marker-pill .shopflow-nav__item.is-current .shopflow-nav__icon {
	box-shadow: none;
}

.shopflow-nav__item.is-current .shopflow-icon {
	stroke: var(--shopflow-icon-active);
}

.shopflow-style-solid .shopflow-nav__item.is-current .shopflow-icon {
	fill: var(--shopflow-icon-active);
	stroke: none;
}

/* --------------------------------------------------------------- panels */

/* The one class that carries the surface treatment. Header bars, nav bars,
   sheets and cards all use it, so switching Flat to Glass changes them
   together instead of one at a time. */
.shopflow-panel {
	background: var(--shopflow-panel-bg);
	border: var(--shopflow-panel-width) solid var(--shopflow-panel-border);
	box-shadow: var(--shopflow-panel-inset, none);
	color: var(--shopflow-text);
}

.shopflow-style-glass .shopflow-panel {
	-webkit-backdrop-filter: var(--shopflow-panel-blur);
	backdrop-filter: var(--shopflow-panel-blur);
}

/* Glass over an unknown page needs a fallback: without backdrop-filter the
   translucent surface would leave text on top of the article underneath. */
@supports not (backdrop-filter: blur(1px)) {
	.shopflow-style-glass .shopflow-panel {
		background: var(--shopflow-surface);
	}
}

.shopflow-bar {
	display: flex;
	align-items: center;
	gap: var(--shopflow-space-sm);
	padding-inline: var(--shopflow-space);
	min-block-size: var(--shopflow-header-height);
}

.shopflow-region--top .shopflow-bar {
	background: var(--shopflow-header-bg);
	color: var(--shopflow-header-ink);
	box-shadow: var(--shopflow-shadow);
}

.shopflow-region--bottom .shopflow-panel {
	box-shadow: var(--shopflow-shadow-lg);
	border-inline-width: 0;
	border-block-end-width: 0;
}

/* --------------------------------------------------------------- buttons */

.shopflow-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--shopflow-space-sm);
	min-block-size: 44px;
	min-inline-size: 44px;
	padding-inline: var(--shopflow-space);
	border: var(--shopflow-panel-width) solid transparent;
	border-radius: var(--shopflow-radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
	overflow: hidden;
	transition: background var(--shopflow-duration-fast) var(--shopflow-ease),
		transform var(--shopflow-duration-fast) var(--shopflow-ease);
}

.shopflow-btn:active {
	transform: scale(0.97);
}

.shopflow-btn--primary {
	background: var(--shopflow-accent);
	color: var(--shopflow-accent-ink);
	font-weight: 650;
}

.shopflow-btn--primary:active {
	background: var(--shopflow-accent-press);
}

.shopflow-btn--quiet {
	background: var(--shopflow-surface-sunken);
	color: var(--shopflow-text);
}

.shopflow-btn--icon {
	padding-inline: 0;
	border-radius: var(--shopflow-radius-pill);
}

.shopflow-btn[disabled],
.shopflow-btn[aria-disabled="true"] {
	opacity: 0.5;
	pointer-events: none;
}

/* --------------------------------------------------------------- badges */

.shopflow-badge {
	position: absolute;
	inset-block-start: 2px;
	inset-inline-end: 2px;
	min-inline-size: 18px;
	block-size: 18px;
	padding-inline: 5px;
	border-radius: var(--shopflow-radius-pill);
	background: var(--shopflow-badge-bg, var(--shopflow-accent));
	color: var(--shopflow-badge-ink, var(--shopflow-accent-ink));
	font-size: var(--shopflow-font-size-sm);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	display: grid;
	place-items: center;
	line-height: 1;
}

/* A badge showing nothing is a badge that should not be there. */
.shopflow-badge:empty,
.shopflow-badge[data-count="0"] {
	display: none;
}

.shopflow-badge--dot {
	min-inline-size: 8px;
	inline-size: 8px;
	block-size: 8px;
	padding: 0;
}

/* --------------------------------------------------------------- sheets */

.shopflow-backdrop {
	position: fixed;
	inset: 0;
	z-index: var(--shopflow-z-overlay);
	background: var(--shopflow-overlay);
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--shopflow-duration) var(--shopflow-ease), visibility var(--shopflow-duration);
}

.shopflow-backdrop[data-shopflow-open="true"] {
	opacity: 1;
	visibility: visible;
}

.shopflow-sheet {
	position: fixed;
	z-index: var(--shopflow-z-drawer);
	display: flex;
	flex-direction: column;
	max-block-size: 100dvh;
	background: var(--shopflow-surface);
	color: var(--shopflow-text);
	box-shadow: var(--shopflow-shadow-lg);
	visibility: hidden;
	transition: transform var(--shopflow-duration) var(--shopflow-ease-out), visibility var(--shopflow-duration);
	will-change: transform;
}

.shopflow-sheet[data-shopflow-open="true"] {
	visibility: visible;
	transform: none;
}

.shopflow-sheet--bottom {
	inset-inline: 0;
	inset-block-end: 0;
	max-block-size: 88dvh;
	border-start-start-radius: var(--shopflow-radius-lg);
	border-start-end-radius: var(--shopflow-radius-lg);
	transform: translateY(100%);
	padding-block-end: env(safe-area-inset-bottom, 0px);
}

.shopflow-sheet--start {
	inset-block: 0;
	inset-inline-start: 0;
	inline-size: min(86vw, 380px);
	transform: translateX(-100%);
}

.shopflow-sheet--end {
	inset-block: 0;
	inset-inline-end: 0;
	inline-size: min(86vw, 380px);
	transform: translateX(100%);
}

/* Logical properties cover layout, but a translate is a physical direction:
   in RTL the start drawer has to slide the other way. */
[dir="rtl"] .shopflow-sheet--start {
	transform: translateX(100%);
}

[dir="rtl"] .shopflow-sheet--end {
	transform: translateX(-100%);
}

.shopflow-sheet--full {
	inset: 0;
	inline-size: 100%;
	transform: translateY(2%);
	opacity: 0;
	transition: transform var(--shopflow-duration) var(--shopflow-ease-out),
		opacity var(--shopflow-duration) var(--shopflow-ease), visibility var(--shopflow-duration);
}

.shopflow-sheet--full[data-shopflow-open="true"] {
	opacity: 1;
}

.shopflow-sheet__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--shopflow-space);
	padding: var(--shopflow-space);
	border-block-end: 1px solid var(--shopflow-border);
	flex: none;
}

.shopflow-sheet__title {
	margin: 0;
	font-size: calc(var(--shopflow-font-size) * 1.15);
	font-weight: 700;
}

.shopflow-sheet__body {
	padding: var(--shopflow-space);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	flex: 1;
}

.shopflow-sheet__grip {
	inline-size: 40px;
	block-size: 4px;
	border-radius: var(--shopflow-radius-pill);
	background: var(--shopflow-border);
	margin: var(--shopflow-space-sm) auto 0;
	flex: none;
}

/* ---------------------------------------------------------- scroll lock */

html.shopflow-locked,
body.shopflow-locked {
	overflow: hidden;
	touch-action: none;
}

/* ------------------------------------------------------------- skeleton */

.shopflow-skeleton {
	background: var(--shopflow-skeleton);
	border-radius: var(--shopflow-radius-sm);
	position: relative;
	overflow: hidden;
	color: transparent;
}

.shopflow-skeleton::after {
	content: "";
	position: absolute;
	inset: 0;
	transform: translateX(-100%);
	background: linear-gradient(90deg, transparent, var(--shopflow-surface-raised), transparent);
	animation: shopflow-sweep 1.2s infinite;
}

@keyframes shopflow-sweep {
	to {
		transform: translateX(100%);
	}
}

/* --------------------------------------------------------------- ripple */

.shopflow-ripple {
	position: absolute;
	border-radius: 50%;
	transform: scale(0);
	background: currentColor;
	opacity: 0.25;
	pointer-events: none;
	animation: shopflow-ripple var(--shopflow-duration) var(--shopflow-ease-out) forwards;
}

@keyframes shopflow-ripple {
	to {
		transform: scale(2.4);
		opacity: 0;
	}
}

/* ------------------------------------------------------- scroll reaction */

/* The runtime writes the direction onto html; modules opt in by styling these
   states rather than each attaching its own scroll listener. */
html[data-shopflow-scroll="down"] .shopflow-hide-on-scroll {
	transform: translateY(-100%);
}

html[data-shopflow-scroll="down"] .shopflow-region--bottom .shopflow-hide-on-scroll {
	transform: translateY(100%);
}

.shopflow-hide-on-scroll {
	transition: transform var(--shopflow-duration) var(--shopflow-ease);
}

html[data-shopflow-scroll="top"] .shopflow-on-scrolled {
	opacity: 0;
	pointer-events: none;
}

.shopflow-on-scrolled {
	transition: opacity var(--shopflow-duration-fast) var(--shopflow-ease);
}

/* -------------------------------------------------------- accessibility */

.shopflow-sr {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.shopflow-region *,
	.shopflow-sheet,
	.shopflow-backdrop {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}

	.shopflow-skeleton::after {
		display: none;
	}
}

@media (prefers-contrast: more) {
	.shopflow-panel {
		border-width: 2px;
		border-color: var(--shopflow-text);
	}
}
