/**
 * PSA Trade Cart — Stylesheet
 * Version: 0.2.0
 *
 * Brand colours and design tokens are defined as CSS custom properties on the
 * top-level wrapper. To re-skin, override these on .psa-cart-wrapper either in
 * the theme stylesheet or via a child plugin.
 */

.psa-cart-wrapper {
	--psa-navy: #0a2540;
	--psa-navy-deep: #061a2e;
	--psa-gold: #d4a017;
	--psa-gold-soft: #fff8e0;
	--psa-gold-border: #f0c850;
	--psa-text: #1a1f29;
	--psa-text-muted: #5b6471;
	--psa-text-subtle: #8a93a1;
	--psa-bg: #f5f6f8;
	--psa-card-bg: #ffffff;
	--psa-card-border: #e5e7eb;
	--psa-card-radius: 10px;
	--psa-success: #16a34a;
	--psa-discount: #1f8043;
	--psa-shadow: 0 1px 2px rgba( 10, 37, 64, 0.04 ), 0 2px 4px rgba( 10, 37, 64, 0.04 );

	max-width: 1280px;
	margin: 0 auto;
	padding: 24px 16px 64px;
	color: var(--psa-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	line-height: 1.5;
	box-sizing: border-box;
}

.psa-cart-wrapper *,
.psa-cart-wrapper *::before,
.psa-cart-wrapper *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ Header */

.psa-cart-header {
	background: var(--psa-navy);
	color: #fff;
	border-radius: var(--psa-card-radius);
	padding: 18px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 16px;
}

.psa-cart-header__brand {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psa-cart-header__back,
.psa-cart-header__back:link,
.psa-cart-header__back:visited {
	font-size: 14px;
	color: rgba( 255, 255, 255, 0.9 );
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: fit-content;
	transition: color 100ms ease, transform 100ms ease;
	font-weight: 500;
	margin-bottom: 2px;
}

.psa-cart-header__back:hover,
.psa-cart-header__back:focus {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.psa-cart-header__back:hover .psa-cart-header__back-arrow,
.psa-cart-header__back:focus .psa-cart-header__back-arrow {
	transform: translateX( -2px );
}

.psa-cart-header__back-arrow {
	display: inline-block;
	transition: transform 120ms ease;
}

.psa-cart-header__eyebrow {
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: rgba( 255, 255, 255, 0.6 );
	font-weight: 500;
}

.psa-cart-header__title {
	font-size: 20px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 12px;
}

.psa-cart-header__title-mark {
	font-weight: 700;
}

.psa-cart-header__title-sep {
	color: rgba( 255, 255, 255, 0.4 );
}

.psa-cart-header__title-page {
	font-weight: 400;
	color: rgba( 255, 255, 255, 0.85 );
}

.psa-cart-header__meta {
	display: flex;
	align-items: center;
	gap: 16px;
}

.psa-cart-header__account {
	text-align: right;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.psa-cart-header__account-label {
	font-size: 11px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: rgba( 255, 255, 255, 0.6 );
}

.psa-cart-header__account-name {
	font-size: 14px;
	font-weight: 600;
}

.psa-cart-header__badge {
	display: inline-block;
	background: var(--psa-gold);
	color: var(--psa-navy);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 8px 14px;
	border-radius: 4px;
}

/* --------------------------------------------------------------- Countdown */

.psa-countdown {
	background: var(--psa-gold-soft);
	border: 1.5px solid var(--psa-gold-border);
	border-radius: var(--psa-card-radius);
	padding: 14px 20px;
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
}

.psa-countdown__icon {
	color: var(--psa-navy);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.psa-countdown__text {
	flex: 1;
	min-width: 0;
}

.psa-countdown__headline {
	margin: 0 0 2px;
	font-size: 14px;
	color: var(--psa-text);
	font-weight: 500;
}

.psa-countdown__headline strong {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.psa-countdown__subline {
	margin: 0;
	font-size: 12px;
	color: var(--psa-text-muted);
}

.psa-countdown__pill {
	background: #fef3c7;
	color: var(--psa-navy);
	font-family: ui-monospace, "SF Mono", Menlo, monospace;
	font-size: 16px;
	font-weight: 700;
	padding: 8px 14px;
	border-radius: 6px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.04em;
	flex-shrink: 0;
}

/* -------------------------------------------------------------- Cart layout */

.psa-cart {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	gap: 20px;
	align-items: start;
}

.psa-cart__main {
	min-width: 0;
}

.psa-cart__summary-wrap {
	position: sticky;
	top: 20px;
}

@media ( max-width: 960px ) {
	.psa-cart {
		grid-template-columns: 1fr;
	}
	.psa-cart__summary-wrap {
		position: static;
	}
}

/* ---------------------------------------------------------------- Cards */

.psa-card {
	background: var(--psa-card-bg);
	border: 1px solid var(--psa-card-border);
	border-radius: var(--psa-card-radius);
	box-shadow: var(--psa-shadow);
	overflow: hidden;
}

.psa-card__header {
	padding: 16px 20px;
	border-bottom: 1px solid var(--psa-card-border);
}

.psa-card__title {
	margin: 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--psa-text-muted);
}

/* ----------------------------------------------------------- Line items */

.psa-cart__items-list {
	padding: 0 20px;
}

.psa-line-item {
	display: grid;
	grid-template-columns: 80px minmax(0, 1fr) 120px 140px;
	gap: 20px;
	padding: 20px 0;
	border-bottom: 1px solid var(--psa-card-border);
	align-items: center;
}

.psa-line-item:last-child {
	border-bottom: 0;
}

.psa-line-item__media {
	width: 80px;
	height: 80px;
	border-radius: 8px;
	overflow: hidden;
	background: #f3f4f6;
	display: flex;
	align-items: center;
	justify-content: center;
}

.psa-line-item__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.psa-line-item__info {
	min-width: 0;
}

.psa-line-item__sku {
	display: inline-block;
	font-size: 11px;
	background: #eef0f3;
	color: var(--psa-text-muted);
	padding: 3px 8px;
	border-radius: 4px;
	font-weight: 600;
	letter-spacing: 0.04em;
	margin-bottom: 6px;
	font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.psa-line-item__title {
	font-size: 15px;
	font-weight: 600;
	margin: 0 0 4px;
	line-height: 1.35;
}

.psa-line-item__title a,
.psa-line-item__title a:link,
.psa-line-item__title a:visited {
	text-decoration: none;
	color: var(--psa-text);
}

.psa-line-item__title a:hover,
.psa-line-item__title a:focus {
	color: var(--psa-navy);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.psa-line-item__excerpt {
	font-size: 13px;
	color: var(--psa-text-muted);
	margin: 0 0 8px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.4;
}

.psa-line-item__stock {
	font-size: 12px;
	color: var(--psa-success);
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.psa-line-item__stock::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--psa-success);
}

/* ----------------------------------------------------------- Bulk tiers */

.psa-tiers {
	margin-top: 12px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 10px 12px;
}

.psa-tiers__grid {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psa-tier {
	display: grid;
	grid-template-columns: minmax(110px, 1fr) auto auto;
	gap: 10px;
	align-items: center;
	padding: 4px 8px;
	border-radius: 5px;
	font-size: 12px;
	color: var(--psa-text-muted);
	font-variant-numeric: tabular-nums;
}

.psa-tier--active {
	background: #ecfdf5;
	color: var(--psa-text);
	border: 1px solid #a7f3d0;
	padding: 5px 7px; /* compensate for the 1px border */
	font-weight: 600;
}

.psa-tier__qty {
	color: inherit;
}

.psa-tier__price {
	font-weight: 600;
	color: var(--psa-text);
	text-align: right;
	min-width: 60px;
}

.psa-tier__badge {
	min-width: 60px;
	text-align: right;
	font-size: 11px;
	font-weight: 600;
}

.psa-tier__save {
	color: var(--psa-discount);
	background: rgba( 31, 128, 67, 0.08 );
	padding: 2px 7px;
	border-radius: 3px;
	display: inline-block;
}

.psa-tier__active-mark {
	color: var(--psa-discount);
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.psa-tiers__taxnote {
	margin: 8px 0 0;
	padding: 0;
	font-size: 11px;
	color: var(--psa-text-subtle);
	font-style: italic;
}

@media ( max-width: 640px ) {
	.psa-tier {
		grid-template-columns: 1fr auto auto;
		font-size: 11px;
	}
}

/* Quantity stepper */
.psa-line-item__qty {
	display: flex;
	justify-content: center;
}

.psa-stepper {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid var(--psa-card-border);
	border-radius: 6px;
	overflow: hidden;
	background: #fff;
	height: 36px;
}

.psa-stepper__btn {
	width: 32px;
	border: 0;
	background: #f8fafc;
	color: var(--psa-text);
	font-size: 18px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	user-select: none;
	transition: background 100ms ease;
	padding: 0;
}

.psa-stepper__btn:hover { background: #e2e8f0; }
.psa-stepper__btn:active { background: #cbd5e1; }
.psa-stepper__btn:disabled { opacity: 0.5; cursor: not-allowed; }

.psa-stepper__btn--minus { border-right: 1px solid var(--psa-card-border); }
.psa-stepper__btn--plus { border-left: 1px solid var(--psa-card-border); }

.psa-stepper__input {
	width: 56px;
	border: 0;
	text-align: center;
	font-size: 14px;
	font-weight: 600;
	background: #fff;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
	padding: 0;
}

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

.psa-stepper__input:focus {
	outline: 2px solid var(--psa-navy);
	outline-offset: -2px;
}

.psa-line-item__total {
	text-align: right;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.psa-line-item__line-total {
	font-weight: 700;
	font-size: 16px;
	color: var(--psa-text);
	font-variant-numeric: tabular-nums;
}

.psa-line-item__unit-price {
	font-size: 12px;
	color: var(--psa-text-muted);
	font-variant-numeric: tabular-nums;
}

.psa-line-item__remove,
.psa-line-item__remove:link,
.psa-line-item__remove:visited {
	display: inline-block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--psa-text-subtle);
	text-decoration: none;
	border: 0;
	border-bottom: 1px dotted currentColor;
	background: transparent;
	padding: 0;
	cursor: pointer;
	align-self: flex-end;
	font-family: inherit;
}

.psa-line-item__remove:hover,
.psa-line-item__remove:focus {
	color: #b91c1c;
	text-decoration: none;
	outline: none;
}

@media ( max-width: 640px ) {
	.psa-line-item {
		grid-template-columns: 64px minmax(0, 1fr);
		gap: 14px;
	}
	.psa-line-item__media {
		width: 64px;
		height: 64px;
	}
	.psa-line-item__qty,
	.psa-line-item__total {
		grid-column: 1 / -1;
	}
	.psa-line-item__qty {
		justify-content: flex-start;
	}
	.psa-line-item__total {
		text-align: left;
		flex-direction: row;
		align-items: baseline;
		gap: 12px;
	}
}

/* ----------------------------------------------------------- Summary */

.psa-summary {
	padding: 16px 20px 20px;
}

.psa-summary__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	padding: 8px 0;
	font-size: 14px;
	color: var(--psa-text);
}

.psa-summary__row span:last-child {
	font-variant-numeric: tabular-nums;
	font-weight: 500;
}

.psa-summary__row--discount {
	color: var(--psa-discount);
}

.psa-summary__row--total {
	border-top: 1px solid var(--psa-card-border);
	margin-top: 10px;
	padding-top: 16px;
	font-size: 16px;
	font-weight: 700;
}

.psa-summary__row--total span:last-child {
	font-size: 22px;
	font-weight: 700;
}

.psa-summary__checkout-btn,
.psa-summary__checkout-btn:link,
.psa-summary__checkout-btn:visited {
	display: block;
	background: var(--psa-navy);
	color: #fff !important;
	text-align: center;
	padding: 15px 20px;
	border-radius: 6px;
	text-decoration: none;
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.02em;
	margin-top: 18px;
	transition: background 120ms ease;
}

.psa-summary__checkout-btn:hover,
.psa-summary__checkout-btn:focus,
.psa-summary__checkout-btn:active {
	background: var(--psa-navy-deep);
	color: #fff !important;
	text-decoration: none;
}

/* ----------------------------------------------------------- Empty state */

.psa-cart--empty {
	background: var(--psa-card-bg);
	border: 1px solid var(--psa-card-border);
	border-radius: var(--psa-card-radius);
	padding: 48px 24px;
	text-align: center;
	box-shadow: var(--psa-shadow);
}

.psa-cart--empty p {
	font-size: 16px;
	color: var(--psa-text-muted);
	margin: 0 0 16px;
}

.psa-cart__continue,
.psa-cart__continue:link,
.psa-cart__continue:visited {
	display: inline-block;
	background: var(--psa-navy);
	color: #fff !important;
	padding: 12px 22px;
	border-radius: 6px;
	text-decoration: none;
	font-weight: 600;
}

.psa-cart__continue:hover,
.psa-cart__continue:focus {
	background: var(--psa-navy-deep);
	color: #fff !important;
	text-decoration: none;
}

/* ----------------------------------------------------------- A11y helpers */

.psa-cart-wrapper .screen-reader-text {
	border: 0;
	clip: rect( 1px, 1px, 1px, 1px );
	height: 1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* ----------------------------------------------------------- Add-ons */

.psa-addons {
	margin-top: 20px;
}

.psa-addons__grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax(180px, 1fr) );
	gap: 14px;
	padding: 16px 20px 20px;
}

.psa-addon {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
	border: 1px solid var(--psa-card-border);
	border-radius: 8px;
	background: #fff;
	transition: border-color 120ms ease, box-shadow 120ms ease;
}

.psa-addon:hover {
	border-color: var(--psa-navy);
	box-shadow: 0 2px 8px rgba( 10, 37, 64, 0.06 );
}

.psa-addon__media {
	width: 100%;
	aspect-ratio: 1 / 1;
	background: #f3f4f6;
	border-radius: 6px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

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

.psa-addon__title {
	margin: 4px 0 0;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 2.6em;
}

.psa-addon__title a,
.psa-addon__title a:link,
.psa-addon__title a:visited {
	color: var(--psa-text);
	text-decoration: none;
}

.psa-addon__title a:hover { color: var(--psa-navy); }

.psa-addon__price {
	font-size: 15px;
	font-weight: 700;
	color: var(--psa-text);
	font-variant-numeric: tabular-nums;
}

.psa-addon__add {
	margin-top: auto;
	padding: 8px 12px;
	border: 1px solid var(--psa-navy);
	background: #fff;
	color: var(--psa-navy);
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	transition: background 100ms ease, color 100ms ease;
}

.psa-addon__add:hover:not(:disabled) {
	background: var(--psa-navy);
	color: #fff;
}

.psa-addon__add:disabled {
	opacity: 0.6;
	cursor: wait;
}

/* ----------------------------------------------------------- Undo banner */

.psa-undo {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX( -50% ) translateY( 100px );
	display: flex;
	align-items: center;
	gap: 16px;
	background: var(--psa-navy);
	color: #fff;
	padding: 12px 16px 12px 20px;
	border-radius: 8px;
	box-shadow: 0 10px 30px rgba( 10, 37, 64, 0.25 );
	font-size: 14px;
	z-index: 100000;
	opacity: 0;
	transition: transform 240ms ease, opacity 240ms ease;
	max-width: calc( 100% - 32px );
}

.psa-undo.is-visible {
	transform: translateX( -50% ) translateY( 0 );
	opacity: 1;
}

.psa-undo__msg { font-weight: 500; }

.psa-undo__btn {
	background: transparent;
	color: var(--psa-gold);
	border: 1px solid var(--psa-gold);
	padding: 5px 12px;
	border-radius: 4px;
	font-weight: 700;
	font-size: 13px;
	cursor: pointer;
	font-family: inherit;
	transition: background 100ms ease, color 100ms ease;
}

.psa-undo__btn:hover {
	background: var(--psa-gold);
	color: var(--psa-navy);
}

/* ----------------------------------------------------------- Error toast */

.psa-toast {
	position: fixed;
	top: 24px;
	right: 24px;
	padding: 12px 18px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 500;
	z-index: 100001;
	box-shadow: 0 4px 12px rgba( 0, 0, 0, 0.15 );
	max-width: 360px;
	transition: opacity 250ms ease, transform 250ms ease;
}

.psa-toast--error {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #991b1b;
}

.psa-toast.is-leaving {
	opacity: 0;
	transform: translateY( -8px );
}

/* ----------------------------------------------------------- Loading state */

.psa-cart-root {
	position: relative;
	transition: opacity 150ms ease;
}

.psa-cart-root.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.psa-cart-root.is-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 32px;
	height: 32px;
	margin: -16px 0 0 -16px;
	border: 3px solid var(--psa-card-border);
	border-top-color: var(--psa-navy);
	border-radius: 50%;
	animation: psa-spin 800ms linear infinite;
}

@keyframes psa-spin {
	to { transform: rotate( 360deg ); }
}

/* ----------------------------------------------------------- Mobile addon grid */

@media ( max-width: 640px ) {
	.psa-addons__grid {
		grid-template-columns: repeat( 2, 1fr );
		gap: 10px;
	}
}

/* ----------------------------------------------------------- Stars */

.psa-stars {
	display: inline-flex;
	gap: 1px;
	line-height: 1;
	vertical-align: middle;
}

.psa-stars__star {
	--psa-fill: 0%;
	display: inline-block;
	width: 14px;
	height: 14px;
	background: linear-gradient(
		90deg,
		var(--psa-gold) 0%,
		var(--psa-gold) var(--psa-fill),
		#e2e8f0 var(--psa-fill),
		#e2e8f0 100%
	);
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/></svg>") center / contain no-repeat;
}

/* ----------------------------------------------------------- Reviews */

.psa-reviews {
	margin-top: 20px;
}

.psa-reviews__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
}

.psa-reviews__summary {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--psa-text-muted);
}

.psa-reviews__avg {
	font-weight: 700;
	color: var(--psa-text);
}

.psa-reviews__total {
	color: var(--psa-text-subtle);
}

.psa-reviews__grid {
	display: grid;
	/* 3 columns at desktop matches the original mockup. Falls to 2 on tablet,
	   1 on mobile via the breakpoints below. */
	grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	gap: 14px;
	padding: 16px 20px 20px;
	align-items: stretch;
}

.psa-review {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 14px;
	border: 1px solid var(--psa-card-border);
	border-radius: 8px;
	background: #fff;
	min-height: 140px;
}

.psa-review__rating {
	display: flex;
	align-items: center;
}

.psa-review__content {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--psa-text);
	flex: 1;
}

.psa-review__author {
	margin-top: auto;
	padding-top: 4px;
	font-size: 12px;
	color: var(--psa-text-muted);
	font-weight: 500;
}

.psa-review__date {
	color: var(--psa-text-subtle);
	font-weight: 400;
}

@media ( max-width: 900px ) {
	.psa-reviews__grid {
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	}
}

@media ( max-width: 640px ) {
	.psa-reviews__grid {
		grid-template-columns: 1fr;
	}

	.psa-reviews__header {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}
}
