/*
 * Shipping Protection - checkout section.
 *
 * Layout follows the approved design (cards, "Recommended" pill, callout, payout bar), dressed in the
 * checkout's own look: the same box (1px orange border, 15px padding), the same label style (the theme's
 * 14px / 2px tracking / uppercase), and the same two-colour scheme. The font is inherited from the site on
 * purpose, so the section sits natively next to Shipping and Terms.
 *
 * Colours: orange accents, and for a Top Trader black accents - the site already turns every orange box
 * and button black for them (see the [top-trader-logo] shortcode), so the palette is a set of variables
 * that the Top Trader variant swaps. There is no green anywhere in this file.
 *
 * Everything is scoped under .ssp-section because the theme styles bare label / p / h3 / ul / a / input
 * globally and those rules have to be neutralised inside the cards.
 *
 * The section is a size container, so the narrow layout follows the width of the checkout column
 * (not the viewport): see the @container rule at the bottom.
 */

.ssp-section {
	--ssp-orange: #ff7a34;
	--ssp-accent: #ff7a34; /* box border, selected card border */
	--ssp-accent-deep: #d9660f; /* radio, icon disc */
	--ssp-accent-text: #a84b08; /* links */
	--ssp-accent-tint: #fff7f0; /* selected card background */
	--ssp-accent-line: #f8d2b4; /* separators inside the selected card */
	--ssp-callout-bg: #fff4e8;
	--ssp-callout-ink: #a84b08; /* the shield icon */
	--ssp-callout-text: #3a2a1c;
	--ssp-pill-bg: #fde3cf;
	--ssp-pill-text: #8a3d06;
	--ssp-ink: #1f1f1f;
	--ssp-body: #333;
	--ssp-muted: #555;
	--ssp-muted-2: #595959;
	--ssp-gray: #f2f2f2;
	--ssp-line: #cfcfcf;
	--ssp-label: #1d1d1d; /* the theme's label colour */

	container-type: inline-size;
	margin: 0 0 18px;
}

/* The site's header floats over the page: when the "required field" notice link scrolls here, the "Shipping
   Protection" title stops 110px below the top of the window, with the whole section underneath it. Keep this on
   the heading and off the radios: on a radio it also applies when a click focuses it, and made the page jump. */
.ssp-heading {
	scroll-margin-top: 110px;
}

/* Top Trader: black accents, like every other box and button on their checkout. The two information boxes (the
   "trade-in is valued at" callout and the per-box labels notice) are deliberately not overridden here: they keep the
   light orange background and text colour everyone gets. */
.ssp-section[data-ssp-top="1"],
.ssp-section[data-ssp-variant="top"] {
	--ssp-accent: #000;
	--ssp-accent-deep: #000;
	--ssp-accent-text: #000;
	--ssp-accent-tint: #f5f5f5;
	--ssp-accent-line: #d9d9d9;
	--ssp-callout-ink: #ff7a34;
	--ssp-pill-bg: #000;
	--ssp-pill-text: #fff;
}

.ssp-section *,
.ssp-section *::before,
.ssp-section *::after {
	box-sizing: border-box;
}

.ssp-section [hidden],
.ssp-section[hidden] {
	display: none !important;
}

.ssp-state {
	display: none;
}

.ssp-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- The box ---------- */

/* Same box as the billing, shipping and order review boxes: 1px border, 15px padding, square corners. */
.ssp-box {
	display: flex;
	flex-direction: column;
	gap: 16px;
	min-width: 0;
	margin: 0;
	padding: 15px 15px 0;
	border: 1px solid var(--ssp-accent);
	border-radius: 0;
	background: transparent;
}

/* Same as every other label on the checkout (the theme's ".woocommerce form label"). */
.ssp-eyebrow {
	display: block;
	font-size: 14px;
	font-weight: 400;
	line-height: 28px;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: var(--ssp-label);
}

.ssp-req {
	color: inherit;
}

/* The theme sets bare <p> to 14px; the design is 16px. */
.ssp-section p {
	font-size: inherit;
	line-height: inherit;
}

.ssp-intro {
	margin: 0;
	font-size: 16px;
	line-height: 1.5;
	color: var(--ssp-body);
}

.ssp-callout {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 16px 18px;
	border-radius: 6px;
	background: var(--ssp-callout-bg);
	color: var(--ssp-callout-ink);
}

.ssp-callout svg {
	flex: none;
	margin-top: 1px;
}

