/*
Theme Name: Auchterprint
Theme URI: https://auchterprint.co.uk
Author: Greenleaf Creative
Description: Fast, lean WooCommerce theme for Auchterprint - no page builder, no icon fonts, one stylesheet, one small script.
Version: 1.0.0
Requires PHP: 7.4
Text Domain: auchterprint
*/

/* =========================================================
   Reset & base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
	margin: 0;
	font-family: var( --ap-font-body );
	font-size: 16px;
	line-height: 1.6;
	color: var( --ap-ink );
	background: var( --ap-surface );
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 {
	font-family: var( --ap-font-head );
	font-weight: 700;
	line-height: 1.2;
	margin: 0 0 0.5em;
	color: var( --ap-ink );
}
h1 { font-size: clamp( 2rem, 4vw, 3rem ); }
h2 { font-size: clamp( 1.5rem, 3vw, 2.1rem ); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
button { font-family: inherit; }

:root {
	--ap-accent: #44236b;
	--ap-accent-dark: #341a53;
	--ap-ink: #282828;
	--ap-ink-muted: #666;
	--ap-surface: #fff;
	--ap-surface-alt: #f2f5f7;
	--ap-border: #e2e2e2;
	--ap-radius: 10px;
	--ap-transition: 0.2s ease;
	--ap-font-body: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--ap-font-head: "Merriweather", Georgia, serif;
	--ap-max: 1240px;
}

.ap-container {
	max-width: var( --ap-max );
	margin: 0 auto;
	padding: 0 24px;
}
.ap-container--narrow {
	max-width: 780px;
}
.ap-container--wide {
	max-width: 1440px;
}

.ap-site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}
.site-main {
	flex: 1 0 auto;
	padding: 48px 0;
}

/* =========================================================
   Buttons
   ========================================================= */
.ap-btn {
	display: inline-block;
	padding: 0.9em 2em;
	border-radius: 60px;
	font-weight: 600;
	font-size: 0.9rem;
	letter-spacing: 0.02em;
	cursor: pointer;
	border: 2px solid transparent;
	transition: background var( --ap-transition ), color var( --ap-transition ), border-color var( --ap-transition );
}
.ap-btn--primary {
	background: var( --ap-accent );
	color: #fff;
}
.ap-btn--primary:hover {
	background: var( --ap-accent-dark );
	color: #fff;
}
.ap-btn--outline {
	background: transparent;
	border-color: var( --ap-accent );
	color: var( --ap-accent );
}
.ap-btn--outline:hover {
	background: var( --ap-accent );
	color: #fff;
}

/* =========================================================
   Topbar + header
   ========================================================= */
.ap-topbar {
	background: var( --ap-ink );
	color: #fff;
	font-size: 0.8rem;
}
.ap-topbar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 24px;
}
.ap-topbar__phone {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #fff;
}
.ap-topbar__social {
	color: rgba( 255, 255, 255, 0.8 );
}

.ap-header {
	background: #fff;
	border-bottom: 1px solid var( --ap-border );
	position: sticky;
	top: 0;
	z-index: 50;
}
.ap-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding: 14px 24px;
}
.ap-header__branding img {
	max-height: 56px;
	width: auto;
}
.ap-header__site-name {
	font-family: var( --ap-font-head );
	font-weight: 700;
	font-size: 1.4rem;
	color: var( --ap-accent );
}

.ap-nav__list {
	display: flex;
	gap: 28px;
}
.ap-nav__list a {
	font-weight: 600;
	font-size: 0.95rem;
	padding: 6px 0;
	border-bottom: 2px solid transparent;
	transition: border-color var( --ap-transition ), color var( --ap-transition );
}
.ap-nav__list a:hover {
	color: var( --ap-accent );
	border-color: var( --ap-accent );
}

