/*
 Theme Name:   Woodmart Child
 Description:  Woodmart Child Theme
 Author:       XTemos
 Author URI:   http://xtemos.com
 Template:     woodmart
 Version:      1.0.0
 Text Domain:  woodmart
*/

/**
 * Bottom-right floating buttons: stack them in one column instead of letting
 * them overlap. From the bottom up: reCAPTCHA badge, WhatsApp bubble (only
 * rendered on touch devices), scroll-to-top button. A slot collapses when
 * its element is not on the page.
 */
body {
	--float-gap: 12px;
	--float-base: 0px; /* bars fixed to the bottom of the screen */
	--float-recaptcha: 0px;
	--float-whatsapp: 0px;
	--float-recaptcha-bottom: calc(var(--float-base) + 14px);
	--float-whatsapp-bottom: calc(var(--float-recaptcha-bottom) + var(--float-recaptcha));
	--float-scrolltop-bottom: calc(var(--float-whatsapp-bottom) + var(--float-whatsapp));
}

body:has(.grecaptcha-badge) {
	--float-recaptcha: calc(60px + var(--float-gap));
}

body:has(.qlwapp__container) {
	--float-whatsapp: calc(60px + var(--float-gap));
}

/* Sticky add to cart bar on product pages */
body:has(.wd-sticky-btn-shown) {
	--float-base: var(--wd-sticky-btn-height);
}

@media (max-width: 1024px) {
	/* Mobile bottom navigation toolbar */
	body.sticky-toolbar-on {
		--float-base: 55px;
	}

	body.sticky-toolbar-on:has(.wd-sticky-btn-shown) {
		--float-base: calc(55px + var(--wd-sticky-btn-height));
	}
}

/* Google sets the position inline */
.grecaptcha-badge {
	bottom: var(--float-recaptcha-bottom) !important;
}

/* The bubble sits 24px above the bottom of its container */
body .qlwapp__container.qlwapp__container--bottom-right {
	bottom: calc(var(--float-whatsapp-bottom) - 24px);
}

/* WoodMart moves this button with its own sticky bar rules */
.scrollToTop {
	bottom: var(--float-scrolltop-bottom) !important;
}

/* Centre it over the 60px WhatsApp bubble, which is 20px from the edge */
body:has(.qlwapp__container) .scrollToTop {
	right: 25px;
}

@media (max-width: 1024px) {
	body:has(.qlwapp__container) .scrollToTop {
		right: 30px;
	}
}

/**
 * Contact Us: the map fills the height of the contact details column beside
 * it (the row is set to equal height). Stacked on phones, it keeps its own height.
 */
@media (min-width: 768px) {
	.gf-contact-map > .vc_column-inner > .wpb_wrapper {
		position: relative;
		flex-grow: 1;
	}

	/* The map element sets its height inline */
	.gf-contact-map .wd-map-container {
		position: absolute;
		inset: 0;
		height: auto !important;
	}
}

/**
 * Contact Us: the pop-up over the map pin. Google's newer pop-up adds an empty
 * title row above the content, and the theme forces the shop name to 300px wide,
 * so the name was cut off on phones and the address sat against the bottom edge.
 */
.gf-contact-map .gm-style .gm-style-iw-c {
	padding: 0 !important;
	max-width: min(300px, calc(100vw - 90px)) !important;
	border-radius: var(--wd-brd-radius, 0);
}

/* Empty title row: keep only the close button, placed over the top-right corner */
.gf-contact-map .gm-style .gm-style-iw-chr {
	position: absolute;
	top: 0;
	right: 0;
	z-index: 1;
}

.gf-contact-map .gm-style .gm-style-iw-ch {
	display: none;
}

.gf-contact-map .gm-style .gm-style-iw-chr > button {
	width: 40px !important;
	height: 40px !important;
	min-height: 0;
}

.gf-contact-map .gm-style .gm-style-iw-chr > button > span {
	width: 18px !important;
	height: 18px !important;
	margin: 11px !important;
}

.gf-contact-map .gm-style .gm-style-iw-d {
	overflow: auto !important;
	max-height: none !important;
	padding: 14px 40px 14px 16px;
	font-family: var(--wd-text-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--wd-text-color, #767676);
}

.gf-contact-map .gm-style .gm-style-iw-d h3 {
	min-width: 0 !important;
	margin: 0 0 4px !important;
	text-align: left !important;
	font-size: 16px;
	line-height: 1.3;
}

/* Delivery Info: carrier logos in the info boxes */
.gafshop-delivery-box .info-box-icon img {
	border-radius: 12px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

/**
 * Delivery Info: the boxes sit in one row laid out as a grid, so every box is
 * as tall as the tallest one, with the buttons lined up along the bottom.
 */
.vc_row.gafshop-delivery-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-auto-rows: 1fr;
}

.gafshop-delivery-grid > .vc_column_container {
	width: auto;
}

.gafshop-delivery-grid .wpb_wrapper,
.gafshop-delivery-grid .info-box-wrapper {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
}

.gafshop-delivery-grid .gafshop-delivery-box {
	flex-grow: 1;
}

.gafshop-delivery-grid .info-box-content {
	display: flex;
	flex-direction: column;
}

.gafshop-delivery-grid .info-btn-wrapper {
	margin-top: auto;
	padding-top: 15px;
}

@media (max-width: 1024px) {
	.vc_row.gafshop-delivery-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Stacked on phones, each box keeps its own height */
@media (max-width: 767px) {
	.vc_row.gafshop-delivery-grid {
		grid-template-columns: minmax(0, 1fr);
		grid-auto-rows: auto;
	}
}

/* Checkout and My Account addresses: each left-hand half field and each sub-heading starts a new row, so pairs of uneven height stay aligned */
.woocommerce-billing-fields__field-wrapper .form-row-first,
.woocommerce-address-fields__field-wrapper .form-row-first,
.woocommerce-billing-fields__field-wrapper .thwcfe-html-field-wrapper {
	clear: both;
}

/* Checkout: phone input (with country flag) fills its column like the other fields */
.woocommerce-billing-fields .iti {
	width: 100%;
}

/* Checkout: "Organisation details" starts a new group and matches the BILLING & SHIPPING heading */
.woocommerce-billing-fields__field-wrapper .thwcfe-html-field-wrapper {
	margin: 10px 0 20px;
	padding-top: 20px;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.woocommerce-billing-fields__field-wrapper .thwcfe-html-field-wrapper h4 {
	font-size: 22px;
	text-transform: uppercase;
}

/* Checkout: ID upload hint reads as help text */
#billing_service_id_card_field .description {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.5;
}

/* Checkout: ID upload button uses the theme's dark grey button colours. The invisible
   file input sits on top of the button, so the hover state is triggered from its wrapper. */
#billing_service_id_card_field .thwcfe-btn-file-upload {
	--btn-color: var(--btn-accented-color);
	--btn-bgcolor: var(--btn-accented-bgcolor);
	--btn-brd-radius: var(--btn-accented-brd-radius);
	--btn-box-shadow: var(--btn-accented-box-shadow);
}

#billing_service_id_card_field .upload-btn-wrapper:hover .thwcfe-btn-file-upload {
	color: var(--btn-accented-color-hover);
	background-color: var(--btn-accented-bgcolor-hover);
}

/* Checkout: "Additional information" gets the same divider as "Organisation details" */
.woocommerce-additional-fields {
	padding-top: 20px;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Checkout: shorter order notes box */
#order_comments {
	height: 110px;
	min-height: 110px;
}
