/**
 * Storefront calculator.
 *
 * Colours are inherited from the theme wherever possible, so the calculator
 * sits inside whatever design the shop already has.
 */

.rpc-calc {
	--rpc-line: rgba( 0, 0, 0, .13 );
	--rpc-line-soft: rgba( 0, 0, 0, .07 );
	--rpc-tint: rgba( 0, 0, 0, .04 );
	--rpc-muted: .62;
	--rpc-radius: 3px;

	margin: 0 0 1.75rem;
	max-width: 36rem;
}

.rpc-calc *,
.rpc-calc *::before,
.rpc-calc *::after {
	box-sizing: border-box;
}

.rpc-field {
	padding: 1.15rem 0;
	border-top: 1px solid var( --rpc-line );
}

.rpc-field:first-child {
	border-top: 0;
	padding-top: 0;
}

.rpc-label {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	margin-bottom: .75rem;
	font-size: .7rem;
	letter-spacing: .11em;
	text-transform: uppercase;
}

.rpc-current {
	font-style: normal;
	text-transform: none;
	letter-spacing: 0;
	opacity: var( --rpc-muted );
	font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- swatches */

.rpc-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}

.rpc-swatch {
	position: relative;
	margin: 0;
	padding: 0;
	cursor: pointer;
	line-height: 0;
}

.rpc-swatch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.rpc-swatch-face {
	display: block;
	width: 3.1rem;
	height: 3.1rem;
	border-radius: var( --rpc-radius );
	overflow: hidden;
	border: 1px solid var( --rpc-line );
	box-shadow: inset 0 0 0 0 currentColor;
	transition: box-shadow .15s, transform .15s;
}

.rpc-swatch-face img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rpc-swatch--plain .rpc-swatch-face {
	width: 2.3rem;
	height: 2.3rem;
	border-radius: 50%;
	box-shadow: inset 0 0 0 3px #fff;
}

.rpc-swatch input:checked + .rpc-swatch-face {
	box-shadow: 0 0 0 2px currentColor;
	transform: translateY( -1px );
}

.rpc-swatch--plain input:checked + .rpc-swatch-face {
	box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px currentColor;
}

