/**
 * Compare — PDP toggle active state, floating bar, /compare/ page table.
 *
 * Reuses tokens + patterns from variable.css and wishlist.css. The PDP
 * .product-info__link--compare base styling already lives in
 * product-detail.css — this file only adds the active-state + button-reset
 * overrides since we replaced the static <a> with a <button>.
 *
 * No !important — specificity bumps via button. prefix / body context.
 */

/* ---------- PDP toggle button (button reset + active state) ---------- */

button.compare-toggle {
	background: transparent;
	border: 0;
	padding: 0;
	cursor: pointer;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	line-height: 0;
}

button.compare-toggle--text {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	line-height: inherit;
}

button.compare-toggle--text[aria-pressed="true"] .compare-toggle__icon,
button.compare-toggle--text[aria-pressed="true"] .compare-toggle__label {
	color: var(--gold-color, #c7a267);
}

/* ---------- Floating bar (bottom of every page) ---------- */

.compare-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1040;
	background: #fff;
	border-top: 1px solid var(--border-color-2, #e5e5e5);
	box-shadow: 0 -8px 24px rgba( 0, 0, 0, 0.06 );
	padding: 14px 0;
	transform: translateY( 0 );
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.compare-bar--hidden {
	transform: translateY( 110% );
	opacity: 0;
	pointer-events: none;
}

.compare-bar__inner {
	display: flex;
	align-items: center;
	gap: 24px;
}

.compare-bar__slots {
	display: flex;
	flex: 1 1 auto;
	gap: 16px;
	min-width: 0;
}

.compare-bar__slot {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	border: 1px solid var(--border-color-2, #e5e5e5);
	border-radius: 4px;
	background: #fafafa;
	position: relative;
}

.compare-bar__slot--empty {
	justify-content: center;
	color: var(--text-secondary, #888);
	background: transparent;
	border-style: dashed;
}

.compare-bar__placeholder {
	font-size: 24px;
	line-height: 1;
	color: var(--text-secondary, #888);
}

.compare-bar__placeholder-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.compare-bar__thumb-link {
	flex: 0 0 auto;
	display: block;
	width: 44px;
	height: 44px;
	overflow: hidden;
	border-radius: 2px;
}

.compare-bar__thumb-link img,
.compare-bar .compare-bar__thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.compare-bar__name {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--text-primary);
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.compare-bar__name:hover {
	color: var(--gold-color, #c7a267);
}

.compare-bar__remove {
	flex: 0 0 auto;
	color: var(--text-secondary, #888);
	font-size: 14px;
	line-height: 1;
}

.compare-bar__remove:hover {
	color: var(--danger-red-border, #c0392b);
}

.compare-bar__actions {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
}

.compare-bar__clear {
	background: transparent;
	border: 0;
	padding: 6px;
	cursor: pointer;
	color: var(--text-secondary, #888);
	font-size: 16px;
	line-height: 1;
}

.compare-bar__clear:hover {
	color: var(--danger-red-border, #c0392b);
}

/* ---------- Hongo-style modal (native <dialog>) ----------
   `<dialog>` gives us focus trap, ESC dismissal and the ::backdrop
   pseudo-element for free. We reset its UA padding to zero so our own
   `.compare-modal__inner` controls spacing. */

.compare-modal {
	padding: 0;
	border: 0;
	background: transparent;
	max-width: min(1140px, 96vw);
	width: 100%;
	max-height: 92vh;
}

.compare-modal::backdrop {
	background: rgba( 0, 0, 0, 0.55 );
}

.compare-modal__inner {
	background: #fff;
	border-radius: 4px;
	max-height: 92vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.compare-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px;
	border-bottom: 1px solid var(--border-color-2, #e5e5e5);
	flex: 0 0 auto;
}

.compare-modal__title {
	margin: 0;
	font-size: 18px;
	font-weight: 500;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--text-primary);
}

.compare-modal__header-actions {
	display: flex;
	align-items: center;
	gap: 16px;
}

.compare-modal__view-page {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--text-secondary, #888);
	text-decoration: none;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-weight: 500;
}

.compare-modal__view-page:hover {
	color: var(--gold-color, #c7a267);
}

.compare-modal__view-page i {
	font-size: 11px;
}

.compare-modal__close {
	background: transparent;
	border: 0;
	padding: 6px 10px;
	cursor: pointer;
	color: var(--text-secondary, #888);
	font-size: 18px;
	line-height: 1;
}

.compare-modal__close:hover {
	color: var(--danger-red-border, #c0392b);
}

.compare-modal__body {
	padding: 24px;
	overflow-y: auto;
	overflow-x: auto;
	flex: 1 1 auto;
}

/* When the modal contains the empty state, centre it inside the body. */
.compare-modal__body .compare-page__empty {
	padding: 60px 20px;
}

/* ---------- /compare/ page ----------
   1-3 product cards laid out side-by-side. Horizontal scroll kicks in only
   when the row exceeds the container; the cards never stack, so the
   comparison shape is preserved at every breakpoint. */

.compare-page {
	padding: 100px 0;
	overflow-x: hidden;
}

.compare-page__empty {
	text-align: center;
	padding: 80px 20px;
}

.compare-page__empty p {
	margin-bottom: 24px;
	color: var(--text-secondary);
}

.compare-page__items {
	margin-bottom: 24px;
}

/* Card row — flex on every viewport. Cards keep a comfortable min-width and
   the row scrolls horizontally when it can't fit. Scroll-snap on touch so
   cards land cleanly when swiped. */
.compare-products {
	display: flex;
	gap: 20px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 12px;
	justify-content: flex-start;
}

@media (min-width: 992px) {
	.compare-products {
		justify-content: center;
		overflow-x: visible;
		scroll-snap-type: none;
		padding-bottom: 0;
	}
}

/* Card — self-contained: image, name, rating, price, stock, description, cart.
   On small screens each card is a fixed flex item (so they scroll). On
   desktop each card grows to share the row width up to a max. The flex
   column with margin-top:auto on .compare-product__cart keeps all cart
   buttons bottom-aligned across cards of differing description length. */
.compare-product {
	display: flex;
	flex-direction: column;
	flex: 0 0 280px;
	min-width: 280px;
	scroll-snap-align: start;
	background: #fff;
	border: 1px solid var(--border-color-2, #e5e5e5);
	border-radius: 6px;
	padding: 28px 22px 22px;
	position: relative;
	transition: box-shadow 0.2s ease;
}

.compare-product:hover {
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

@media (min-width: 768px) {
	.compare-product {
		flex: 0 0 300px;
		min-width: 300px;
	}
}

@media (min-width: 992px) {
	.compare-product {
		flex: 1 1 0;
		min-width: 0;
		max-width: 360px;
	}
}

/* Remove × — top-right of each card so the action is always visible. */
.compare-product__remove {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	color: var(--text-secondary, #888);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	transition: background-color 0.2s, color 0.2s;
	z-index: 2;
}

.compare-product__remove:hover {
	background: var(--surface-f7f7f7, #f7f7f7);
	color: var(--danger-red-border, #c0392b);
}

.compare-product__thumb-link {
	display: block;
	margin-bottom: 16px;
	text-align: center;
}

.compare-product__img {
	display: block;
	max-width: 180px;
	height: auto;
	margin: 0 auto;
}

.compare-product__title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.4;
	text-align: center;
}

.compare-product__title a {
	color: var(--text-primary);
	text-decoration: none;
}

.compare-product__title a:hover {
	color: var(--gold-color, #c7a267);
}

.compare-product__rating {
	text-align: center;
	min-height: 1.2em;
	margin-bottom: 18px;
	font-size: 13px;
}

.compare-product__no-rating {
	color: var(--text-secondary, #888);
}

/* Spec list — small uppercase label left, value right. */
.compare-product__specs {
	margin: 0 0 22px;
	padding: 0;
	border-top: 1px solid var(--border-color-2, #e5e5e5);
}

.compare-product__spec {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--border-color-2, #e5e5e5);
}

.compare-product__spec dt {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--text-secondary, #888);
	flex: 0 0 auto;
	margin: 0;
}

.compare-product__spec dd {
	margin: 0;
	font-size: 14px;
	color: var(--text-primary);
	text-align: right;
	flex: 1 1 auto;
	min-width: 0;
}

.compare-product__spec dd del {
	color: var(--text-secondary);
	margin-right: 6px;
}

.compare-product__spec dd ins {
	text-decoration: none;
	color: var(--danger-red-border);
}

.compare-product__spec dd a {
	color: var(--text-primary);
	text-decoration: none;
}

.compare-product__spec dd a:hover {
	color: var(--gold-color, #c7a267);
}

/* Missing-value placeholder — muted so it reads as "no data" not "primary". */
.compare-product__dash {
	color: var(--text-secondary, #888);
}

/* Description spec — full-width column rather than label/value row. */
.compare-product__spec--desc {
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

.compare-product__spec--desc dd {
	text-align: left;
	font-size: 13px;
	line-height: 1.55;
	color: var(--text-secondary);
}

/* Stock badge — same tokens as .wishlist-page__item-stock. */
.compare-product__stock {
	display: inline-block;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.compare-product__stock.is-in {
	color: var(--success-green, #5ca846);
}

.compare-product__stock.is-out {
	color: var(--danger-red-border, #c0392b);
}

.compare-product__stock.is-backorder {
	color: var(--warning-orange, #ff9800);
}

/* Cart action — auto-margin pushes it to the bottom of the card so all
   cards' buttons line up regardless of description length. */
.compare-product__cart {
	margin-top: auto;
}

.compare-product__cart .btn {
	width: 100%;
}

/* wpc-ajax-add-to-cart injects an <a class="added_to_cart">"View cart"</a>
   after a successful add — the header badge + toast already confirm. */
.compare-product .added_to_cart {
	display: none !important;
}

/* ---------- Star-rating fallback (woocommerce-general.css dequeued) ----------
   WC's star-rating CSS + WooCommerce webfont lived in woocommerce-general
   which we disabled (see comment block in inc/woocommerce.php). Without it
   `<div class="star-rating">` just leaks its screen-reader text ("Rated X
   out of 5"). Re-import the plugin webfont and the layered-star trick here
   so review stars render everywhere on the site, not just /compare/. */
@font-face {
	font-family: "WooCommerce";
	src: url("/wp-content/plugins/woocommerce/assets/fonts/WooCommerce.woff2") format("woff2"),
	     url("/wp-content/plugins/woocommerce/assets/fonts/WooCommerce.woff")  format("woff");
	font-weight: 400;
	font-style: normal;
	font-display: block; /* icon font — hide text until glyphs load to avoid FOUT */
}

.star-rating {
	overflow: hidden;
	position: relative;
	height: 1em;
	line-height: 1;
	font-size: 1em;
	width: 5.4em;
	font-family: "WooCommerce";
	display: inline-block;
}

.star-rating::before {
	content: "sssss";
	color: #cfc8d8;
	float: left;
	top: 0;
	left: 0;
	position: absolute;
}

.star-rating span {
	overflow: hidden;
	float: left;
	top: 0;
	left: 0;
	position: absolute;
	padding-top: 1.5em;
}

.star-rating span::before {
	content: "SSSSS";
	top: 0;
	position: absolute;
	left: 0;
}

/* Stars inside a compare card render in the theme's rating-orange. */
.compare-product__rating .star-rating {
	float: none;
	margin: 0 auto;
	color: var(--rating-orange, #fd9d38);
}

.compare-product__rating .star-rating::before,
.compare-product__rating .star-rating span::before {
	color: var(--rating-orange, #fd9d38);
}

.compare-actions {
	text-align: center;
	margin-top: 32px;
	margin-bottom: 32px;
}

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

/* Desktop-only feature — side-by-side comparison loses value on tablet +
   phone, so the PDP toggle, floating bar and modal are hidden below
   Bootstrap's `lg` breakpoint. The /compare/ page itself stays reachable
   via direct URL and renders the new card layout with horizontal scroll if
   cards don't fit.
   :not(.compare-product__remove) keeps the per-card remove × visible on
   mobile so users who reach the page on a phone can still empty it. */
@media (max-width: 991.98px) {
	button.compare-toggle:not(.compare-product__remove),
	button.compare-toggle--text,
	.compare-bar,
	.compare-modal {
		display: none;
	}

	.compare-page {
		padding: 60px 0;
	}
}

@media (max-width: 767.98px) {
	.compare-page {
		padding: 40px 0;
	}
}
