/**
 * Single product ([tp_product])
 * Builds on home.css (TPTrue tokens, .tp-btn, .tp-cart-btn, .tp-card, .tp-grid live there).
 * Layout: left column = gallery then description (7fr); right column = sticky buy box + details (5fr) → related grid.
 * Radius rule (same as home): buttons, chips, price = full pill; media and panels = 16px.
 */

.tp-product-page {
	padding-bottom: 112px;
}

/* ---------- Breadcrumb ---------- */

.tp-crumbs ol {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 28px 0 24px;
	font-size: 14px;
	line-height: 1.4;
	list-style: none;
	color: var(--tp-muted);
}

.tp-crumbs li {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.tp-crumbs li + li::before {
	content: "/";
	color: var(--tp-border);
}

.tp-crumbs a {
	color: var(--tp-muted);
	text-decoration: none;
}

.tp-crumbs a:hover {
	color: var(--tp-ink);
}

.tp-crumbs [aria-current="page"] {
	overflow: hidden;
	max-width: 40ch;
	white-space: nowrap;
	text-overflow: ellipsis;
	color: var(--tp-ink);
}

/* ---------- Top: gallery + buy box ---------- */

.tp-pd {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
	grid-template-areas:
		"gallery side"
		"desc    side";
	grid-template-rows: auto 1fr;
	column-gap: 56px;
	row-gap: 64px;
	align-items: start;
}

.tp-pd__gallery { grid-area: gallery; }
.tp-pd__desc { grid-area: desc; min-width: 0; }

/* Right column: buy box + details travel together while the left column scrolls. */
.tp-pd__side {
	grid-area: side;
	position: sticky;
	top: 24px;
	display: flex;
	flex-direction: column;
	gap: 24px;
	min-width: 0;
	/* Taller than the screen: scroll inside the column instead of cutting off its bottom. */
	max-height: calc(100dvh - 48px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	/* Room for the focus rings and shadows that overflow:auto would clip. */
	padding: 4px;
	margin: -4px;
}

.tp-pd__stage {
	position: relative;
	margin: 0;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--tp-surface);
	border-radius: var(--tp-r-media);
	box-shadow: inset 0 0 0 1px var(--tp-hairline);
}

.tp-pd__stage img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.25s var(--tp-ease);
}

.tp-pd__stage img.is-loading {
	opacity: 0.4;
}

.tp-pd__stage .tp-card__badge {
	top: 16px;
	left: 16px;
}

.tp-pd__thumbs {
	display: flex;
	gap: 12px;
	margin-top: 12px;
	overflow-x: auto;
	scrollbar-width: none;
}

.tp-pd__thumb {
	flex: none;
	width: 96px;
	aspect-ratio: 4 / 3;
	padding: 0;
	overflow: hidden;
	background: var(--tp-surface);
	border: 0;
	border-radius: 10px;
	box-shadow: inset 0 0 0 1px var(--tp-hairline);
	cursor: pointer;
	opacity: 0.6;
	transition: opacity 0.2s var(--tp-ease), box-shadow 0.2s var(--tp-ease);
}

.tp-pd__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tp-pd__thumb:hover {
	opacity: 1;
}

.tp-pd__thumb[aria-pressed="true"] {
	opacity: 1;
	box-shadow: 0 0 0 2px var(--tp-primary);
}

/* Buy box */
.tp-buy {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	padding: 32px;
	background: #fff;
	border-radius: var(--tp-r-media);
	box-shadow: inset 0 0 0 1px var(--tp-hairline), var(--tp-shadow);
}

.tp-buy__cat {
	display: inline-flex;
	padding: 4px 12px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	color: var(--tp-primary);
	text-decoration: none;
	background: var(--tp-tint);
	border-radius: var(--tp-r-pill);
	transition: background-color 0.2s var(--tp-ease);
}

.tp-buy__cat:hover {
	color: var(--tp-primary);
	background: #e2eaff;
}