/*
 * Mega menu, built for the real menu structure (checked against the live HTML):
 * a genuine 3-tier nav - "All Products" > category (Exhibition & Banners, Printing,
 * Signage, Construction, Stickers) > individual product links under each category
 * (Signage alone has 11). "About" and "Account" are plain 2-item dropdowns with no
 * further nesting.
 *
 * Only the FIRST level opens on hover (.ap-nav__list > li > .sub-menu) - it would be
 * bad UX to require hovering "All Products" and then separately hovering "Signage"
 * just to see products, so anything nested deeper than that (product links under a
 * category) is simply always visible, laid out as a static column, as soon as the
 * first-level panel is open. A panel that itself contains further nesting becomes a
 * multi-column grid (one column per category); a plain one-level dropdown (About,
 * Account) stays a simple narrow list.
 *
 * Desktop-only (min-width matches the mobile breakpoint below) - on mobile every
 * level just expands inline within the existing hamburger menu instead.
 */
@media ( min-width: 861px ) {
	.ap-nav__list li.menu-item-has-children {
		position: relative;
	}

	.ap-nav__list > li > .sub-menu {
		display: block;
		position: absolute;
		top: 100%;
		left: 50%;
		background: #fff;
		border: 1px solid var( --ap-border );
		border-radius: var( --ap-radius );
		box-shadow: 0 12px 32px rgba( 0, 0, 0, 0.12 );
		padding: 20px;
		z-index: 60;
		visibility: hidden;
		opacity: 0;
		transform: translateX( -50% ) translateY( 8px );
		transition: opacity var( --ap-transition ), transform var( --ap-transition ), visibility var( --ap-transition );
	}
	.ap-nav__list > li.menu-item-has-children:hover > .sub-menu,
	.ap-nav__list > li.menu-item-has-children:focus-within > .sub-menu {
		visibility: visible;
		opacity: 1;
		transform: translateX( -50% ) translateY( 0 );
	}

	/* Contains further nesting (e.g. "All Products") - true mega menu, one column per category. */
	.ap-nav__list > li > .sub-menu:has( .sub-menu ) {
		display: grid;
		grid-template-columns: repeat( auto-fit, minmax( 160px, 1fr ) );
		gap: 8px 28px;
		max-width: min( 920px, 90vw );
	}
	/* No further nesting (e.g. "About", "Account") - stays a simple narrow dropdown. */
	.ap-nav__list > li > .sub-menu:not( :has( .sub-menu ) ) {
		min-width: 200px;
	}

	.ap-nav__list .sub-menu a {
		display: block;
		padding: 6px 8px;
		border-bottom: none;
		border-radius: 6px;
		font-weight: 500;
		font-size: 0.9rem;
	}
	.ap-nav__list .sub-menu a:hover {
		background: var( --ap-surface-alt );
	}

	/* A category's own heading link (e.g. "Signage") sits above its product list. */
	.ap-nav__list > li > .sub-menu > li > a {
		font-weight: 700;
		font-size: 0.8rem;
		text-transform: uppercase;
		letter-spacing: 0.03em;
		color: var( --ap-accent );
	}

	/* Product links under a category - always visible once the panel is open, no second hover. */
	.ap-nav__list .sub-menu .sub-menu {
		position: static;
		display: block;
		box-shadow: none;
		border: none;
		background: none;
		padding: 2px 0 10px;
		min-width: 0;
	}
	.ap-nav__list .sub-menu .sub-menu a {
		font-weight: 500;
		font-size: 0.85rem;
		text-transform: none;
		color: var( --ap-ink );
	}
}

.ap-header__actions {
	display: flex;
	align-items: center;
}
.ap-cart-link {
	position: relative;
	display: inline-flex;
	color: var( --ap-ink );
}
.ap-cart-count {
	position: absolute;
	top: -8px;
	right: -10px;
	background: var( --ap-accent );
	color: #fff;
	font-size: 0.65rem;
	font-weight: 700;
	line-height: 1;
	padding: 3px 5px;
	border-radius: 999px;
	min-width: 16px;
	text-align: center;
}

.ap-nav-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 4px;
	width: 32px;
	height: 32px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
}
.ap-nav-toggle__bar {
	display: block;
	width: 100%;
	height: 2px;
	background: var( --ap-ink );
}

@media ( max-width: 860px ) {
	.ap-nav-toggle { display: flex; }
	.ap-topbar__social { display: none; }
	.ap-nav {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		background: #fff;
		border-bottom: 1px solid var( --ap-border );
		padding: 12px 24px 20px;
	}
	.ap-nav.is-open { display: block; }
	.ap-nav__list {
		flex-direction: column;
		gap: 4px;
	}
	.ap-nav__list a { display: block; padding: 10px 0; }
}

