/**
 * Product page — the buy group: COD line, category note, trust row, delivery
 * box, the phone buy bar and the reviews strip.
 * ==========================================================================
 * Loaded on product pages only, after product.css and product-details.css.
 * Markup is in inc/woocommerce-product-buy.php and
 * inc/woocommerce-product-trust.php.
 *
 * @package Preloved
 * @since   1.9.0
 * ========================================================================== */


/* ==========================================================================
   1. Under the price: Cash on Delivery and the category note
   ========================================================================== */

.product__cod,
.product__note {
	display: flex;
	align-items: flex-start;
	gap: var(--pl-space-2);
	margin: var(--pl-space-3) 0 0;
	font-size: var(--pl-body-sm);
	line-height: var(--pl-leading-snug);
}

.product__cod .icon,
.product__note .icon {
	flex: 0 0 auto;
	margin-block-start: 1px;
	color: var(--pl-green-700);
}

.product__cod strong {
	display: block;
	font-weight: 600;
}

.product__cod-ur {
	display: block;
	color: var(--pl-text-secondary);
	font-style: italic;
}

.product__note {
	color: var(--pl-green-800);
	font-weight: 600;
}

/* The buy form follows the COD line directly now; it needs the air the old
   specifications block used to give it. */
.product-single__summary .product__buy {
	margin-block-start: var(--pl-space-5);
}


/* ==========================================================================
   2. Trust row under the button
   ========================================================================== */

.product__trust {
	display: flex;
	flex-wrap: wrap;
	gap: var(--pl-space-2) var(--pl-space-4);
	margin: var(--pl-space-4) 0 0;
	padding: 0;
	list-style: none;
	font-size: var(--pl-body-sm);
	color: var(--pl-text-secondary);
}

.product__trust-item {
	display: inline-flex;
	align-items: center;
	gap: var(--pl-space-2);
	min-block-size: 44px;
}

.product__trust-item .icon {
	flex: 0 0 auto;
	color: var(--pl-primary);
}

.product__trust-item a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}


/* ==========================================================================
   3. Delivery box
   ========================================================================== */

.product__delivery {
	display: grid;
	gap: var(--pl-space-3);
	margin: var(--pl-space-4) 0 var(--pl-space-6);
	padding: var(--pl-space-4);
	background-color: var(--pl-peach-50);
	border-radius: var(--pl-radius);
	font-size: var(--pl-body-sm);
}

.product__delivery-line,
.product__delivery-days {
	display: flex;
	align-items: flex-start;
	gap: var(--pl-space-3);
	margin: 0;
}

.product__delivery .icon {
	flex: 0 0 auto;
	margin-block-start: 1px;
	color: var(--pl-primary);
}

.product__delivery-line.is-free {
	color: var(--pl-green-800);
}

.product__delivery-line.is-free .icon {
	color: var(--pl-green-700);
}

