/**
 * fuze-play/price-calculator – "How much will our visit cost?"
 *
 * Loads only where the block is used (block.json "style"), in the editor too.
 * Narrow containers: one column (rows, then the total card). Wide containers: rows | sticky total card.
 * Rows stack their parts when the list itself is narrow (phones), where a small "peek" total also
 * appears above the quick bar while the rows are on screen and the total card is not.
 * Until view.js has built the rows – and without JavaScript – only the heading, a short note and
 * the booking button show (the block has no `is-ready` class yet).
 */

.wp-block-fuze-play-price-calculator {
	--fuze-calc-gap: clamp(1rem, 0.6rem + 1.6vw, 2rem);
	container: fuze-calc / inline-size;
	position: relative;
	box-sizing: border-box;
	margin-block-start: var(--wp--preset--spacing--50);
	padding: clamp(1.25rem, 0.9rem + 1.6vw, 2.25rem);
	border-radius: var(--wp--custom--radius--lg, 24px);
	background: var(--wp--preset--color--white, #fff);
	color: var(--wp--preset--color--body, #474446);
	box-shadow: 0 0 0 1px rgb(15 27 61 / 0.05), var(--wp--preset--shadow--soft, 0 10px 30px rgb(15 27 61 / 0.08));
	/* A jump to #cost-calculator stops a little below the header (html scroll-padding covers the header). */
	scroll-margin-top: 1rem;
}

/* Wide, but no wider than the opening hours table below it. */
.is-layout-constrained > .wp-block-fuze-play-price-calculator.alignwide {
	max-width: min(1040px, 100%);
}

.fuze-calc > * {
	margin-block: 0;
}

/* ---------------------------------------------------------------- *
 * Heading
 * ---------------------------------------------------------------- */
/* A tilted pink "ticket" sticker sits beside the heading (decoration only). */
.fuze-calc__head {
	position: relative;
	min-height: 3rem;
	padding-inline-start: 4.1rem;
}

.fuze-calc__head::before,
.fuze-calc__head::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	width: 3rem;
	height: 3rem;
	transform: rotate(-8deg);
}

.fuze-calc__head::before {
	border-radius: 50%;
	background: var(--wp--preset--color--pink-strong, #D1007A);
	box-shadow: 3px 3px 0 var(--wp--preset--color--navy, #0F1B3D);
}

.fuze-calc__head::after {
	background: var(--wp--preset--color--white, #fff);
	-webkit-mask: url(../../assets/images/icons/ticket.svg) center / 1.5rem no-repeat;
	mask: url(../../assets/images/icons/ticket.svg) center / 1.5rem no-repeat;
}

.fuze-calc__head > * {
	margin: 0;
}

.fuze-calc__title {
	font-size: var(--wp--preset--font-size--x-large);
	line-height: 1.15;
	text-wrap: balance;
}

.fuze-calc__lead {
	margin-block-start: 0.35rem !important;
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.5;
	text-wrap: pretty;
}

/* ---------------------------------------------------------------- *
 * Layout
 * ---------------------------------------------------------------- */
.fuze-calc__body {
	display: grid;
	gap: var(--fuze-calc-gap);
	margin-block-start: var(--wp--preset--spacing--40) !important;
}

.fuze-calc:not(.is-ready) .fuze-calc__body {
	margin-block-start: var(--wp--preset--spacing--30) !important;
}

.fuze-calc:not(.is-ready) :is(.fuze-calc__rows, .fuze-calc__sum, .fuze-calc__reset) {
	display: none;
}

@container fuze-calc (min-width: 720px) {
	.fuze-calc.is-ready .fuze-calc__body {
		grid-template-columns: minmax(0, 1.5fr) minmax(17rem, 1fr);
		align-items: start;
	}
}

/* ---------------------------------------------------------------- *
 * Rows
 * ---------------------------------------------------------------- */
.fuze-calc__rows {
	container: fuze-calc-rows / inline-size;
	display: grid;
	gap: 0.65rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.fuze-calc__row {
	--fuze-accent: var(--wp--preset--color--purple, #7030A0);
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"label stepper"
		"each stepper"
		"note stepper";
	align-items: center;
	column-gap: 1rem;
	margin: 0;
	padding: 0.8rem 0.85rem 0.8rem 1.35rem;
	border-radius: var(--wp--custom--radius--md, 14px);
	background: var(--wp--preset--color--white, #fff);
	box-shadow: inset 6px 0 0 var(--fuze-accent), inset 0 0 0 2px var(--wp--preset--color--purple-tint, #F4ECFA);
	transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.fuze-calc__row.is-active {
	background: color-mix(in srgb, var(--fuze-accent) 9%, var(--wp--preset--color--white, #fff));
	box-shadow: inset 6px 0 0 var(--fuze-accent), inset 0 0 0 2px color-mix(in srgb, var(--fuze-accent) 55%, transparent);
}

.fuze-calc__label {
	grid-area: label;
	align-self: end;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	line-height: 1.25;
	color: var(--wp--preset--color--heading, #312F30);
	text-wrap: balance;
}

.fuze-calc__each {
	grid-area: each;
	align-self: start;
	margin-block-start: 0.1rem;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	line-height: 1.35;
	color: var(--wp--preset--color--purple, #7030A0);
	font-variant-numeric: tabular-nums;
}

.fuze-calc__note {
	grid-area: note;
	justify-self: start;
	margin-block-start: 0.4rem;
	padding: 0.2em 0.65em;
	border-radius: var(--wp--custom--radius--sm, 8px);
	background: color-mix(in srgb, var(--fuze-accent) 14%, var(--wp--preset--color--white, #fff));
	color: var(--wp--preset--color--heading, #312F30);
	font-size: 0.8125rem;
	font-weight: 700;
	line-height: 1.35;
}

.fuze-calc__stepper {
	grid-area: stepper;
	display: flex;
	align-items: center;
	gap: 0.3rem;
}

/* − and + : 48px round buttons. + is filled (the main action), − is outlined. */
.fuze-calc__step {
	display: grid;
	place-items: center;
	flex: none;
	box-sizing: border-box;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0 0 0.08em;
	border: 2px solid var(--wp--preset--color--purple, #7030A0);
	border-radius: 50%;
	background: var(--wp--preset--color--white, #fff);
	color: var(--wp--preset--color--purple, #7030A0);
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.75rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.fuze-calc__step--up {
	background: var(--wp--preset--color--purple, #7030A0);
	color: var(--wp--preset--color--white, #fff);
}

/* Mouse only: touch screens keep :hover on the last button tapped, which then looked selected. */
@media (hover: hover) and (pointer: fine) {
	.fuze-calc__step:hover:not([aria-disabled="true"]) {
		border-color: var(--wp--preset--color--pink-strong, #D1007A);
		background: var(--wp--preset--color--pink-strong, #D1007A);
		color: var(--wp--preset--color--white, #fff);
	}
}

.fuze-calc__step[aria-disabled="true"] {
	border-color: color-mix(in srgb, var(--wp--preset--color--purple, #7030A0) 35%, #fff);
	background: var(--wp--preset--color--white, #fff);
	color: color-mix(in srgb, var(--wp--preset--color--purple, #7030A0) 45%, #fff);
	cursor: not-allowed;
}

.fuze-calc__qty {
	box-sizing: border-box;
	width: 3.25rem;
	height: 48px;
	margin: 0;
	padding: 0 0.2rem;
	border: 2px solid color-mix(in srgb, var(--wp--preset--color--purple, #7030A0) 65%, #fff);
	border-radius: 12px;
	background: var(--wp--preset--color--white, #fff);
	color: var(--wp--preset--color--heading, #312F30);
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.375rem;
	font-weight: 600;
	line-height: 1;
	text-align: center;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
	appearance: textfield;
}

.fuze-calc__qty::-webkit-outer-spin-button,
.fuze-calc__qty::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
	appearance: none;
}

.fuze-calc__row.is-active .fuze-calc__qty {
	border-color: var(--wp--preset--color--purple, #7030A0);
}

/* Phones: name on its own line, then "£7.00 each" beside the − / + buttons. */
@container fuze-calc-rows (max-width: 27rem) {
	.fuze-calc__row {
		grid-template-areas:
			"label label"
			"note note"
			"each stepper";
		column-gap: 0.75rem;
		padding: 0.75rem 0.75rem 0.75rem 1.2rem;
	}

	.fuze-calc__label {
		align-self: start;
	}

	.fuze-calc__note {
		margin-block-start: 0.35rem;
	}

	.fuze-calc__each,
	.fuze-calc__stepper {
		align-self: center;
		margin-block-start: 0.55rem;
	}
}

/* ---------------------------------------------------------------- *
 * Total card
 * ---------------------------------------------------------------- */
.fuze-calc__summary {
	display: grid;
	gap: 1.1rem;
	align-content: start;
}

.fuze-calc.is-ready .fuze-calc__summary {
	container: fuze-calc-sum / inline-size;
	--fuze-focus: var(--wp--preset--color--yellow, #FCC953);
	--fuze-focus-halo: var(--wp--preset--color--navy, #0F1B3D);
	--fuze-press: rgb(9 12 30 / 0.45);
	--fuze-press-soft: rgb(9 12 30 / 0.5);
	position: relative;
	isolation: isolate;
	overflow: hidden;
	padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
	border-radius: var(--wp--custom--radius--lg, 24px);
	background-color: var(--wp--preset--color--navy, #0F1B3D);
	background-image: var(--wp--preset--gradient--night, none);
	color: var(--wp--preset--color--white, #fff);
	box-shadow: var(--wp--preset--shadow--lift, 0 22px 48px rgb(112 48 160 / 0.18));
}

/* Side by side with the rows, the total stays in view while the rows scroll past. */
@container fuze-calc (min-width: 720px) {
	.fuze-calc.is-ready .fuze-calc__summary {
		position: sticky;
		top: calc(var(--fuze-header-offset, 96px) + 1rem);
	}
}

/* A soft pink glow in the corner (decoration only). */
.fuze-calc.is-ready .fuze-calc__summary::before {
	content: "";
	position: absolute;
	z-index: -1;
	top: -3.5rem;
	right: -3.5rem;
	width: 9rem;
	height: 9rem;
	border-radius: 50%;
	background: radial-gradient(circle, rgb(245 0 139 / 0.55), rgb(245 0 139 / 0) 70%);
	pointer-events: none;
}

.fuze-calc__sum > * {
	margin: 0;
}

.fuze-calc__eyebrow {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--wp--preset--color--yellow, #FCC953);
}

.fuze-calc__lines {
	display: grid;
	gap: 0.35rem;
	margin: 0.75rem 0 0 !important;
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

.fuze-calc__line {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	margin: 0;
}

.fuze-calc__line-cost {
	flex: none;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.fuze-calc__total {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.25rem 1rem;
	margin-block-start: 1rem !important;
	padding-block-start: 1rem;
	border-top: 2px dashed rgb(255 255 255 / 0.3);
}

.fuze-calc__total-label {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 600;
	line-height: 1.2;
}

.fuze-calc__amount {
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(2.5rem, 2rem + 2vw, 3.5rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--wp--preset--color--yellow, #FCC953);
	font-variant-numeric: tabular-nums;
	transform-origin: 100% 60%;
}

.fuze-calc__small {
	margin-block-start: 0.9rem !important;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.45;
}

.fuze-calc__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
}

.fuze-calc__book {
	margin: 0;
}

/* In a narrow total card the button fills the width; in a wide one (tablets) it sits beside Reset. */
.fuze-calc.is-ready .fuze-calc__book {
	flex: 1 1 100%;
}

.fuze-calc.is-ready .fuze-calc__book .wp-block-button__link {
	box-sizing: border-box;
	width: 100%;
}

/* On the navy card the button lights up sunshine yellow, like every button on a dark panel
 * (the light sections' purple hover looked dimmed here). */
.fuze-calc__summary .wp-block-button__link:focus-visible {
	background: var(--wp--preset--color--yellow, #FCC953);
	color: var(--wp--preset--color--navy, #0F1B3D);
}

@media (hover: hover) and (pointer: fine) {
	.fuze-calc__summary .wp-block-button__link:hover {
		background: var(--wp--preset--color--yellow, #FCC953);
		color: var(--wp--preset--color--navy, #0F1B3D);
	}
}

@container fuze-calc-sum (min-width: 32rem) {
	.fuze-calc.is-ready .fuze-calc__book {
		flex: 0 1 auto;
	}

	.fuze-calc.is-ready .fuze-calc__book .wp-block-button__link {
		width: auto;
		min-width: 16rem;
	}

	.fuze-calc.is-ready .fuze-calc__reset {
		margin: 0;
	}
}

.fuze-calc__reset {
	min-height: 44px;
	margin: 0 auto;
	padding: 0 0.75rem;
	border: 0;
	border-radius: var(--wp--custom--radius--pill, 999px);
	background: none;
	color: inherit;
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	text-decoration: underline;
	text-decoration-thickness: 0.08em;
	text-underline-offset: 0.2em;
	cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
	.fuze-calc__reset:hover {
		color: var(--wp--preset--color--yellow, #FCC953);
	}
}

.fuze-calc__reset[aria-disabled="true"] {
	color: inherit;
	text-decoration: none;
	opacity: 0.6;
	cursor: default;
}

/* ---------------------------------------------------------------- *
 * Peek (phones): "Total £15.15 · See breakdown", pinned just above the quick bar while the rows
 * are on screen and the total card below them is not (view.js adds it to <body> and shows it with
 * .is-visible). It hides as the card's own total comes up to meet it, so the rows' last line is
 * never left under it. A tap scrolls to the card. Screen readers hear the card's total instead.
 * ---------------------------------------------------------------- */
.fuze-calc__peek {
	position: fixed;
	z-index: 94; /* over the page, under the quick bar (95) and the open menu */
	right: 1rem;
	bottom: calc(var(--wp--custom--cta-bar, 64px) + env(safe-area-inset-bottom) + 0.5rem);
	left: 1rem;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	max-width: 26rem;
	min-height: 48px;
	margin-inline: auto;
	padding: 0.3rem 0.3rem 0.3rem 1.1rem;
	border-radius: var(--wp--custom--radius--pill, 999px);
	background-color: var(--wp--preset--color--navy, #0F1B3D);
	background-image: var(--wp--preset--gradient--night, none);
	box-shadow: 0 0 0 2px rgb(255 255 255 / 0.85), 0 12px 28px rgb(15 27 61 / 0.35);
	color: var(--wp--preset--color--white, #fff);
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.fuze-calc__peek.is-visible {
	visibility: visible;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.fuze-calc__peek-label {
	font-size: var(--wp--preset--font-size--small);
}

.fuze-calc__peek-amount {
	color: var(--wp--preset--color--yellow, #FCC953);
	font-size: 1.375rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
}

.fuze-calc__peek-more {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	margin-inline-start: auto;
	padding: 0.55em 0.9em;
	border-radius: var(--wp--custom--radius--pill, 999px);
	background: rgb(255 255 255 / 0.14);
	font-size: 0.875rem;
	white-space: nowrap;
}

/* A down arrow: the breakdown is further down the page. */
.fuze-calc__peek-more::after {
	content: "";
	flex: none;
	width: 1em;
	height: 1em;
	background: currentColor;
	-webkit-mask: url(../../assets/images/icons/arrow.svg) center / contain no-repeat;
	mask: url(../../assets/images/icons/arrow.svg) center / contain no-repeat;
	transform: rotate(90deg);
}

/* While it shows, anything brought into view from below (keyboard focus on the next − / +) stops
 * above it rather than behind it. */
html.has-fuze-calc-peek {
	scroll-padding-bottom: calc(var(--wp--custom--cta-bar, 64px) + env(safe-area-inset-bottom) + 1rem + 48px);
}

/* Only where the quick bar is (below 782px); wider screens keep the total card beside the rows. */
@media (min-width: 782px) {
	.fuze-calc__peek {
		display: none;
	}
}

/* ---------------------------------------------------------------- *
 * Motion (only for visitors who have not asked for less)
 * ---------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
	.fuze-calc__step:active:not([aria-disabled="true"]) {
		transform: scale(0.9);
	}

	.fuze-calc__amount.is-bump {
		animation: fuze-calc-bump 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.fuze-calc__peek.is-visible {
		animation: fuze-calc-peek-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
	}
}

@keyframes fuze-calc-bump {
	40% {
		transform: scale(1.08);
	}
}

@keyframes fuze-calc-peek-in {
	from {
		transform: translateY(0.75rem);
	}
}

/* Windows high-contrast and other forced-colour modes: keep the row and button outlines. */
@media (forced-colors: active) {
	.fuze-calc__row {
		border: 1px solid CanvasText;
	}

	.fuze-calc__step,
	.fuze-calc__qty {
		border-color: ButtonText;
	}

	.fuze-calc__head::before,
	.fuze-calc__head::after {
		display: none;
	}

	.fuze-calc__head {
		padding-inline-start: 0;
	}
}

/* ---------------------------------------------------------------- *
 * Editor preview (index.js)
 * ---------------------------------------------------------------- */
.fuze-calc__preview-note {
	margin: 0 0 1rem !important;
	padding: 0.6rem 0.9rem;
	border: 2px dashed color-mix(in srgb, var(--wp--preset--color--purple, #7030A0) 45%, #fff);
	border-radius: var(--wp--custom--radius--md, 14px);
	background: var(--wp--preset--color--purple-tint, #F4ECFA);
	color: var(--wp--preset--color--heading, #312F30);
	font-size: 0.875rem;
	line-height: 1.45;
}

.fuze-calc.is-preview .fuze-calc__qty {
	display: grid;
	place-items: center;
}

.fuze-calc.is-preview .fuze-calc__reset {
	display: inline-flex;
	align-items: center;
}

.fuze-calc.is-preview :is(.fuze-calc__step, .fuze-calc__qty, .fuze-calc__reset, .wp-block-button__link) {
	pointer-events: none;
}