/* =========================================================
   Hero
   ========================================================= */
.ap-hero {
	background: linear-gradient( 135deg, var( --ap-accent ) 0%, var( --ap-accent-dark ) 100% );
	color: #fff;
	padding: 96px 0;
	text-align: center;
}
.ap-hero__inner {
	max-width: 720px;
}
.ap-hero h1 {
	color: #fff;
	font-size: clamp( 2.2rem, 5vw, 3.4rem );
}
.ap-hero p {
	color: rgba( 255, 255, 255, 0.85 );
	font-size: 1.1rem;
	margin-bottom: 1.5em;
}
.ap-hero .ap-btn--primary {
	background: #fff;
	color: var( --ap-accent );
}
.ap-hero .ap-btn--primary:hover {
	background: var( --ap-surface-alt );
}

/* =========================================================
   USPs
   ========================================================= */
.ap-usps {
	padding: 56px 0;
	border-bottom: 1px solid var( --ap-border );
}
.ap-usps__grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 200px, 1fr ) );
	gap: 32px;
	text-align: center;
}
.ap-usp svg {
	color: var( --ap-accent );
	margin-bottom: 12px;
}
.ap-usp h3 {
	margin-bottom: 0.25em;
	font-size: 1rem;
}
.ap-usp p {
	color: var( --ap-ink-muted );
	font-size: 0.9rem;
	margin: 0;
}

/* =========================================================
   Category promo cards
   ========================================================= */
.ap-categories {
	padding: 64px 0;
	background: var( --ap-surface-alt );
}
.ap-categories__grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 260px, 1fr ) );
	gap: 24px;
}
.ap-category-card {
	background: #fff;
	border-radius: var( --ap-radius );
	padding: 32px;
	text-align: center;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.04 ), 0 8px 24px rgba( 0, 0, 0, 0.05 );
}
.ap-category-card p {
	color: var( --ap-ink-muted );
}

/* Page-template-specific styles (page hero, About intro/stats, CTA band,
 * Contact form) live in assets/css/pages.css - only enqueued when a custom
 * page template is active, see ap_enqueue_assets() in functions.php. */

/* =========================================================
   Trending products
   ========================================================= */
.ap-trending {
	padding: 64px 24px;
}
.ap-section-heading {
	text-align: center;
	margin-bottom: 1.2em;
}

/* =========================================================
   WooCommerce - shop loop
   ========================================================= */
.woocommerce ul.products {
	/* Fixed 4 columns rather than auto-fit: this matches what the shortcode/loop
	 * actually declares (columns="4" / loop_shop_columns), so the column count
	 * is deterministic instead of being recalculated from available width -
	 * auto-fit was producing an inconsistent column count between rows. */
	display: grid;
	grid-template-columns: repeat( 4, 1fr );
	gap: 32px;
	list-style: none;
	margin: 0;
	padding: 0;
}
/* WooCommerce's own stylesheet applies a clearfix (::before/::after with
 * content:"") to ul.products, to contain its old float-based layout. Under
 * display:grid those generated-content pseudo-elements become real (empty)
 * grid items instead - the ::before was exactly the phantom first cell
 * pushing every real product one column to the right. */
.woocommerce ul.products::before,
.woocommerce ul.products::after {
	content: none;
}
@media ( max-width: 980px ) {
	.woocommerce ul.products {
		grid-template-columns: repeat( 3, 1fr );
	}
}
@media ( max-width: 700px ) {
	.woocommerce ul.products {
		grid-template-columns: repeat( 2, 1fr );
	}
}
@media ( max-width: 480px ) {
	.woocommerce ul.products {
		grid-template-columns: 1fr;
	}
}
.woocommerce ul.products li.product {
	/* WooCommerce's own stylesheet still ships a float-era `width: 22.05%` on this
	 * selector. Once the parent became a grid, that percentage resolved against the
	 * grid cell instead of the old float row - a cell that's already sized by
	 * grid-template-columns above, so the product ended up a fraction of a fraction
	 * of the row width. Reset explicitly rather than relying on load order to win. */
	width: auto !important;
	float: none !important;
	margin: 0 !important;

	display: flex;
	flex-direction: column;
	text-align: center;
	background: #fff;
	border: 1px solid var( --ap-border );
	border-radius: var( --ap-radius );
	padding: 20px;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.03 );
	transition: box-shadow var( --ap-transition ), transform var( --ap-transition );
}
.woocommerce ul.products li.product:hover {
	box-shadow: 0 16px 32px rgba( 0, 0, 0, 0.1 );
	transform: translateY( -4px );
}
/* Just the image/title/price link - the Add to Cart button is a separate sibling <a>
 * (per WooCommerce's own content-product.php), so a blanket `li.product a` selector
 * would have stretched that too. */
