/* Product page (inc/product.php). Loaded after style.css; colours, fonts and --jkd-* variables come from there. Owner: product page.
   Design notes: docs/design/product.md. Selectors carry the Kadence prefix (.woocommerce div.product ...) where they must beat the parent theme's rules. */

/* ------------------------------------------------------------------ Page frame: photos left, buy column right */
.single-product div.product {
	display: grid;
	grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
	column-gap: 40px;
	align-items: start;
}
.single-product div.product::before,
.single-product div.product::after { content: none; }
.woocommerce div.product .jkd-media,
.woocommerce div.product .jkd-gallery div.images,
.woocommerce div.product div.summary { float: none; width: 100%; margin: 0; padding: 0; }
.single-product div.product > .woocommerce-tabs,
.single-product div.product > .jkd-about,
.single-product div.product > .jkd-related-head,
.single-product div.product > .related,
.single-product div.product > .up-sells { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ Gallery (WooCommerce's slider, restyled) */
.jkd-media { display: flex; flex-direction: column; gap: 12px; }
.jkd-gallery { position: relative; container-type: inline-size; }
/* The slider arrives with opacity 0 until its script runs; the first photo can show right away. */
.woocommerce div.product .jkd-gallery div.images { opacity: 1 !important; }

/* Every photo in a 4:3 dark frame; portrait garage shots sit on it instead of being cropped.
   The slider sets each slide's width itself; the cap (100cqw = the gallery's width) and the float only matter
   if that ever fails to happen, so a slide can't stretch across the slider's 600% wide track. */
.woocommerce div.product .jkd-gallery .woocommerce-product-gallery__image:nth-child(n) {
	display: block;
	aspect-ratio: 4 / 3;
	height: auto;
	max-width: 100cqw;
	margin: 0;
	border-radius: var(--jkd-radius);
	overflow: hidden;
	background: linear-gradient(150deg, var(--jkd-steel), #1b1d21 58%, var(--jkd-black));
}
.woocommerce div.product .jkd-gallery .flex-viewport .woocommerce-product-gallery__image:nth-child(n) { float: left; }
.jkd-gallery .woocommerce-product-gallery__image a { display: block; height: 100%; }
.woocommerce div.product .jkd-gallery div.images img { width: 100%; height: 100%; margin: 0; object-fit: contain; }
/* The viewport is as tall as the photo in it (all are 4:3), whatever height the slider measured. */
.jkd-gallery .flex-viewport { height: auto !important; border-radius: var(--jkd-radius); }

/* Before the script runs, the other photos stand in for the thumbnail row, so nothing jumps once it does. */
.woocommerce div.product .jkd-gallery .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) {
	display: inline-block;
	vertical-align: top;
	width: 76px;
	height: 76px;
	aspect-ratio: auto;
	margin: 10px 8px 0 0;
	border-radius: 6px;
}
.woocommerce div.product .jkd-gallery .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) img { object-fit: cover; }

/* Thumbnails: a row of squares under the photo, the current one outlined in red. Wraps when there are many
   (phones scroll it sideways instead, see below). */
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs {
	position: static;
	left: auto;
	transform: none;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	gap: 8px;
	width: 100%;
	max-width: none;
	margin: 10px 0 0;
	padding: 0;
}
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) {
	flex: 0 0 76px;
	width: 76px;
	height: 76px;
	margin: 0;
	padding: 0;
	border-radius: 6px;
	overflow: hidden;
	background: var(--jkd-black);
}
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) img {
	width: 100%;
	height: 100%;
	margin: 0;
	border: 0;
	border-radius: 6px;
	object-fit: cover;
	opacity: .6;
	cursor: pointer;
	transition: opacity .15s;
}
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) img:hover,
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) img.flex-active { opacity: 1; }
.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) img.flex-active { outline: 2px solid var(--jkd-red); outline-offset: -2px; }