.ssp-callout p {
	margin: 0;
	font-size: 15px;
	line-height: 1.5;
	color: var(--ssp-callout-text);
}

/* ---------- Option cards ---------- */

.ssp-options {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.ssp-opt {
	margin: 1px; /* keeps the card the same size when the selected border gets thicker */
	overflow: hidden;
	border: 1px solid var(--ssp-line);
	border-radius: 8px;
	background: #fff;
	transition: border-color 0.15s;
}

.ssp-opt.is-selected {
	margin: 0;
	border: 2px solid var(--ssp-accent);
}

/* The row is a <label>, which the theme styles as small uppercase spaced text: undo that. */
.ssp-section label.ssp-opt-row {
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 64px;
	margin: 0;
	padding: 18px 22px;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.4;
	letter-spacing: normal;
	text-transform: none;
	color: var(--ssp-body);
	cursor: pointer;
}

.ssp-opt-row:hover {
	background: #fafafa;
}

.ssp-opt.is-selected .ssp-opt-row,
.ssp-opt.is-selected .ssp-opt-row:hover {
	background: var(--ssp-accent-tint);
}

.ssp-section input.ssp-radio {
	flex: none;
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--ssp-accent-deep);
	cursor: pointer;
}

.ssp-radio:focus-visible {
	outline: 3px solid #1a5fb4;
	outline-offset: 3px;
}

.ssp-opt-main {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.ssp-opt-title-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.ssp-opt-title {
	font-size: 17px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--ssp-ink);
}

.ssp-opt-title--plain {
	font-weight: 600;
}

/* "($9.00)" / "($9.00 Free)" wraps as one piece, never leaving a stray bracket on its own line. */
.ssp-price-note {
	white-space: nowrap;
}

/* Included coverage (Top Trader, custom quote): the normal price struck through, and the word "Free" next to it. */
.ssp-opt-title s {
	font-weight: 600;
	color: var(--ssp-muted);
}

.ssp-free {
	display: inline-block;
	padding: 0 8px;
	border-radius: 4px;
	background: var(--ssp-orange);
	font-weight: 800;
	line-height: 1.5;
	color: #000;
}

.ssp-opt-sub {
	font-size: 14px;
	line-height: 1.45;
	color: var(--ssp-muted);
}

.ssp-pill {
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--ssp-pill-bg);
	font-size: 11px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ssp-pill-text);
}

.ssp-pay {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 2px;
	text-align: right;
}

.ssp-pay-lbl {
	font-size: 13px;
	color: var(--ssp-muted);
}

.ssp-pay-amt {
	font-size: 22px;
	font-weight: 800;
	line-height: 1.2;
	color: var(--ssp-ink);
	font-variant-numeric: tabular-nums;
}

.ssp-pay-amt--plain {
	font-weight: 700;
}

.ssp-pay-note {
	font-size: 12px;
	color: var(--ssp-muted-2);
}

/* Included coverage cannot be declined: the "No" card stays visible, but faded and inert. */
.ssp-opt.is-disabled {
	opacity: 0.5;
	background: #f7f7f7;
}

.ssp-opt.is-disabled .ssp-opt-row,
.ssp-opt.is-disabled .ssp-opt-row:hover {
	background: transparent;
	cursor: not-allowed;
}

.ssp-opt.is-disabled .ssp-radio {
	cursor: not-allowed;
}

/* ---------- "What's not covered" ---------- */

.ssp-excl {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px 22px 18px 58px;
	border-top: 1px solid var(--ssp-accent-line);
	background: #fff;
}

.ssp-opt:not(.is-selected) .ssp-excl {
	border-top-color: #e2e2e2;
}

.ssp-excl-title {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
	color: #222;
}

.ssp-excl ul {
	margin: 0;
	padding-left: 18px;
	list-style: disc;
	font-size: 14px;
	line-height: 1.7;
	color: var(--ssp-body);
}

.ssp-excl li {
	margin: 0;
	padding: 0;
}

.ssp-excl a {
	color: var(--ssp-accent-text);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ssp-excl a:hover {
	color: #7a3606;
}

.ssp-section[data-ssp-top="1"] .ssp-excl a:hover,
.ssp-section[data-ssp-variant="top"] .ssp-excl a:hover {
	color: #444;
}

.ssp-excl .ssp-excl-note {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--ssp-muted-2);
}

/* Orders over the per-box limit: how many labels, and what to do. A band across the whole card; its left padding
   (58px = radio + gap) puts the text in line with the title above and "What's not covered" below. */