.woocommerce ul.products li.product a.woocommerce-loop-product__link {
	display: flex;
	flex-direction: column;
	flex: 1;
}
.woocommerce ul.products li.product img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: calc( var( --ap-radius ) - 4px );
	margin-bottom: 14px;
}
.woocommerce ul.products li.product .woocommerce-loop-product__title {
	font-family: var( --ap-font-body );
	font-size: 1rem;
	font-weight: 600;
	margin: 0 0 0.3em;
}
.woocommerce ul.products li.product .price {
	color: var( --ap-accent );
	font-weight: 700;
	margin-top: auto;
}
.woocommerce ul.products li.product .button {
	display: block;
	margin-top: 12px;
	text-align: center;
	background: var( --ap-ink );
	color: #fff;
	border-radius: 60px;
	padding: 0.7em 1.2em;
	font-size: 0.85rem;
	font-weight: 600;
	transition: background var( --ap-transition );
}
.woocommerce ul.products li.product .button:hover {
	background: var( --ap-accent );
}
.woocommerce span.onsale {
	background: var( --ap-accent );
	border-radius: 999px;
	font-weight: 700;
}

/* =========================================================
   WooCommerce - single product
   ========================================================= */
.woocommerce div.product .product_title {
	font-size: 2rem;
}
.woocommerce div.product p.price,
.woocommerce div.product span.price {
	color: var( --ap-accent );
	font-size: 1.3rem;
	font-weight: 700;
}
.woocommerce div.product .single_add_to_cart_button {
	background: var( --ap-accent );
	border-radius: 60px;
	padding: 0.9em 2em;
	font-weight: 600;
}
.woocommerce div.product .single_add_to_cart_button:hover {
	background: var( --ap-accent-dark );
}

/* =========================================================
   WooCommerce - cart & checkout: keep close to defaults, just
   restyle primary buttons/links to match the rest of the site.
   ========================================================= */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit {
	background: var( --ap-accent );
	color: #fff;
	border-radius: 60px;
	font-weight: 600;
	border: none;
	padding: 0.8em 1.6em;
}
.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover {
	background: var( --ap-accent-dark );
	color: #fff;
}
.woocommerce table.shop_table th {
	background: var( --ap-surface-alt );
}

/* =========================================================
   Footer
   ========================================================= */
.ap-footer {
	background: var( --ap-ink );
	color: rgba( 255, 255, 255, 0.75 );
	margin-top: 64px;
}
.ap-footer__grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 200px, 1fr ) );
	gap: 32px;
	padding: 56px 24px 32px;
}
.ap-footer__brand {
	font-family: var( --ap-font-head );
	font-size: 1.3rem;
	font-weight: 700;
	color: #fff;
	margin-bottom: 0.4em;
}
.ap-footer__heading {
	color: #fff;
	font-size: 0.95rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 0.8em;
}
.ap-footer-links li {
	margin-bottom: 0.5em;
}
.ap-footer-links a:hover {
	color: #fff;
}
.ap-footer__legal {
	border-top: 1px solid rgba( 255, 255, 255, 0.1 );
	padding: 20px 24px;
	font-size: 0.8rem;
	text-align: center;
}

/* =========================================================
   Generic post/page content
   ========================================================= */
.ap-article__title a:hover { color: var( --ap-accent ); }
.ap-article { margin-bottom: 48px; }
.ap-archive-header { margin-bottom: 32px; }
.ap-no-results, .ap-404 { text-align: center; }
