/*
Theme Name: MotoWales Shoptimizer Child
Theme URI: https://motowales.co.uk/
Description: Upgrade-safe Shoptimizer child theme for the MotoWales WooCommerce website.
Author: MotoWales / Trans4 Ltd
Author URI: https://motowales.co.uk/
Template: shoptimizer
Version: 1.5.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: motowales-shoptimizer-child
*/

/*
 * MotoWales wide-store layout.
 *
 * This deliberately builds on Shoptimizer rather than replacing its templates.
 * It keeps future parent-theme updates straightforward and avoids adding another
 * front-end framework or JavaScript dependency.
 */

/*
 * MOTOWALES COLOUR SETTINGS
 * -------------------------
 * Change the values in this block to recolour the header and navigation.
 * All header rules below use these variables; do not edit Shoptimizer itself.
 */
:root {
	--mw-container: 1680px;
	--mw-gutter: clamp(16px, 2.1vw, 36px);

	--mw-header-background: #000000;
	--mw-header-text: #ffffff;
	--mw-header-muted: #f9f9f9;
	--mw-header-border: #d0d0d0;
	--mw-header-accent: #d71920;
	--mw-navigation-hover: #ffffff;
	--mw-dropdown-background: #000000;
	--mw-dropdown-text: #ffffff;

	--mw-search-background: #ffffff;
	--mw-search-text: #000000;
	--mw-search-line: #bbbfc4;
	--mw-search-focus-ring: rgba(215, 25, 32, 0.18);

	--mw-text: #444444;
	--mw-surface: #ffffff;
}

/* Wider, consistent page frame. */
.motowales-wide-store .col-full,
.motowales-wide-store .footer-widgets,
.motowales-wide-store .site-info {
	box-sizing: border-box;
	width: min(calc(100% - (2 * var(--mw-gutter))), var(--mw-container));
	max-width: var(--mw-container);
	margin-right: auto;
	margin-left: auto;
	padding-right: 0;
	padding-left: 0;
}

.motowales-wide-store .elementor-section.elementor-section-boxed > .elementor-container,
.motowales-wide-store .e-con-boxed > .e-con-inner {
	max-width: var(--mw-container) !important;
}

/*
 * Preserve the current MotoWales header identity while widening its contents.
 * MotoWales uses one seamless black band across the top bar, main header
 * and primary navigation, with white text and a compact white search field.
 */
.motowales-wide-store .topbar-wrapper,
.motowales-wide-store .site-header,
.motowales-wide-store .col-full-nav {
	background-color: var(--mw-header-background) !important;
	background-image: none !important;
}

/*
 * Shoptimizer/Customizer can target these rows with more specific selectors.
 * Match the actual live header classes so no white background remains behind
 * the top-bar content, logo, search, account links or primary navigation.
 */
body.motowales-wide-store .col-full.topbar-wrapper.hide-on-mobile,
body.motowales-wide-store header.site-header,
body.motowales-wide-store .site-header .main-header.col-full,
body.motowales-wide-store .site-header .site-branding,
body.motowales-wide-store .site-header .site-search,
body.motowales-wide-store .site-header .secondary-navigation,
body.motowales-wide-store .col-full-nav,
body.motowales-wide-store .col-full-nav .shoptimizer-primary-navigation.col-full {
	background-color: var(--mw-header-background) !important;
	background-image: none !important;
}

body.motowales-wide-store .site-header .woocommerce-product-search,
body.motowales-wide-store .site-header .woocommerce-product-search .search-field {
	background-color: var(--mw-search-background) !important;
}

/*
 * Some Shoptimizer header layouts place search, menu and basket directly in
 * this wrapper. Keep these selectors independent of the child body class so
 * cached body markup or a body-class optimisation cannot leave the row white.
 */
html body .shoptimizer-primary-navigation.col-full,
html body .shoptimizer-primary-navigation.col-full #site-navigation.main-navigation,
html body .shoptimizer-primary-navigation.col-full .primary-navigation,
html body .shoptimizer-primary-navigation.col-full .menu-primary-menu-container,
html body .shoptimizer-primary-navigation.col-full ul#menu-primary-menu,
html body .shoptimizer-primary-navigation.col-full .site-header-cart,
html body .shoptimizer-primary-navigation.col-full .shoptimizer-cart {
	background-color: var(--mw-header-background) !important;
	background-image: none !important;
}

html body .shoptimizer-primary-navigation.col-full .site-search {
	background-color: transparent !important;
	background-image: none !important;
}

html body .shoptimizer-primary-navigation.col-full .woocommerce-product-search,
html body .shoptimizer-primary-navigation.col-full .woocommerce-product-search .search-field {
	background-color: var(--mw-search-background) !important;
}

.motowales-wide-store .topbar-wrapper.col-full {
	width: 100%;
	max-width: none;
	padding-right: var(--mw-gutter);
	padding-left: var(--mw-gutter);
}

.motowales-wide-store .topbar-wrapper,
.motowales-wide-store .topbar-wrapper a {
	color: var(--mw-header-text);
	font-family: Inter, sans-serif;
	font-size: 14px;
	font-weight: 400;
	line-height: 21px;
}

.motowales-wide-store .topbar-wrapper {
	border-bottom-color: var(--mw-header-border);
}

.motowales-wide-store .secondary-navigation a {
	color: var(--mw-header-muted);
	font-family: Inter, sans-serif;
	font-size: 14px;
	font-weight: 400;
	line-height: 21px;
}

.motowales-wide-store .main-navigation ul.menu > li > a,
.motowales-wide-store .site-header-cart .cart-contents {
	color: var(--mw-header-text);
	font-family: Inter, sans-serif;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.1px;
}