.tp-buy__title {
	margin: 16px 0 0;
	font-size: clamp(26px, 2.4vw, 34px);
	font-weight: 500;
	line-height: 1.18;
	letter-spacing: -0.02em;
	color: var(--tp-ink);
	text-wrap: balance;
}

.tp-buy__lead {
	margin-top: 12px;
	font-size: 15px;
	line-height: 1.6;
	color: var(--tp-muted);
}

.tp-buy__lead p {
	margin: 0;
}

.tp-buy__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	margin-top: 24px;
	font-size: 32px;
	font-weight: 600;
	line-height: 1.1;
	color: var(--tp-ink);
}

.tp-buy__price ins {
	order: -1;
	text-decoration: none;
}

.tp-buy__price del {
	font-size: 17px;
	font-weight: 400;
	color: var(--tp-muted);
}

.tp-buy__price del .woocommerce-Price-amount {
	color: var(--tp-muted);
}

/* Two equal buttons side by side: "Mua ngay" solid blue, "Thêm vào giỏ" blue outline. */
.tp-buy__actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	width: 100%;
	margin-top: 24px;
}

.tp-btn--block {
	width: 100%;
}

.tp-home .tp-buy__actions .tp-btn,
.tp-home .tp-buy__actions .tp-cart-btn {
	justify-content: center;
	gap: 8px;
	min-width: 0;
	min-height: 50px;
	padding: 12px 16px;
	font-size: 15px;
	font-weight: 600;
	border-radius: 12px;
	transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tp-home .tp-buy__actions .tp-btn--primary {
	color: #fff;
	background: var(--tp-primary);
	box-shadow: 0 1px 2px rgba(14, 74, 224, 0.35), 0 8px 18px -8px rgba(21, 93, 255, 0.55);
}

.tp-home .tp-buy__actions .tp-btn--primary:hover,
.tp-home .tp-buy__actions .tp-btn--primary:focus-visible {
	color: #fff;
	background: var(--tp-primary-hover);
	transform: translateY(-1px);
}

.tp-home .tp-buy__actions .tp-btn--primary:active {
	background: var(--tp-primary-press);
	box-shadow: none;
	transform: translateY(1px);
}

.tp-home .tp-buy__actions .tp-cart-btn:not(.is-in-cart) {
	color: var(--tp-primary);
	background: #fff;
	box-shadow: inset 0 0 0 1.5px var(--tp-primary);
}

.tp-home .tp-buy__actions .tp-cart-btn:not(.is-in-cart):hover,
.tp-home .tp-buy__actions .tp-cart-btn:not(.is-in-cart):focus-visible {
	color: var(--tp-primary-press);
	background: var(--tp-tint);
	box-shadow: inset 0 0 0 1.5px var(--tp-primary-press);
	transform: translateY(-1px);
}

.tp-home .tp-buy__actions .tp-cart-btn:not(.is-in-cart):active {
	background: #e2eaff;
	transform: translateY(1px);
}

/* In the cart: the green state from home.css, same size as the buy button */
.tp-home .tp-buy__actions .tp-cart-btn.is-in-cart {
	box-shadow: inset 0 0 0 1.5px #9bd9b0;
}

.tp-home .tp-buy__actions .tp-cart-btn span {
	overflow: hidden;
	text-overflow: ellipsis;
}

.tp-home .tp-buy__actions .added_to_cart {
	display: none;
}

/* Very narrow phones: stack so the labels never truncate */
@media (max-width: 359px) {
	.tp-buy__actions {
		grid-template-columns: 1fr;
	}
}

.tp-buy__soldout {
	margin: 24px 0 0;
	font-size: 15px;
	color: var(--tp-muted);
}

.tp-buy__demo {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 14px;
	font-size: 15px;
	font-weight: 500;
	color: var(--tp-primary);
	text-decoration: none;
}

.tp-buy__demo:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.tp-buy__perks {
	display: grid;
	gap: 6px;
	width: 100%;
	margin: 20px 0 0;
	padding: 18px 0 0;
	list-style: none;
	border-top: 1px solid var(--tp-hairline);
}

.tp-buy__perks li {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--tp-muted);
}

