/*
 * The quote dialog ("Pyydä tarjous", inc/quote-modal.php + assets/quote-modal.js): a white panel in the middle of the
 * window over a navy veil, the Leadoo form in it. Square corners, no shadow (the site's buttons and cards); Oxygen and
 * the colours of the site (navy #1b2a57, accent #01a6e6). Up to 720px wide; on phones the panel is a full-height sheet.
 * The <dialog> element itself covers the window (transparent) so that a click outside the panel is a click on it.
 * Sizes come from the tokens of blocks.css (--ab-gutter, --ab-flow, --ab-tap); the fallbacks are the phone values.
 */

.ab-quote-modal {
	box-sizing: border-box;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: var(--ab-gutter, 20px);
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--body, #1b2a57);
	font-family: inherit;
	overflow: auto;
	overscroll-behavior: contain;
}

.ab-quote-modal[open] {
	display: grid;
	place-items: center;
}

.ab-quote-modal::backdrop {
	background: rgba(20, 35, 80, 0.72);
}

/* the page behind does not scroll (and does not jump when the scroll bar goes) */
html.ab-quote-modal-open {
	overflow: hidden;
	scrollbar-gutter: stable;
}

.ab-quote-modal__panel {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 720px;
	max-height: calc(100vh - 2 * var(--ab-gutter, 20px));
	max-height: calc(100dvh - 2 * var(--ab-gutter, 20px));
	padding: calc(var(--ab-tap, 44px) + 16px) 48px 40px;
	overflow: auto;
	overscroll-behavior: contain;
	background: #fff;
}

.ab-quote-modal__close {
	position: absolute;
	top: 8px;
	right: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--ab-tap, 44px);
	height: var(--ab-tap, 44px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--ab-navy, #1b2a57);
	cursor: pointer;
}