.product__delivery-link {
	display: inline-block;
	padding-block: var(--pl-space-2);
	font-weight: 600;
	color: var(--pl-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}


/* ==========================================================================
   4. Phone buy bar
   ========================================================================== */

.buy-bar {
	display: none;
}

@media (max-width: 1023px) {
	.buy-bar {
		position: fixed;
		inset-inline: 0;
		inset-block-end: 0;
		/* Header level: under the cart drawer, overlays, toasts and any
		   third-party cookie or chat layer, which all sit higher. */
		z-index: var(--pl-z-header);
		display: flex;
		align-items: center;
		gap: var(--pl-space-2);
		padding: var(--pl-space-2) var(--pl-gutter);
		padding-block-end: calc(var(--pl-space-2) + env(safe-area-inset-bottom));
		background-color: var(--pl-bg-elevated);
		border-block-start: 1px solid var(--pl-border);
		box-shadow: 0 -4px 16px rgb(0 0 0 / 0.08);
		transition: transform var(--pl-base) var(--pl-ease-out);
	}

	/* product.js hides it while the main button is on screen. */
	.buy-bar.is-hidden {
		transform: translateY(110%);
		visibility: hidden;
		transition: transform var(--pl-base) var(--pl-ease-in), visibility 0s linear var(--pl-base);
	}

	.buy-bar__info {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		min-inline-size: 0;
		line-height: var(--pl-leading-tight);
	}

	.buy-bar__price {
		font-family: var(--pl-font-display);
		font-size: var(--pl-price);
		font-weight: 700;
		white-space: nowrap;
	}

	.buy-bar__stock {
		font-size: var(--pl-caption);
		color: var(--pl-text-secondary);
	}

	.buy-bar__button {
		flex: 0 0 auto;
		min-block-size: 48px;
		padding-inline: var(--pl-space-5);
	}

	/* Icon only — the label stays for screen readers. */
	.buy-bar__whatsapp {
		flex: 0 0 48px;
		inline-size: 48px;
		min-block-size: 48px;
		padding: 0;
		justify-content: center;
	}

	.buy-bar__whatsapp > span:not(.screen-reader-text) {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	/* Room at the end of the page so the bar never covers the footer's last
	   line, and the add-to-cart toast lifted clear of it. */
	body.has-buy-bar {
		padding-block-end: calc(72px + env(safe-area-inset-bottom));
	}

	body.has-buy-bar .toast {
		inset-block-end: calc(80px + env(safe-area-inset-bottom));
	}
}

@media (prefers-reduced-motion: reduce) {
	.buy-bar,
	.buy-bar.is-hidden {
		transition: none;
	}
}


/* ==========================================================================
   5. Reviews strip
   ========================================================================== */

.product__reviews {
	padding-block: var(--pl-space-8);
	background-color: var(--pl-bg-sunken);
}

.product__reviews .section__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--pl-space-4);
	margin-block-end: var(--pl-space-5);
}

/* ==========================================================================
   6. Collapsed description
   ========================================================================== */

.disclosure--description {
	border-block: 1px solid var(--pl-border);
}

.disclosure--description .disclosure__title {
	font-family: var(--pl-font-display);
	font-size: var(--pl-h3);
}


/* ==========================================================================
   7. Gallery: video slide
   Here rather than in product.css, which is already past the size limit.
   ========================================================================== */

.gallery__play {
	position: relative;
	display: block;
	inline-size: 100%;
	block-size: 100%;
	color: #fff;
}

.gallery__play[hidden] {
	display: none;
}

.gallery__poster {
	filter: brightness(0.7);
}

.gallery__play-button {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 72px;
	block-size: 72px;
	padding-inline-start: 4px;
	background-color: rgb(0 0 0 / 0.55);
	border: 2px solid #fff;
	border-radius: 50%;
	transform: translate(-50%, -50%);
}

.gallery__player {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	border: 0;
	background-color: #000;
}

/* Nothing to enlarge on the video slide. */
.gallery.is-video .gallery__expand {
	display: none;
}

.gallery__thumb--video {
	position: relative;
}

.gallery__thumb-play {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	color: #fff;
	filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.6));
	transform: translate(-50%, -50%);
}


/* ==========================================================================
   8. Phone first screen
   An ad click lands here on a ~390 px phone. Before 1.9.0 the first screen
   held the photo and nothing else — the price started at ~850 px. These rules
   bring photo, name, price, grade and the Cash on Delivery line into roughly
   the first 700 px, above the buy bar. Desktop is unchanged.
   ========================================================================== */

@media (max-width: 639px) {
	/* "← Shop" — the phone's own back button does this, and the row cost
	   ~30 px of the first screen. Hidden, not removed: the markup stays. */
	.product-single .breadcrumbs {
		display: none;
	}

	.product-single__hero {
		gap: var(--pl-space-4);
	}

	/* Square, not 4:5 — 90 px back. The photo is shown whole in the lightbox. */
	.gallery__stage {
		aspect-ratio: 1 / 1;
	}

	/* Swipe, the arrows and the "1 / 5" counter already move between images;
	   the rail cost 76 px of the first screen to duplicate them. */
	.gallery__thumbs {
		display: none;
	}

	.product__title {
		margin-block-end: var(--pl-space-2);
		font-size: var(--pl-h2);
	}

	/* Price and grade on one line. */
	.product__price,
	.product__condition {
		display: inline-flex;
		align-items: center;
		vertical-align: middle;
		margin-block-end: var(--pl-space-2);
	}

	.product__price {
		margin-inline-end: var(--pl-space-3);
	}

	/* The badge itself links to the condition guide; the text link moves the
	   grade onto a second line, so it is left to the condition panel. */
	.product__condition-link {
		display: none;
	}

	.product__cod {
		margin-block-start: var(--pl-space-1);
	}
}