.ssp-multibox {
	margin: 0;
	padding: 14px 22px 14px 58px;
	background: var(--ssp-callout-bg);
	font-size: 14px;
	line-height: 1.5;
	color: var(--ssp-callout-text);
}

/* ---------- Payout bar ---------- */

/* Runs edge to edge of the box (the box has no bottom padding), like a footer. */
.ssp-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin: 0 -15px;
	padding: 14px 15px;
	border-top: 1px solid #e2e2e2;
	background: var(--ssp-gray);
}

.ssp-hint {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	line-height: 1.4;
	color: #444;
}

.ssp-hint svg {
	flex: none;
}

.ssp-total {
	display: flex;
	align-items: baseline;
	gap: 10px;
}

.ssp-total-lbl {
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ssp-body);
}

.ssp-total-amt {
	font-size: 24px;
	font-weight: 800;
	line-height: 1.2;
	color: var(--ssp-ink);
	font-variant-numeric: tabular-nums;
	transition: opacity 0.2s;
}

/* While WooCommerce recalculates, the payout is dimmed so it is never read as final. */
.ssp-summary.is-updating .ssp-total-amt {
	opacity: 0.45;
}

/* ---------- Within the free basic coverage ---------- */

.ssp-covered {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 20px 22px;
	border: 1px solid var(--ssp-accent-line);
	border-radius: 8px;
	background: var(--ssp-accent-tint);
}

.ssp-covered-ic {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 999px;
	background: var(--ssp-accent-deep);
	color: #fff;
}

.ssp-covered strong {
	display: block;
	font-size: 17px;
	line-height: 1.4;
	color: var(--ssp-ink);
}

.ssp-covered-sub {
	font-size: 14px;
	color: var(--ssp-muted);
}

.ssp-more summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	font-size: 14px;
	font-weight: 600;
	color: var(--ssp-accent-text);
	text-decoration: underline;
	text-underline-offset: 3px;
	list-style: none;
	cursor: pointer;
}

.ssp-more summary::-webkit-details-marker {
	display: none;
}

.ssp-more[open] summary svg {
	transform: rotate(180deg);
}

.ssp-more .ssp-excl {
	padding: 4px 0 8px;
	border: 0;
}

/* ---------- Narrow layout (follows the section's own width) ---------- */

@container (max-width: 560px) {
	.ssp-callout {
		gap: 12px;
		padding: 14px;
	}

	.ssp-section label.ssp-opt-row {
		flex-wrap: wrap;
		align-items: flex-start;
		gap: 12px;
		padding: 16px;
	}

	.ssp-section input.ssp-radio {
		width: 22px;
		height: 22px;
		margin-top: 2px;
	}

	.ssp-opt-title-row {
		flex-direction: column-reverse;
		align-items: flex-start;
		gap: 6px;
	}

	.ssp-pay {
		flex-basis: calc(100% - 34px);
		flex-direction: row;
		flex-wrap: wrap;
		align-items: baseline;
		justify-content: space-between;
		min-width: 0;
		margin-left: 34px;
		padding-top: 10px;
		border-top: 1px solid var(--ssp-accent-line);
		text-align: left;
	}

	.ssp-opt:not(.is-selected) .ssp-pay {
		border-top-color: #e2e2e2;
	}

	.ssp-pay-note {
		flex-basis: 100%;
		text-align: right;
	}

	.ssp-excl {
		padding: 14px 16px 16px;
	}

	.ssp-multibox {
		padding: 12px 16px;
	}

	.ssp-summary {
		flex-direction: column-reverse;
		align-items: stretch;
		gap: 6px;
	}

	.ssp-total {
		justify-content: space-between;
	}

	.ssp-total-lbl {
		font-size: 13px;
	}

	.ssp-hint {
		font-size: 13px;
	}
}

/* ---------- Fee row in the order review table and the cart totals ---------- */

/*
 * The theme hides every .fee row (it needs to for the coupon bonus fee); this un-hides only the row
 * that contains our amount marker (see SSP_Cart_Fee::mark_fee_amount), and on the checkout aligns its
 * label like the Total row's.
 */
tr.fee:has(.ssp-fee-amount) {
	display: table-row;
}

.woocommerce-checkout-review-order-table tr.fee:has(.ssp-fee-amount) th {
	text-align: right;
	padding-right: 10px;
}

/* "Included" in the totals: plain bold in the table's own colour. */
.ssp-fee-free {
	font-weight: 700;
	color: inherit;
}