.rpc-swatch input:focus-visible + .rpc-swatch-face {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* -------------------------------------------------------------- gallery */

.rpc-gallery {
	margin-top: .9rem;
}

.rpc-gallery-main {
	overflow: hidden;
	border-radius: var( --rpc-radius );
	background: var( --rpc-tint );
	aspect-ratio: 4 / 3;
}

.rpc-gallery-main img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rpc-gallery-strip {
	display: flex;
	gap: .4rem;
	margin-top: .4rem;
	overflow-x: auto;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.rpc-gallery-strip:empty {
	display: none;
}

.rpc-thumb {
	flex: none;
	width: 3.6rem;
	height: 3.6rem;
	padding: 0;
	border: 1px solid var( --rpc-line );
	border-radius: var( --rpc-radius );
	background: none;
	overflow: hidden;
	cursor: pointer;
	opacity: .6;
	transition: opacity .15s, border-color .15s;
}

.rpc-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rpc-thumb:hover,
.rpc-thumb.is-active {
	opacity: 1;
	border-color: currentColor;
}

.rpc-thumb:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* -------------------------------------------------------------- choices */

.rpc-choices {
	display: grid;
	gap: .5rem;
	grid-template-columns: repeat( auto-fit, minmax( 7rem, 1fr ) );
}

.rpc-choices--wide {
	grid-template-columns: repeat( auto-fit, minmax( 10rem, 1fr ) );
}

.rpc-choice {
	position: relative;
	display: block;
	margin: 0;
	cursor: pointer;
}

.rpc-choice input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.rpc-choice > span {
	display: block;
	padding: .75rem .85rem;
	border: 1px solid var( --rpc-line );
	border-radius: var( --rpc-radius );
	line-height: 1.35;
	transition: border-color .15s, background-color .15s;
}

.rpc-choice strong {
	display: block;
	font-weight: 500;
	font-size: .88rem;
}

.rpc-choice small {
	display: block;
	margin-top: .15rem;
	font-size: .73rem;
	opacity: var( --rpc-muted );
}

.rpc-shape-icon {
	display: block;
	width: 1.5rem;
	height: 1.5rem;
	margin: 0 auto .35rem;
	opacity: .8;
}

.rpc-choice input:checked + span {
	border-color: currentColor;
	background: var( --rpc-tint );
}

.rpc-choice input:focus-visible + span {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ----------------------------------------------------------------- size */

.rpc-size + .rpc-size {
	margin-top: 1.1rem;
}

.rpc-size-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: .4rem;
}

.rpc-size-head label {
	font-size: .84rem;
	opacity: .8;
	margin: 0;
}

.rpc-stepper {
	display: flex;
	align-items: center;
	gap: .3rem;
}

.rpc-calc .rpc-step {
	width: 1.9rem;
	height: 1.9rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1px solid var( --rpc-line );
	border-radius: var( --rpc-radius );
	background: none;
	color: inherit;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color .15s;
}

.rpc-calc .rpc-step:hover {
	background: var( --rpc-tint );
}

.rpc-calc .rpc-step:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

.rpc-calc .rpc-stepper input[type="number"] {
	width: 4.4rem;
	padding: .3rem .4rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
	border: 1px solid var( --rpc-line );
	border-radius: var( --rpc-radius );
	background: none;
	color: inherit;
	-moz-appearance: textfield;
}

.rpc-calc .rpc-stepper input[type="number"]::-webkit-outer-spin-button,
.rpc-calc .rpc-stepper input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.rpc-unit {
	font-size: .78rem;
	opacity: var( --rpc-muted );
}

.rpc-calc input[type="range"] {
	width: 100%;
	margin: 0;
	accent-color: currentColor;
}

/* Scale outline */

.rpc-proportion {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 7rem;
	margin-top: 1.1rem;
	padding: .5rem;
	border-radius: var( --rpc-radius );
	background: var( --rpc-tint );
	overflow: hidden;
}

.rpc-proportion-shape {
	flex: none;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	aspect-ratio: var( --rpc-ratio, 1 );
	border: 1px solid currentColor;
	background: rgba( 255, 255, 255, .35 );
	transition: border-radius .18s;
}

/* Browsers without aspect-ratio get pixel sizes from the script instead. */
@supports not ( aspect-ratio: 1 / 1 ) {
	.rpc-proportion-shape {
		height: auto;
		aspect-ratio: auto;
	}
}

/* -------------------------------------------------------------- summary */

.rpc-summary {
	margin-top: 1.3rem;
	padding-top: 1.15rem;
	border-top: 1px solid var( --rpc-line );
}

.rpc-total-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
}

.rpc-total-label {
	font-size: .7rem;
	letter-spacing: .11em;
	text-transform: uppercase;
}

.rpc-total {
	font-size: 1.75rem;
	font-weight: 500;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
}

.rpc-calc .rpc-toggle {
	margin-top: .5rem;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font-size: .8rem;
	text-decoration: underline;
	text-underline-offset: .18em;
	cursor: pointer;
	opacity: .68;
}

.rpc-calc .rpc-toggle:hover {
	opacity: 1;
}

.rpc-breakdown dl {
	margin: .85rem 0 0;
	font-size: .83rem;
}

.rpc-breakdown dl > div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: .38rem 0;
	border-bottom: 1px solid var( --rpc-line-soft );
}

.rpc-breakdown dt,
.rpc-breakdown dd {
	margin: 0;
}

.rpc-breakdown dt {
	opacity: var( --rpc-muted );
}

.rpc-breakdown dd {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.rpc-breakdown-total {
	font-weight: 600;
	border-bottom: 0 !important;
}

.rpc-breakdown-total dt {
	opacity: 1 !important;
}

.rpc-error {
	margin: .75rem 0 0;
	font-size: .83rem;
	color: #b3261e;
}

@media ( max-width: 480px ) {
	.rpc-choices {
		grid-template-columns: 1fr 1fr;
	}

	.rpc-total {
		font-size: 1.45rem;
	}

	.rpc-swatch-face {
		width: 2.7rem;
		height: 2.7rem;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.rpc-calc * {
		transition: none !important;
	}
}