/* ==========================================================================
   1.11 — phone-first product page (inc/woocommerce-product-layout.php)
   ========================================================================== */

/* One COD line under the price. */
.product__cod--line { align-items: center; }

.product__cod--line strong { display: inline; }

.product-single__summary .product__buy { margin-block-start: var(--pl-space-3); }

.product-single__summary .product__stock { margin-block-end: 0; }

/* The description is one section among the others now, not a page heading. */
.product__sections .disclosure--description { border-block: 0; }

.product__sections .disclosure--description .disclosure__title {
	font-family: inherit;
	font-size: inherit;
}

/* Quantity beside Add to cart, Buy it now under both. */
.product__buy-row {
	display: flex;
	gap: var(--pl-space-2);
	align-items: stretch;
}

.product__add { flex: 1 1 auto; }

.product__buy-now { margin-block-start: var(--pl-space-2); }

.qty-stepper {
	display: flex;
	flex: 0 0 auto;
	align-items: stretch;
	border: 1px solid var(--pl-border-field);
	border-radius: var(--pl-radius-sm);
	background-color: var(--pl-bg-elevated);
}

.qty-stepper__btn {
	inline-size: 48px;
	min-block-size: 48px;
	padding: 0;
	background: none;
	border: 0;
	color: var(--pl-text);
	font: inherit;
	font-size: 1.25rem;
	cursor: pointer;
}

.qty-stepper__btn:focus-visible,
.qty-stepper__input:focus-visible { outline: 2px solid var(--pl-focus); outline-offset: -2px; }

.qty-stepper__input {
	inline-size: 2.5em;
	padding: 0;
	border: 0;
	background: none;
	color: var(--pl-text);
	font: inherit;
	font-size: max(16px, 1rem); /* No iOS zoom on focus. */
	font-weight: 600;
	text-align: center;
	-moz-appearance: textfield;
}

.qty-stepper__input::-webkit-inner-spin-button,
.qty-stepper__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* WhatsApp and the heart: one quiet row, not two more big buttons. */
.product__more-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--pl-space-2);
	margin-block: var(--pl-space-2) var(--pl-space-4);
}

.product__ask {
	display: inline-flex;
	align-items: center;
	gap: var(--pl-space-2);
	min-block-size: 48px;
	color: var(--pl-text);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.product__ask .icon { color: #1a7f45; }

.product__more-actions .wishlist-toggle--product { margin: 0; }

.product__more-actions .wishlist-toggle--product .wishlist-toggle__btn {
	inline-size: auto;
	min-block-size: 48px;
	block-size: auto;
	padding-inline: var(--pl-space-2);
	border: 0;
	font-weight: 600;
}

/* Sections: the description cut to a few lines until "Read more". */
.product__description-text.is-clamped {
	max-block-size: 9.5em;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
	mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

.read-more {
	min-block-size: 44px;
	padding: 0;
	background: none;
	border: 0;
	color: var(--pl-primary);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.read-more:focus-visible { outline: 2px solid var(--pl-focus); outline-offset: 2px; }

@media (max-width: 767px) {
	/* Said once, inside "Delivery & returns": the per-area days and the 24h line. */
	.product__delivery-days,
	.product__trust { display: none; }

	.product__delivery { margin-block: var(--pl-space-3); padding: var(--pl-space-3); }
}

/* Sticky bar: price, Add to cart, Buy now. */
@media (max-width: 1023px) {
	.buy-bar .buy-bar__button { padding-inline: var(--pl-space-3); }

	.buy-bar__price { font-size: var(--pl-body-lg); }
}

/* 1.12 — large text: the price row wraps instead of pushing the page wider
   (old price, new price and the grade on one unbreakable line). */
@media (max-width: 1023px) {
	.product__price { flex-wrap: wrap; max-inline-size: 100%; column-gap: var(--pl-space-2); }

	.product__price .woocommerce-Price-amount,
	.product__price del,
	.product__price ins { white-space: nowrap; }
}

/* 1.12 — large text: quantity and Add to cart wrap onto two lines rather
   than widen the page. */
.product__buy-row { flex-wrap: wrap; }

.product__buy-row .product__add { flex: 1 1 10rem; min-inline-size: 0; }
