/**
 * Calculator section & quote success dialog styles.
 * Loaded on front page only.
 *
 * @package Beaver_Movers
 */

/* Calculator design token */
:root {
	--bm-calculator-padding-block: 1.75rem;
	--bm-calculator-padding-inline: 2rem;
	/* Tweak to scale the SVG backgrounds without changing layout */
	--bm-calculator-bg-size: contain;
	/* Tablet (601px–1024px): image + size; defaults match desktop */
	--bm-calculator-bg-image-tablet: url(../images/calculator-bg.svg);
	--bm-calculator-bg-size-tablet: 100% 100%;
	--bm-calculator-bg-size-mobile: auto 100%;
	--bm-calculator-max-width-tablet: 780px;
}

.main__calculator-section {
	max-width: 1440px;
	margin: 0 auto;
	display: flex;
	gap: 28px;
	align-items: center;
	padding: 0 48px;
}

/* Calculator section – Figma node 1553:285 (kalkulator), 1693:451 (dropdown state) */
.calculator-section {
	background-image: url(../images/calculator-bg.svg);
	background-repeat: no-repeat;
	background-position: center;
	background-size: var(--bm-calculator-bg-size);
	padding: 32px 56px 24px;
	min-height: 158px;
	max-width: 780px;
	min-width: 660px;
	width: 780px;
	overflow: visible;
}

.calculator-section__tagline {
	font-family: var(--bm-font-nav);
	font-size: 20px;
	font-weight: 500;
	line-height: 0.9;
	color: #333333;
	margin: 0;
	text-align: center;
}

.calculator-section__form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	font-family: var(--bm-font-body);
}

.calculator-section__step {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.calculator-section__step[hidden] {
	display: none;
}

.calculator-section__row {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	grid-template-rows: auto minmax(40px, auto);
	gap: 0 8px;
	align-items: start;
}

/* Step 3 – 3 fields + button (Figma 1693-550) */
.calculator-section__row--contacts {
	grid-template-columns: 1fr 1fr 1fr auto;
}

.calculator-section__row--contacts .calculator-section__field:nth-child(1) {
	grid-column: 1;
}

.calculator-section__row--contacts .calculator-section__field:nth-child(2) {
	grid-column: 2;
}

.calculator-section__row--contacts .calculator-section__field:nth-child(3) {
	grid-column: 3;
}

.calculator-section__row--contacts .calculator-section__submit {
	grid-column: 4;
}

.calculator-section__field {
	position: relative;
	display: grid;
	grid-template-rows: subgrid;
	grid-row: 1 / -1;
	gap: 8px;
	min-width: 0;
}

.calculator-section__field:first-of-type {
	grid-column: 1;
}

.calculator-section__field:last-of-type {
	grid-column: 2;
}

.calculator-section__submit {
	grid-column: 3;
	grid-row: 2;
}

.calculator-section__field--dropdown {
	position: relative;
}

.calculator-section__label {
	font-size: 13px;
	font-weight: 500;
	line-height: 20px;
	color: #333333;
	display: block;
}

.calculator-section__field.is-invalid .calculator-section__label {
	color: #ff4600;
}

.calculator-section__field.is-invalid .calculator-section__input-wrap {
	border-color: #ff4600;
}

.calculator-section__error {
	position: absolute;
	top: 64px;
	left: 0;
	z-index: 0;
	display: block;
	font-family: var(--bm-font-nav);
	font-size: 12px;
	font-weight: 500;
	color: #ff4600;
	min-height: 0;
}

.calculator-section__input-wrap {
	position: absolute;
	top: 24px;
	left: 0;
	right: 0;
	display: block;
	border: 2px solid var(--bm-color-border-accent);
	border-radius: var(--bm-radius-pill);
	background: var(--bm-color-bg-page);
	overflow: hidden;
}

.calculator-section__field.is-open .calculator-section__input-wrap {
	border-radius: 24px;
	border: 2px solid var(--bm-color-border-accent);
	z-index: 3;
}

/* Step 2 – closed state radii (Figma 1693-480) */
.calculator-section__input-wrap--date {
	border-radius: 21px;
}

[data-step="2"] .calculator-section__field--dropdown .calculator-section__input-wrap:not(.calculator-section__input-wrap--date) {
	border-radius: 24px;
}

[data-step="2"] .calculator-section__field--dropdown.is-open .calculator-section__input-wrap {
	border-radius: 24px;
}

/* Step 3 – text fields without icon (Figma 1693-550) */
.calculator-section__input-wrap--text .calculator-section__input-inner {
	padding-left: 0;
}

.calculator-section__input-wrap--text {
	border-radius: 21px;
}

[data-step="3"] .calculator-section__field .calculator-section__input-wrap--text {
	border-radius: 23px;
}

.calculator-section__input-wrap--text .calculator-section__input-inner input {
	padding-left: 16px;
}

.calculator-section__input-icon {
	position: absolute;
	left: 12px;
	top: 18px;
	transform: translateY(-50%);
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--bm-color-text-muted);
	pointer-events: none;
}