.motowales-wide-store .main-navigation ul.menu ul li > a {
	color: var(--mw-dropdown-text);
	font-family: Inter, sans-serif;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.4;
}

.motowales-wide-store .main-navigation .sub-menu-wrapper,
.motowales-wide-store .main-navigation .sub-menu-wrapper .container,
.motowales-wide-store .main-navigation ul.sub-menu {
	background-color: var(--mw-dropdown-background) !important;
}

.motowales-wide-store .main-navigation ul.menu > li > a:hover,
.motowales-wide-store .main-navigation ul.menu > li.current-menu-item > a,
.motowales-wide-store .main-navigation ul.menu > li.current-menu-parent > a {
	color: var(--mw-navigation-hover);
}

.motowales-wide-store .site-header-cart .count,
.motowales-wide-store .main-navigation .caret {
	border-color: var(--mw-header-accent);
	color: var(--mw-header-accent);
}

/* Desktop header: current proportions, but with more width available to search. */
@media (min-width: 993px) {
	.motowales-wide-store .main-header.col-full {
		display: flex;
		align-items: center;
		gap: clamp(24px, 3vw, 48px);
		min-height: 69px;
		padding-top: 5px;
		padding-bottom: 4px;
	}

	.motowales-wide-store .main-header .site-branding {
		flex: 0 0 256px;
		width: 256px;
	}

	.motowales-wide-store .main-header .site-branding img {
		width: 100%;
		max-height: 60px;
		object-fit: contain;
	}

	.motowales-wide-store .main-header .site-search {
		flex: 1 1 505px;
		width: auto;
		max-width: none;
		margin-left: 0 !important;
	}

	.motowales-wide-store .main-header .secondary-navigation {
		flex: 0 0 auto;
		padding-left: 0;
	}

	.motowales-wide-store .shoptimizer-primary-navigation.col-full {
		display: flex;
		align-items: stretch;
		gap: 0;
		height: 60px;
	}

	.motowales-wide-store .main-navigation,
	.motowales-wide-store .menu-primary-menu-container {
		width: auto;
	}

	.motowales-wide-store .main-navigation {
		flex: 1 1 auto;
	}

	.motowales-wide-store .main-navigation ul.menu > li > a,
	.motowales-wide-store .site-header-cart .cart-contents {
		line-height: 60px;
	}
}

/* Match the current clean 40px white CommerceKit/WooCommerce search field. */
.motowales-wide-store .site-search .woocommerce-product-search {
	position: relative;
	display: block;
	width: 100%;
	height: 40px;
	margin: 0;
	background: var(--mw-search-background);
}

.motowales-wide-store .site-search .search-field {
	width: 100%;
	height: 40px;
	padding: 12px 15px;
	border: 1px solid var(--mw-search-line);
	border-radius: 0;
	background: var(--mw-search-background);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	color: var(--mw-search-text);
	font-family: Muli, sans-serif;
	font-size: 16px;
}

.motowales-wide-store .site-search .search-field:focus {
	border-color: var(--mw-header-accent);
	outline: 2px solid var(--mw-search-focus-ring);
	outline-offset: 0;
}

/* Retain Shoptimizer's present menu states; only distribute links more evenly. */
.motowales-wide-store .main-navigation ul.menu > li > a {
	padding-right: clamp(8px, 0.75vw, 14px);
	padding-left: clamp(8px, 0.75vw, 14px);
}

/* Cleaner, denser product cards for a four-column catalogue. */
.motowales-wide-store.woocommerce-shop ul.products,
.motowales-wide-store.tax-product_cat ul.products,
.motowales-wide-store.tax-product_brand ul.products {
	gap: 24px 18px;
}

.motowales-wide-store ul.products li.product {
	box-sizing: border-box;
	padding: 14px 14px 18px;
	border: 1px solid #e6e6e6;
	border-radius: 3px;
	background: #fff;
	transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.motowales-wide-store ul.products li.product:hover {
	border-color: #c9c9c9;
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.motowales-wide-store ul.products li.product .woocommerce-loop-product__title {
	display: -webkit-box;
	overflow: hidden;
	min-height: 2.8em;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.motowales-wide-store ul.products li.product img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: #fff;
}

/* Keep basket and checkout pages focused and comfortably readable. */
.motowales-wide-store.woocommerce-cart .site-content > .col-full,
.motowales-wide-store.woocommerce-checkout .site-content > .col-full,
.motowales-wide-store.woocommerce-account .site-content > .col-full {
	max-width: 1280px;
}

/* Search remains visible without opening the menu on phones and tablets. */
@media (max-width: 992px) {
	.motowales-wide-store .main-header.col-full {
		display: flex;
		flex-wrap: wrap;
		width: calc(100% - 32px);
		padding-top: 10px;
		padding-bottom: 12px;
	}

	.motowales-wide-store .main-header .site-search {
		display: block !important;
		order: 20;
		flex: 1 0 100%;
		width: 100%;
		max-width: none;
		margin: 10px 0 0 !important;
	}

	.motowales-wide-store .site-search .woocommerce-product-search,
	.motowales-wide-store .site-search .search-field {
		height: 46px;
	}
}

@media (max-width: 600px) {
	.motowales-wide-store .col-full,
	.motowales-wide-store .footer-widgets,
	.motowales-wide-store .site-info {
		width: calc(100% - 32px);
	}

	.motowales-wide-store .site-search .search-field {
		padding-right: 12px;
		padding-left: 12px;
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.motowales-wide-store ul.products li.product {
		transition: none;
	}
}