.ab-quote-modal__close:hover {
	color: var(--ab-accent-hover, #0194cd);
}

.ab-quote-modal__close:focus-visible,
.ab-quote-modal__btn:focus-visible,
.ab-quote-modal__alt a:focus-visible,
.ab-quote-trigger:focus-visible {
	outline: 2px solid var(--ab-accent, #01a6e6);
	outline-offset: 2px;
}

.ab-quote-modal__title {
	margin: 0;
	color: var(--ab-heading, #1b2a57);
	font-family: inherit;
	font-size: 28px;
	font-weight: 700;
	line-height: 1.2;
	overflow-wrap: break-word;
}

/* the note (loading, error, consent) takes the place of the form (Leadoo's form may bring a margin of its own on top) */
.ab-quote-modal__body {
	margin-top: var(--ab-flow, 16px);
}

.ab-quote-modal__msg {
	display: none;
	margin: 0 0 var(--ab-flow, 16px);
	font-size: 17px;
	line-height: 1.5;
}

.ab-quote-modal__body[data-state="loading"] [data-ab-msg="loading"],
.ab-quote-modal__body[data-state="error"] [data-ab-msg="error"],
.ab-quote-modal__body[data-state="consent"] [data-ab-msg="consent"] {
	display: block;
}

.ab-quote-modal__body[data-state="ready"] .ab-quote-modal__note,
.ab-quote-modal__body[data-state="idle"] .ab-quote-modal__note {
	display: none;
}

/* the phone number and the e-mail address while the form cannot be shown (error, consent): 44px rows (round 4 fix 2) */
.ab-quote-modal__contact {
	display: none;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	margin: 0 0 var(--ab-flow, 16px);
}

.ab-quote-modal__body[data-state="error"] .ab-quote-modal__contact,
.ab-quote-modal__body[data-state="consent"] .ab-quote-modal__contact {
	display: flex;
}

.ab-quote-modal__alt {
	margin: 0;
	font-size: 15px;
	line-height: 1.5;
}

.ab-quote-modal__alt a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ab-quote-modal__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--ab-tap, 44px);
	margin: 0;
	padding: 10px 24px;
	border: 0;
	border-radius: 0;
	background: var(--ab-navy, #1b2a57);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.2;
	cursor: pointer;
}

.ab-quote-modal__btn:hover {
	background: #0f1e4b;
}

.ab-quote-modal__form iframe {
	max-width: 100%;
}

/* the Gravity Forms contact form of the Swedish and English pages (data-mode="gf"; its look: the theme's forms.css) */
.ab-quote-modal__form--gf .gform_wrapper,
.ab-quote-modal__form--gf .gform_confirmation_wrapper {
	margin: 0;
}

.ab-quote-modal__form--gf .gform_confirmation_message {
	margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
	.ab-quote-modal[open] .ab-quote-modal__panel {
		animation: ab-quote-in 0.18s ease-out;
	}

	.ab-quote-modal[open]::backdrop {
		animation: ab-quote-fade 0.18s ease-out;
	}
}

@keyframes ab-quote-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ab-quote-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

/* phones: the panel is the whole screen */
@media (max-width: 768px) {
	.ab-quote-modal {
		padding: 0;
	}

	.ab-quote-modal[open] {
		place-items: stretch;
	}

	.ab-quote-modal__panel {
		max-width: none;
		height: 100vh;
		height: 100dvh;
		max-height: none;
		padding: calc(var(--ab-tap, 44px) + 12px) var(--ab-gutter, 20px) 32px;
	}

	.ab-quote-modal__title {
		font-size: 24px;
	}
}

/*
 * The contact card of the product pages' band (inc/forms-i18n.php ab_forms_contact_card(), round 4 phase B): a white
 * card with the forms' blue top line on the light band: "Kysyttävää tuotteesta?", one line of text, the quote button
 * (navy, bold, 48px) and the phone number and e-mail address as 44px links. On Finnish pages it follows the Leadoo slot
 * and shows only while the slot is empty (Leadoo blocked or not loaded): once Leadoo has put its bot in the slot the
 * card goes. Phones: the button full width, the two links under it.
 */
ld-slot:not(:empty) + .ab-contact-card {
	display: none;
}

/* (the empty slot is an empty inline element: no flow gap above the card) */
ld-slot:empty + .ab-contact-card {
	margin-top: 0;
}

/*
 * The fallback of a Leadoo bot in the content (inc/forms-i18n.php ab_forms_leadoo_fallbacks(), round 4 fix 2): the
 * contact card (the products page, the end of a Finnish article) or the note (the contact page's form card). Leadoo puts
 * its bot right after its script: the fallback shows only while it still directly follows the script (Leadoo blocked,
 * no consent, not loaded yet), and goes when the bot is there.
 */
.ab-leadoo-fallback {
	display: none;
}

script + .ab-leadoo-fallback {
	display: block;
}

.ab-contact-card {
	box-sizing: border-box;
	width: 100%;
	max-width: 880px;
	margin-inline: auto;
	padding: 32px 32px 36px;
	border: 1px solid #dfe3ea;
	border-top: 4px solid var(--ab-accent, #01a6e6);
	background: #fff;
	color: var(--ab-navy, #1b2a57);
}

/* at the end of an article's text (div.ab-leadoo-end: the bot's script, the bot once Leadoo has put it there, the
   card): a picture's gap from the text (the text's own rhythm is 14px; three classes beat .an-text.an-text.an-text > *);
   no gap while it holds only a script (an inpage bot shows elsewhere) */
.wp-block-post-content.wp-block-post-content.wp-block-post-content > .ab-leadoo-end {
	margin-block: 0;
}

.wp-block-post-content.wp-block-post-content.wp-block-post-content > .ab-leadoo-end:has(> :not(script)) {
	margin-block: var(--ab-flow-c, 32px);
}

.ab-leadoo-end > .ab-contact-card {
	margin-block: 0;
}

/* in a column beside a text (the products page's "Miksi Vestelli?") */
.wp-block-column > .ab-contact-card {
	margin-block: 0;
}

/* the note under the contact page's own heading: one line, the phone number and the e-mail address (centred like the
   card's heading and line); the consent row only while marketing consent is needed (assets/quote-modal.js) */
.ab-leadoo-note {
	margin-top: 24px;
	color: var(--ab-navy, #1b2a57);
	text-align: center;
}

.ab-leadoo-note.ab-leadoo-note.ab-leadoo-note .ab-leadoo-note__text {
	max-width: 60ch;
	margin: 0 auto;
	font-size: 17px;
	line-height: 1.5;
	text-wrap: balance;
}

.ab-leadoo-note__links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px 28px;
	margin-top: 12px;
}

.ab-leadoo-note__consent {
	margin-bottom: 20px;
}

.ab-leadoo-note__consent[hidden] {
	display: none;
}

.ab-leadoo-note.ab-leadoo-note .ab-leadoo-note__consent p {
	max-width: 60ch;
	margin: 0 auto 12px;
	font-size: 17px;
	line-height: 1.5;
}

.ab-contact-card.ab-contact-card.ab-contact-card .ab-contact-card__title {
	margin: 0;
	color: var(--ab-heading, #1b2a57);
	font-family: inherit;
	font-size: clamp(22px, 1.1rem + 0.8vw, 28px);
	font-weight: 700;
	line-height: 1.2;
}

.ab-contact-card.ab-contact-card.ab-contact-card .ab-contact-card__text {
	max-width: 60ch;
	margin: 8px 0 0;
	color: var(--ab-navy, #1b2a57);
	font-size: 17px;
	line-height: 1.5;
}

.ab-contact-card__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 28px;
	margin-top: 24px;
}

/* the quote button of the card */
a.ab-contact-card__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 48px;
	margin: 0;
	padding: 12px 28px;
	border: 0;
	border-radius: 0;
	background: var(--ab-navy, #1b2a57);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.2s ease;
}

a.ab-contact-card__btn:hover,
a.ab-contact-card__btn:focus-visible {
	background: #0f1e4b;
	color: #fff;
}

a.ab-contact-card__btn:focus-visible,
a.ab-contact-card__link:focus-visible {
	outline: 2px solid var(--ab-accent, #01a6e6);
	outline-offset: 2px;
}

a.ab-contact-card__link {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	color: var(--ab-navy, #1b2a57);
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
	overflow-wrap: anywhere;
}

a.ab-contact-card__link:hover {
	text-decoration-thickness: 2px;
}

a.ab-contact-card__link svg {
	flex: 0 0 auto;
}

@media (max-width: 768px) {
	.ab-contact-card {
		padding: 24px 20px 28px;
	}

	.ab-contact-card__actions {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
		margin-top: 20px;
	}

	.ab-contact-card__actions a.ab-contact-card__btn {
		width: 100%;
		margin-bottom: 4px;
	}

	.ab-leadoo-note__links {
		flex-direction: column;
		align-items: center;
		gap: 4px;
	}
}

/* the quote button on a card of a product list (avalon/product-list with quoteButton): the site's own button, as on
   the product cards (blocks.css .ab-product__buy); the selectors are as specific as WooCommerce's "a.button" rules */
.ab-plist .ab-plist__buy {
	margin-top: 12px;
}

.ab-plist--listing .ab-plist__buy {
	margin-top: 4px;
	padding: 0 20px 20px;
}

.ab-plist .ab-plist__buy a.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--ab-tap, 44px);
	margin: 0;
	padding: 10px 24px;
	border: 0;
	border-radius: 0;
	background: var(--ab-navy, #1b2a57);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}

.ab-plist .ab-plist__buy a.button:hover,
.ab-plist .ab-plist__buy a.button:focus-visible {
	background: #0f1e4b;
	color: #fff;
}

@media (min-width: 769px) and (max-width: 1024px) {
	.ab-plist--listing .ab-plist__buy {
		padding-inline: 16px;
	}
}

/* phones: the list is rows (a picture of 96px and the text beside it): the button goes under the text */
@media (max-width: 768px) {
	.ab-plist .ab-plist__item > .ab-plist__buy,
	.ab-plist--listing .ab-plist__buy {
		grid-column: 2;
		grid-row: 4;
		align-self: start;
		margin-top: 8px;
		padding: 0;
	}
}