.calculator-section__input-icon svg {
	width: 24px;
	height: 24px;
}

.calculator-section__input-inner {
	display: block;
}

.calculator-section__field input {
	width: 100%;
	height: 36px;
	padding: 0 1rem 0 44px;
	border: none;
	background: transparent;
	color: var(--bm-color-text-main);
	font-family: var(--bm-font-nav);
	font-size: 14px;
	-webkit-font-smoothing: antialiased;
}

.calculator-section__field input::placeholder {
	color: var(--bm-color-text-muted);
}

.calculator-section__field input:focus {
	outline: none;
	box-shadow: none;
	border: none;
}

.calculator-section__field input[type="date"] {
	font-family: var(--bm-font-nav);
	cursor: pointer;
}

.calculator-section__field input[type="date"]::-webkit-calendar-picker-indicator {
	opacity: 0;
	position: absolute;
	width: 100%;
	height: 100%;
	cursor: pointer;
}

/* Calculator dropdown: height in JS; option text opacity follows aria-hidden (like FAQ). */
.calculator-section__dropdown {
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	height: 0;
	overflow: hidden;
	background: var(--bm-color-bg-page);
	opacity: 0;
	transition: opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1);
}

.calculator-section__field.is-open .calculator-section__dropdown[aria-hidden="false"] {
	opacity: 1;
}

.calculator-section__field.is-open .calculator-section__dropdown {
	max-height: 192px;
	overflow-x: hidden;
	overflow-y: auto;
}

@media (prefers-reduced-motion: reduce) {
	.calculator-section__dropdown {
		transition: none;
	}
}

.calculator-section__dropdown::-webkit-scrollbar {
	width: 8px;
}

.calculator-section__dropdown::-webkit-scrollbar-track {
	background: #e5e7eb;
	border-radius: 4px;
}

.calculator-section__dropdown::-webkit-scrollbar-thumb {
	background: #9ca3af;
	border-radius: 4px;
}

.calculator-section__dropdown::-webkit-scrollbar-thumb:hover {
	background: #6b7280;
}

.calculator-section__dropdown-option {
	height: 32px;
	padding: 0 8px;
	display: flex;
	align-items: center;
	font-family: var(--bm-font-nav);
	font-size: 14px;
	font-weight: 500;
	line-height: 20px;
	color: #1a1f29;
	cursor: pointer;
	background-color: var(--bm-color-bg-page);
	transition: background-color 0.12s ease;
}

/* JS sets `hidden` while filtering; author `display:flex` would otherwise override the attribute. */
.calculator-section__dropdown-option[hidden] {
	display: none !important;
}

.calculator-section__dropdown-option:hover,
.calculator-section__dropdown-option:focus,
.calculator-section__dropdown-option[aria-selected="true"] {
	background-color: #ffecec;
	outline: none;
}

.calculator-section__submit {
	display: inline-flex;
	align-items: center;
	align-self: end;
	justify-content: center;
	gap: 4px;
	height: 40px;
	min-width: 144px;
	padding: 0 24px;
	border: none;
	border-radius: var(--bm-radius-pill);
	background: var(--bm-color-bg-cta);
	color: var(--bm-color-cta-text);
	font-family: var(--bm-font-nav);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.14px;
	text-transform: uppercase;
	cursor: pointer;
	transition:
		background-color 0.2s ease,
		color 0.2s ease;
	flex-shrink: 0;
}

.calculator-section__submit:hover,
.calculator-section__submit:focus {
	background: var(--bm-color-bg-cta-hover);
	color: var(--bm-color-cta-text-hover);
}