.tp-buy__perks .tp-icon {
	flex: none;
	margin-top: 1px;
	font-size: 18px;
	color: var(--tp-primary);
}

/* ---------- Description + details ---------- */

.tp-pd-desc .tp-h2 {
	margin-bottom: 20px;
}

.tp-pd__desc { margin-top: 24px; }

.tp-prose {
	max-width: 68ch;
	font-size: 16px;
	line-height: 1.7;
	color: var(--tp-ink);
}

.tp-prose > :first-child {
	margin-top: 0;
}

.tp-prose p,
.tp-prose ul,
.tp-prose ol {
	margin: 0 0 16px;
}

.tp-prose ul,
.tp-prose ol {
	padding-left: 0;
	list-style: none;
}

.tp-prose li {
	position: relative;
	padding-left: 28px;
}

.tp-prose li + li {
	margin-top: 8px;
}

.tp-prose ul li::before {
	content: "";
	position: absolute;
	top: 0.62em;
	left: 6px;
	width: 7px;
	height: 7px;
	background: var(--tp-primary);
	border-radius: var(--tp-r-pill);
}

.tp-prose ol {
	counter-reset: tp-ol;
}

.tp-prose ol li::before {
	counter-increment: tp-ol;
	content: counter(tp-ol) ".";
	position: absolute;
	left: 0;
	font-family: var(--tp-font-num);
	font-weight: 500;
	color: var(--tp-primary);
}

.tp-prose h2,
.tp-prose h3,
.tp-prose h4 {
	margin: 32px 0 12px;
	font-size: 20px;
	font-weight: 500;
	line-height: 1.3;
}

.tp-prose a {
	color: var(--tp-primary);
	text-underline-offset: 3px;
}

.tp-prose em {
	padding: 1px 6px;
	font-style: normal;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.9em;
	background: var(--tp-surface);
	border-radius: 6px;
	box-shadow: inset 0 0 0 1px var(--tp-hairline);
}

.tp-prose img {
	max-width: 100%;
	height: auto;
	border-radius: var(--tp-r-media);
}

.tp-pd-details {
	padding: 18px 32px 8px;
	background: var(--tp-surface);
	border-radius: var(--tp-r-media);
	box-shadow: inset 0 0 0 1px var(--tp-hairline);
}

.tp-pd-details__title {
	margin: 0 0 2px;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.3;
}

.tp-pd-details dl {
	margin: 0;
}

.tp-pd-details__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 9px 0;
	font-size: 14px;
	line-height: 1.4;
}

.tp-pd-details__row + .tp-pd-details__row {
	border-top: 1px solid var(--tp-hairline);
}

.tp-pd-details dt {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--tp-muted);
}

.tp-pd-details dt .tp-icon {
	font-size: 16px;
}

.tp-pd-details dd {
	margin: 0;
	font-weight: 500;
	text-align: right;
	color: var(--tp-ink);
}

/* ---------- Related ---------- */

.tp-related {
	margin-top: 96px;
	padding-top: 56px;
	border-top: 1px solid var(--tp-hairline);
}

.tp-related__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 32px;
}

.tp-related__all {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 15px;
	font-weight: 500;
	color: var(--tp-primary);
	text-decoration: none;
	white-space: nowrap;
}

.tp-related__all .tp-icon {
	transition: transform 0.2s var(--tp-ease);
}

.tp-related__all:hover .tp-icon {
	transform: translateX(3px);
}

/* ---------- Mobile buy bar (shown by product.js when the buy box is off screen) ---------- */

.tp-buybar {
	display: none;
}

/* Related: 6 x 2 compact tiles (Shopify/Etsy-like: square image, name, price under it) */
.tp-grid--6 {
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 32px 16px;
}

.tp-card--compact {
	gap: 10px;
}

.tp-card--compact .tp-card__media {
	aspect-ratio: 1;
	border-radius: 12px;
}

.tp-card--compact .tp-card__badge {
	top: 8px;
	left: 8px;
	padding: 2px 8px;
	font-size: 11px;
}