/* Previous / next, centred on the big photo (not on photo plus thumbnails). Shown on hover and keyboard focus. */
.jkd-gallery .flex-direction-nav { list-style: none; margin: 0; padding: 0; }
.jkd-gallery .flex-direction-nav li { margin: 0; }
.jkd-gallery .flex-direction-nav a {
	position: absolute;
	top: 50%;
	z-index: 5;
	width: 44px;
	height: 44px;
	margin-top: -22px;
	border-radius: 50%;
	background: rgba(14, 15, 17, .72) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E") center / 20px no-repeat;
	opacity: 0;
	text-decoration: none;
	transition: opacity .15s;
}
.jkd-gallery--thumbs .flex-direction-nav a { top: calc(50% - 43px); }
.jkd-gallery .flex-direction-nav .flex-prev { left: 10px; }
.jkd-gallery .flex-direction-nav .flex-next { right: 10px; transform: scaleX(-1); }
.jkd-gallery:hover .flex-direction-nav a,
.jkd-gallery .flex-direction-nav a:focus-visible { opacity: 1; }
.jkd-gallery .flex-direction-nav a.flex-disabled { opacity: 0 !important; pointer-events: none; }

/* "Enlarge" (top right of the big photo): opens WooCommerce's lightbox on the current photo. */
.jkd-gallery__zoom {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 6;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #fff;
	color: var(--jkd-text);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
	transition: background .15s, color .15s;
}
.jkd-gallery__zoom:hover { background: var(--jkd-black); color: #fff; }
.jkd-gallery__zoom svg { width: 22px; height: 22px; }
/* WooCommerce's own trigger only appears with hover zoom, which is off; keep it hidden if that ever changes. */
.woocommerce div.product .jkd-gallery div.images .woocommerce-product-gallery__trigger { display: none; }

/* "1 / 3" top left, "Photos of this engine" bottom left of the big photo. */
.jkd-gallery__count,
.jkd-gallery__cap {
	position: absolute;
	z-index: 6;
	pointer-events: none;
	padding: 7px 9px;
	border-radius: 4px;
	font: 600 12px/1 var(--global-body-font-family, Saira, sans-serif);
}
.jkd-gallery__count { top: 10px; left: 10px; background: rgba(14, 15, 17, .78); color: #fff; letter-spacing: .04em; }
.jkd-gallery__cap { left: 10px; bottom: 10px; background: #fff; color: var(--jkd-text); }
.jkd-gallery--thumbs .jkd-gallery__cap { bottom: 96px; } /* 76px thumbnails + 10px gap + 10px */

/* ------------------------------------------------------------------ Start-up video */
.jkd-video__btn {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	margin: 0;
	padding: 8px;
	border: 1px solid var(--jkd-line);
	border-radius: var(--jkd-radius);
	background: #fff;
	color: var(--jkd-text);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: border-color .15s;
}
.jkd-video__btn:hover { border-color: var(--jkd-text); background: #fff; color: var(--jkd-text); }
.jkd-video__poster {
	position: relative;
	flex: 0 0 128px;
	aspect-ratio: 16 / 9;
	border-radius: 6px;
	overflow: hidden;
	background: var(--jkd-black);
}
.jkd-video__poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.jkd-video__play {
	position: absolute;
	inset: 0;
	width: 36px;
	height: 36px;
	margin: auto;
	border-radius: 50%;
	background: var(--jkd-red);
	color: #fff;
	display: grid;
	place-items: center;
}
.jkd-video__play svg { width: 16px; height: 16px; margin-left: 2px; }
.jkd-video__text b { display: block; font: 800 17px/1.1 var(--jkd-display); letter-spacing: .03em; text-transform: uppercase; }
.jkd-video__text span { display: block; margin-top: 3px; font-size: 13px; color: var(--jkd-muted); }
.jkd-video__frame { aspect-ratio: 16 / 9; border-radius: var(--jkd-radius); overflow: hidden; background: var(--jkd-black); }
.jkd-video__frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ------------------------------------------------------------------ Buy column */
.jkd-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.jkd-badge {
	font: 700 11.5px/1 var(--global-body-font-family, Saira, sans-serif);
	letter-spacing: .06em;
	text-transform: uppercase;
	padding: 6px 8px;
	border-radius: 3px;
	background: var(--jkd-grey);
	color: var(--jkd-text);
}
.jkd-badge--origin { background: var(--jkd-red); color: #fff; font-family: var(--jkd-display); font-size: 12.5px; letter-spacing: .1em; }
.jkd-badge--ok { background: var(--jkd-ok-bg); color: var(--jkd-ok); }
.jkd-badge--sold { background: var(--jkd-black); color: #fff; }
.single-product div.product .product_title { margin: 0 0 6px; font-size: clamp(27px, 2.8vw, 34px); line-height: 1.05; letter-spacing: .005em; }
.jkd-sku { margin: 0 0 14px; font-size: 13px; color: var(--jkd-muted); }
.jkd-pricebox { display: flex; align-items: baseline; gap: 10px; margin: 0 0 18px; }
.jkd-bigprice,
.jkd-bigprice .amount { font: 800 38px/1 var(--jkd-display); letter-spacing: .01em; color: var(--jkd-text); }
.jkd-tax { font-size: 13px; color: var(--jkd-muted); }

/* Spec table and delivery box share one grid: same radius, same padding, same left edge. */
.jkd-specs { display: grid; margin: 0 0 18px; border: 1px solid var(--jkd-line); border-radius: var(--jkd-radius); overflow: hidden; }
.jkd-specs > div {
	display: grid;
	grid-template-columns: 9.5em minmax(0, 1fr);
	gap: 10px;
	padding: 9px 14px;
	border-top: 1px solid var(--jkd-line);
	font-size: 14px;
	line-height: 1.4;
}
.jkd-specs > div:first-child { border-top: 0; }
.jkd-specs dt { margin: 0; color: var(--jkd-muted); font-weight: 400; }
.jkd-specs dd { margin: 0; font-weight: 600; }
.jkd-fits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.jkd-fits li { display: flex; gap: 8px; align-items: flex-start; margin: 0; }
.jkd-fits li::before { content: ""; width: 6px; height: 6px; margin-top: .5em; background: var(--jkd-red); flex-shrink: 0; }

.jkd-delivery { margin: 0 0 18px; }
.jkd-delivery__head { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.jkd-delivery__head span { color: var(--jkd-muted); font-weight: 500; }
.jkd-delivery__list { border: 1px solid var(--jkd-line); border-radius: var(--jkd-radius); overflow: hidden; }
.jkd-delivery__list > div {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 9px 14px;
	border-top: 1px solid var(--jkd-line);
	font-size: 14px;
	line-height: 1.4;
}
.jkd-delivery__list > div:first-child { border-top: 0; }
.jkd-delivery__list b { font-weight: 700; white-space: nowrap; }
.jkd-delivery__note { margin: 6px 0 0; font-size: 12.5px; color: var(--jkd-muted); }

/* Add to cart: full width, 52px, the quantity box beside it when a part is stocked in quantity. */
.single-product div.product form.cart { display: flex; gap: 10px; margin: 0 0 16px; }
.single-product div.product form.cart::before,
.single-product div.product form.cart::after { content: none; }
.single-product div.product form.cart .quantity { float: none; margin: 0; }
.single-product div.product form.cart .quantity:has(input[type="hidden"]) { display: none; }
.single-product div.product form.cart .qty {
	width: 76px;
	height: 52px;
	margin: 0;
	padding: 0 8px;
	border: 1px solid var(--jkd-line);
	border-radius: 4px;
	box-shadow: none;
	background: #fff;
	font-size: 16px;
	font-weight: 600;
	text-align: center;
	color: var(--jkd-text);
}
.single-product div.product form.cart .qty:focus { border-color: var(--jkd-text); outline: none; }
.single-product div.product form.cart .single_add_to_cart_button {
	flex: 1;
	float: none;
	height: 52px;
	line-height: 52px;
	padding: 0 18px;
	border-radius: 4px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
}

.jkd-assure { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; line-height: 1.4; color: var(--jkd-muted); }
.jkd-assure li { display: flex; gap: 10px; align-items: flex-start; margin: 0; }
.jkd-assure svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; color: var(--jkd-text); }
.jkd-assure a { color: var(--jkd-text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.jkd-assure a[href^="tel"] { font-weight: 700; text-decoration: none; }

/* Sold: the badge turns black and the button gives way to this box. */
.jkd-sold { margin: 0 0 16px; padding: 16px 18px; border: 1px solid var(--jkd-line); border-left: 4px solid var(--jkd-black); border-radius: var(--jkd-radius); }
.jkd-sold__title { margin: 0 0 4px; font: 800 20px/1.1 var(--jkd-display); text-transform: uppercase; letter-spacing: .01em; }
.jkd-sold p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--jkd-muted); }
.jkd-sold p a { color: var(--jkd-text); font-weight: 700; text-decoration: none; }
.jkd-sold .jkd-btn { margin-top: 14px; }
/* Product-page button (the sold box). Scoped so it can't restyle buttons elsewhere. */
.single-product .jkd-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 48px;
	padding: 0 20px;
	border-radius: 4px;
	background: var(--jkd-black);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	text-decoration: none;
}
.single-product .jkd-btn:hover { background: var(--jkd-steel); color: #fff; }

/* ------------------------------------------------------------------ Below the columns */
.jkd-about { margin: 32px 0 0; padding: 26px 0 0; border-top: 1px solid var(--jkd-line); }
.jkd-about h2 { margin: 0 0 10px; font-size: 24px; }
.jkd-about__text { max-width: 760px; }
.jkd-about p { margin: 0 0 1em; }
.jkd-about p:last-child { margin-bottom: 0; }
.jkd-related-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin: 36px 0 0;
	padding: 28px 0 0;
	border-top: 1px solid var(--jkd-line);
}
.jkd-related-head h2 { margin: 0; font-size: 24px; }
.jkd-related-head a {
	font-size: 13.5px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--jkd-red);
	text-decoration: none;
	white-space: nowrap;
}
.jkd-related-head a::after { content: " \2192"; }
.jkd-related-head a:hover { color: var(--jkd-text); }
.single-product div.product > .related.products { margin: 18px 0 0; }
/* Four related parts: two by two on small tablets, where the shop grid would leave one alone on a second row. */
@media (min-width: 576px) and (max-width: 1024px) {
	.single-product div.product > .related.products ul.products.grid-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ Sticky bar on phones (product.js shows it) */
.jkd-sticky {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 90;
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
	background: #fff;
	border-top: 1px solid var(--jkd-line);
	box-shadow: 0 -8px 24px -12px rgba(0, 0, 0, .25);
}
.jkd-sticky[hidden] { display: none; }
.jkd-sticky__in { display: flex; align-items: center; gap: 14px; max-width: 600px; margin: 0 auto; }
.jkd-sticky__price { display: flex; flex-direction: column; line-height: 1; }
.jkd-sticky__price .amount { font: 800 24px/1 var(--jkd-display); color: var(--jkd-text); }
.jkd-sticky__price small { margin-top: 3px; font-size: 11.5px; color: var(--jkd-muted); }
.jkd-sticky__btn {
	flex: 1;
	height: 48px;
	margin: 0;
	padding: 0 18px;
	border: 0;
	border-radius: 4px;
	background: var(--jkd-red);
	color: #fff;
	font: 700 14px/1 var(--global-body-font-family, Saira, sans-serif);
	letter-spacing: .06em;
	text-transform: uppercase;
	cursor: pointer;
}
.jkd-sticky__btn:hover { background: var(--global-palette2, #b0141f); }
body.jkd-sticky-on { padding-bottom: 76px; }

/* ------------------------------------------------------------------ Focus */
.jkd-video__btn:focus-visible,
.jkd-sticky__btn:focus-visible,
.single-product .jkd-btn:focus-visible,
.jkd-assure a:focus-visible,
.jkd-related-head a:focus-visible,
.jkd-sold a:focus-visible,
.jkd-gallery .flex-direction-nav a:focus-visible,
.jkd-gallery__zoom:focus-visible,
.single-product div.product form.cart .single_add_to_cart_button:focus-visible { outline: 2px solid var(--jkd-red); outline-offset: 2px; }

/* ------------------------------------------------------------------ Wide screens: the page is 1440px from here (1600px from 1800px) */
@media (min-width: 1440px) {
	.single-product div.product { column-gap: 56px; }
	.jkd-media { gap: 14px; }
	.single-product div.product .product_title { font-size: 38px; }
	.jkd-sku { font-size: 14px; }
	.jkd-bigprice,
	.jkd-bigprice .amount { font-size: 42px; }
	.jkd-tax { font-size: 14px; }
	.jkd-specs > div,
	.jkd-delivery__list > div { padding: 10px 16px; font-size: 15px; }
	.jkd-specs > div { grid-template-columns: 10em minmax(0, 1fr); }
	.jkd-delivery__head { font-size: 15px; }
	.jkd-delivery__note { font-size: 13px; }
	.single-product div.product form.cart .single_add_to_cart_button { height: 56px; line-height: 56px; font-size: 16px; }
	.single-product div.product form.cart .qty { width: 84px; height: 56px; }
	.jkd-assure { font-size: 14px; gap: 10px; }
	.woocommerce div.product .jkd-gallery .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) { width: 84px; height: 84px; margin: 12px 8px 0 0; }
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs { margin-top: 12px; }
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) { flex-basis: 84px; width: 84px; height: 84px; }
	.jkd-gallery--thumbs .flex-direction-nav a { top: calc(50% - 48px); }
	.jkd-gallery--thumbs .jkd-gallery__cap { bottom: 106px; } /* 84px thumbnails + 12px gap + 10px */
	.jkd-gallery__count,
	.jkd-gallery__cap { font-size: 13px; padding: 8px 10px; }
	.jkd-video__btn { padding: 10px; gap: 18px; }
	.jkd-video__poster { flex-basis: 160px; }
	.jkd-video__text b { font-size: 19px; }
	.jkd-video__text span { font-size: 14px; }
	.jkd-about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: 56px; margin-top: 40px; padding-top: 32px; }
	.jkd-about h2,
	.jkd-related-head h2 { font-size: 28px; }
	.jkd-about__text { font-size: 17px; }
	.jkd-related-head { margin-top: 44px; padding-top: 32px; }
	.jkd-related-head a { font-size: 14px; }
	.single-product div.product > .related.products { margin-top: 22px; }
}
@media (min-width: 1800px) {
	/* The buy column stops at 640px; the photos take the rest. */
	.single-product div.product { grid-template-columns: minmax(0, 1fr) minmax(0, 640px); column-gap: 64px; }
	.single-product div.product .product_title { font-size: 42px; }
	.jkd-bigprice,
	.jkd-bigprice .amount { font-size: 46px; }
	.woocommerce div.product .jkd-gallery .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) { width: 92px; height: 92px; }
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) { flex-basis: 92px; width: 92px; height: 92px; }
	.jkd-gallery--thumbs .flex-direction-nav a { top: calc(50% - 52px); }
	.jkd-gallery--thumbs .jkd-gallery__cap { bottom: 114px; } /* 92px thumbnails + 12px gap + 10px */
	.jkd-about { column-gap: 64px; }
}

/* ------------------------------------------------------------------ Tablets in portrait: one column, but desktop-size parts */
@media (min-width: 600px) and (max-width: 860px) {
	.single-product div.product .product_title { font-size: 32px; }
}

/* ------------------------------------------------------------------ Phones and small tablets */
@media (min-width: 861px) {
	.jkd-sticky { display: none !important; }
}
@media (max-width: 860px) {
	.single-product div.product { grid-template-columns: minmax(0, 1fr); row-gap: 22px; }
	.single-product div.product > .summary { grid-column: 1; }
	.jkd-gallery .flex-direction-nav { display: none; }
	.jkd-specs > div { grid-template-columns: 6.5em minmax(0, 1fr); padding: 9px 12px; }
	.jkd-delivery__list > div { padding: 9px 12px; }
	.single-product .kadence-breadcrumbs .kadence-breadcrumb-container { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 599px) {
	/* Thumbnails scroll sideways under a thumb instead of wrapping. */
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs { flex-wrap: nowrap; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs::-webkit-scrollbar { display: none; }
	.woocommerce div.product .jkd-gallery .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) { width: 64px; height: 64px; margin: 8px 8px 0 0; }
	.woocommerce div.product .jkd-gallery div.images .flex-control-thumbs li:nth-child(n) { flex-basis: 64px; width: 64px; height: 64px; }
	.jkd-gallery--thumbs .jkd-gallery__cap { bottom: 82px; } /* 64px thumbnails + 8px gap + 10px */
}