.calculator-section__submit-arrow {
	flex-shrink: 0;
}

/* Mobile styles – Figma 2129:910 (402px) */
@media (max-width: 1024px) {

	/*
	 * .beaver-main-pic uses align-items: center, so flex children shrink to content width.
	 * Without stretch, .calculator-section stays ~660px (its min-width) instead of filling up to 780px.
	 */
	.main__calculator-section {
		display: grid;
		grid-template-columns: 1fr;
		align-self: stretch;
		width: 100%;
		box-sizing: border-box;
		padding-left: 12px;
		padding-right: 12px;
		margin-top: 12px;
		gap: 28px;
	}

	.calculator-section {
		width: 100%;
		margin-left: auto;
		margin-right: auto;
		padding: 1.25rem 1rem;
	}

	.calculator-section__form {
		padding: 24px 16px;
	}

	.calculator-section__step {
		gap: 16px;
	}

	.calculator-section__tagline {
		font-size: 16px;
		padding: 0 32px;
	}
}

@media (max-width: 768px) {
	.main__calculator-section {
		gap: 0;
	}
}

/*
 * Tablet (601px–1024px): background + max-width.
 * Must come after @media (max-width: 1024px) which sets max-width: 100% on .calculator-section,
 * otherwise 780px cap is overridden.
 */
@media (min-width: 661px) and (max-width: 1024px) {
	.calculator-section {
		background-image: var(--bm-calculator-bg-image-tablet);
		background-size: var(--bm-calculator-bg-size-tablet);
		width: 100%;
		max-width: var(--bm-calculator-max-width-tablet);
		min-width: 0;
		width: 100%;
	}
}

@media (max-width: 660px) {
	.main__calculator-section {
		padding-left: 12px;
		padding-right: 12px;
		gap: 28px;
	}

	.calculator-section {
		background-image: url(../images/calculator-bg-mobile.svg);
		background-repeat: no-repeat;
		background-position: center center;
		background-size: var(--bm-calculator-bg-size-mobile);
		padding: 0;
		height: auto;
		min-height: 284px;
		min-width: 0;
	}

	.calculator-section__row {
		gap: 16px;
	}

	.calculator-section__form {
		max-width: 356px;
		margin: 0 auto;
	}

	.calculator-section__row {
		grid-template-columns: 1fr;
		grid-template-rows: auto;
	}

	.calculator-section__row .calculator-section__field:first-of-type,
	.calculator-section__row .calculator-section__field:last-of-type {
		grid-column: 1;
	}

	.calculator-section__row .calculator-section__submit {
		grid-column: 1;
		grid-row: auto;
	}

	/* Contacts row: name + email (2 cols each), phone (4 cols), CTA (4 cols) */
	.calculator-section__row--contacts {
		grid-template-columns: repeat(4, 1fr);
		grid-template-rows: auto auto auto;
	}

	.calculator-section__row--contacts .calculator-section__field:nth-child(1),
	.calculator-section__row--contacts .calculator-section__field:nth-child(2),
	.calculator-section__row--contacts .calculator-section__field:nth-child(3) {
		min-width: 0;
	}

	.calculator-section__row--contacts .calculator-section__field:nth-child(1) {
		grid-column: 1 / 3;
		grid-row: 1;
		grid-template-rows: auto auto auto;
		min-width: 0;
	}

	.calculator-section__row--contacts .calculator-section__field:nth-child(2) {
		grid-column: 3 / 5;
		grid-row: 1;
		grid-template-rows: auto auto auto;
		min-width: 0;
	}

	.calculator-section__row--contacts .calculator-section__field:nth-child(3) {
		grid-column: 1 / -1;
		grid-row: 2;
		grid-template-rows: auto auto auto;
		min-width: 0;
	}

	.calculator-section__row--contacts .calculator-section__submit {
		grid-column: 1 / -1;
		grid-row: 3;
		width: 100%;
		align-self: stretch;
	}

	.calculator-section__field:first-of-type,
	.calculator-section__field:last-of-type {
		grid-column: 1;
	}

	.calculator-section__submit {
		grid-column: 1;
		grid-row: auto;
		width: 100%;
		min-width: 0;
	}

	.calculator-section__field {
		grid-row: auto;
		grid-column: 1;
		display: flex;
		flex-direction: column;
		grid-template-rows: unset;
		min-height: 68px;
	}

	.calculator-section__input-wrap {
		top: 24px;
	}
}