.tp-card--compact .tp-card__actions {
	right: 8px;
	bottom: 8px;
}

.tp-home .tp-card--compact .tp-cart-btn {
	justify-content: center;
	width: 40px;
	min-height: 40px;
	padding: 0;
}

.tp-card--compact .tp-card__body {
	flex: 1; /* fill the tile so every price lines up at the bottom of its row */
	flex-direction: column;
	gap: 6px;
}

.tp-card--compact .tp-card__text {
	width: 100%;
}

.tp-card--compact .tp-card__price {
	margin-top: auto;
}

.tp-card--compact .tp-card__name {
	display: -webkit-box;
	overflow: hidden;
	font-size: 14px;
	line-height: 1.35;
	max-height: 2.7em; /* 2 lines; the clamp adds the ellipsis */
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow-wrap: anywhere;
}

.tp-card--compact .tp-card__version {
	display: none;
}

.tp-card--compact .tp-card__price {
	padding: 0;
	font-size: 14px;
	color: var(--tp-ink);
	background: transparent;
	border-radius: 0;
}

.tp-card--compact .tp-card__price ins {
	color: var(--tp-warm-ink);
}

@media (max-width: 1279px) {
	.tp-grid--6 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (max-width: 1023px) {
	.tp-grid--6 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.tp-grid--6 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px 12px;
	}
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
	.tp-pd__gallery,
	.tp-buy {
		animation: tp-rise 0.7s var(--tp-ease) both;
	}

	.tp-buy {
		animation-delay: 0.08s;
	}
}

/* ---------- Responsive ---------- */


@media (max-width: 1023px) {
	.tp-pd {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"gallery"
			"side"
			"desc";
		grid-template-rows: none;
		row-gap: 32px;
	}

	.tp-pd__side {
		position: static;
		max-height: none;
		overflow: visible;
		padding: 0;
		margin: 0;
	}

	.tp-pd__desc { margin-top: 16px; }
}

@media (max-width: 767px) {
	.tp-product-page {
		padding-bottom: 120px; /* room for the buy bar */
	}

	.tp-crumbs ol {
		padding: 20px 0 16px;
	}

	.tp-crumbs [aria-current="page"] {
		max-width: 22ch;
	}

	.tp-pd {
		row-gap: 24px;
	}

	.tp-pd__thumb {
		width: 76px;
	}

	.tp-buy {
		padding: 0;
		background: transparent;
		box-shadow: none;
	}

	.tp-buy__price {
		font-size: 28px;
	}

	.tp-pd-details {
		padding: 14px 20px 6px;
	}

	.tp-related {
		margin-top: 64px;
		padding-top: 40px;
	}

	.tp-buybar {
		position: fixed;
		right: 12px;
		bottom: 12px;
		left: 12px;
		z-index: 90;
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 8px 8px 8px 20px;
		background: #fff;
		border-radius: var(--tp-r-pill);
		box-shadow: inset 0 0 0 1px var(--tp-hairline), 0 12px 32px -8px rgba(31, 49, 71, 0.28);
		opacity: 0;
		visibility: hidden;
		transform: translateY(16px);
		transition: opacity 0.25s var(--tp-ease), transform 0.25s var(--tp-ease), visibility 0s linear 0.25s;
	}

	.tp-buybar.is-visible {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}

	.tp-buybar__text {
		display: flex;
		flex-direction: column;
		min-width: 0;
	}

	.tp-buybar__name {
		overflow: hidden;
		font-size: 13px;
		line-height: 1.3;
		white-space: nowrap;
		text-overflow: ellipsis;
		color: var(--tp-muted);
	}

	.tp-buybar__price {
		font-size: 16px;
		font-weight: 600;
		line-height: 1.3;
	}

	.tp-buybar__price del {
		display: none;
	}

	.tp-buybar__price ins {
		text-decoration: none;
	}

	.tp-buybar .tp-btn {
		flex: none;
		min-height: 44px;
		padding: 10px 22px;
	}
}