/* Quote success dialog (Figma 1693-1289) */
.beaver-quote-dialog {
	--beaver-quote-dialog-dur: 0.3s;
	--beaver-quote-dialog-ease: cubic-bezier(0.33, 1, 0.68, 1);
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.beaver-quote-dialog[aria-hidden="true"] {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
	transition:
		opacity var(--beaver-quote-dialog-dur) var(--beaver-quote-dialog-ease),
		visibility 0s linear var(--beaver-quote-dialog-dur);
}

.beaver-quote-dialog[aria-hidden="false"] {
	opacity: 1;
	pointer-events: auto;
	visibility: visible;
	transition:
		opacity var(--beaver-quote-dialog-dur) var(--beaver-quote-dialog-ease),
		visibility 0s;
}

/* Exit: keep aria-open until transition ends (JS sets --closing, then aria-hidden) */
.beaver-quote-dialog[aria-hidden="false"].beaver-quote-dialog--closing {
	opacity: 0;
	pointer-events: none;
}

.beaver-quote-dialog__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
}

.beaver-quote-dialog__content {
	position: relative;
	background: var(--bm-color-bg-page);
	border-radius: 16px;
	padding: 32px 80px 64px;
	width: 420px;
	height: 193px;
	box-shadow:
		0 24px 38px rgba(0, 0, 0, 0.14),
		0 9px 46px rgba(0, 0, 0, 0.12),
		0 11px 15px rgba(0, 0, 0, 0.2);
	text-align: center;
	transform: translateY(8px) scale(0.98);
	opacity: 0;
	transition:
		transform var(--beaver-quote-dialog-dur) var(--beaver-quote-dialog-ease),
		opacity var(--beaver-quote-dialog-dur) var(--beaver-quote-dialog-ease);
}

.beaver-quote-dialog[aria-hidden="false"] .beaver-quote-dialog__content {
	transform: translateY(0) scale(1);
	opacity: 1;
}

.beaver-quote-dialog[aria-hidden="false"].beaver-quote-dialog--closing .beaver-quote-dialog__content {
	transform: translateY(6px) scale(0.99);
	opacity: 0;
}

@media (prefers-reduced-motion: reduce) {

	.beaver-quote-dialog[aria-hidden="true"],
	.beaver-quote-dialog[aria-hidden="false"],
	.beaver-quote-dialog__content,
	.beaver-quote-dialog[aria-hidden="false"] .beaver-quote-dialog__content,
	.beaver-quote-dialog[aria-hidden="false"].beaver-quote-dialog--closing .beaver-quote-dialog__content {
		transition-duration: 0.01ms;
		transition-delay: 0s;
	}
}

.beaver-quote-dialog__close {
	position: absolute;
	top: 12px;
	right: 12px;
	padding: 4px;
	background: none !important;
	border: none;
	cursor: pointer;
	color: var(--bm-color-text-main);
	box-shadow: none !important;
}

.beaver-quote-dialog__close:hover,
.beaver-quote-dialog__close:focus {
	color: var(--bm-color-text-body);
}

.beaver-quote-dialog__close:focus-visible {
	outline: 2px solid var(--bm-color-border-accent);
	outline-offset: 2px;
}

.beaver-quote-dialog__body {
	position: relative;
}

.beaver-quote-dialog__text-wrap {
	text-align: center;
}

.beaver-quote-dialog__image-wrap {
	position: absolute;
	bottom: -4px;
	right: -4px;
	width: 83px;
	height: 103px;
	line-height: 0;
	pointer-events: none;
}

.beaver-quote-dialog__image {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
	object-position: bottom right;
}

.beaver-quote-dialog__title {
	font-family: var(--bm-font-nav);
	font-size: 20px;
	font-weight: 600;
	line-height: normal;
	color: var(--bm-color-text-heading);
	text-transform: uppercase;
	margin: 0 0 0.5rem;
}

.beaver-quote-dialog__text {
	font-family: var(--bm-font-nav);
	font-size: 16px;
	font-weight: 500;
	line-height: 1.125;
	color: var(--bm-color-text-main);
	margin: 0;
}

@media (max-width: 736px) {
	.beaver-quote-dialog__content {
		min-width: 280px;
		max-width: 90vw;
	}
}