/* ---------------------------------------------------------------
   Checkout
   ---------------------------------------------------------------
   Tokens come from cart.css, which is a declared dependency, so a
   theme that retheres the catalogue retheres this too.
   --------------------------------------------------------------- */

.spc-checkout-form {
	display: flex;
	align-items: flex-start;
	gap: 48px;
}

.spc-checkout--two-column .spc-checkout-main  { flex: 1 1 auto; min-width: 0; }
.spc-checkout--two-column .spc-checkout-aside { flex: 0 0 38%; min-width: 0; }

.spc-checkout--single .spc-checkout-form { flex-direction: column; }
.spc-checkout--single .spc-checkout-main,
.spc-checkout--single .spc-checkout-aside { flex: 1 1 100%; width: 100%; }

.spc-checkout-title { margin: 0 0 1rem; }

/* ---------------------------------------------------------------
   Fields
   ---------------------------------------------------------------
   A wrapping flex row rather than grid: a half-width field can sit
   beside another half, and anything full-width simply takes the row,
   without the template needing to know the order.
   --------------------------------------------------------------- */
.spc-checkout-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.spc-field {
	display: flex;
	flex-direction: column;
	margin: 0;
	min-width: 0;
}
.spc-field--100 { flex: 1 1 100%; }
.spc-field--50  { flex: 1 1 calc(50% - 8px); }

.spc-field label {
	margin-bottom: 6px;
	font-size: .9em;
	font-weight: 600;
	line-height: 1.3;
}

.spc-required { margin-left: 2px; color: var(--spc-danger, #b32d2e); }

.spc-field input,
.spc-field textarea {
	box-sizing: border-box;
	width: 100%;
	padding: .6rem .7rem;
	font: inherit;
	color: inherit;
	background: transparent;
	border: 1px solid var(--spc-border-strong, rgba(0,0,0,.24));
	border-radius: var(--spc-radius, 4px);
	transition: border-color var(--spc-speed, 160ms) var(--spc-ease, ease);
}
.spc-field textarea { resize: vertical; min-height: 6.5rem; }

.spc-field input:hover,
.spc-field textarea:hover { border-color: var(--spc-accent, #6c3ce9); }

.spc-field input:focus-visible,
.spc-field textarea:focus-visible {
	outline: 2px solid var(--spc-accent, #6c3ce9);
	outline-offset: 1px;
	border-color: var(--spc-accent, #6c3ce9);
}

/* Error state. The message is always in the DOM so assistive tech
   announces it via aria-describedby the moment it gains text. */
.spc-field-error {
	display: block;
	margin-top: 4px;
	font-size: .82em;
	line-height: 1.35;
	color: var(--spc-danger, #b32d2e);
}
.spc-field-error:empty { display: none; }

.spc-field.has-error input,
.spc-field.has-error textarea { border-color: var(--spc-danger, #b32d2e); }

/* ---------------------------------------------------------------
   Terms
   --------------------------------------------------------------- */
.spc-checkout-terms { margin-top: 1.25rem; }
.spc-checkout-terms label {
	display: flex;
	align-items: flex-start;
	gap: .6rem;
	cursor: pointer;
	line-height: 1.4;
}
.spc-checkout-terms input { margin-top: .2em; flex: 0 0 auto; }
.spc-checkout-terms.has-error { color: var(--spc-danger, #b32d2e); }

/* ---------------------------------------------------------------
   Summary
   --------------------------------------------------------------- */
.spc-checkout-aside { box-sizing: border-box; }

.spc-checkout-line {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--spc-border, rgba(0,0,0,.14));
}
.spc-checkout-line:last-child { border-bottom: 0; }

.spc-checkout-line-thumb { flex: 0 0 auto; }
.spc-checkout-line-thumb img {
	display: block;
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: var(--spc-radius, 4px);
}

.spc-checkout-line-name {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}
.spc-checkout-line-variation,
.spc-checkout-line-qty {
	display: block;
	margin-top: 2px;
	font-size: .85em;
	font-weight: 400;
	color: var(--spc-muted, #5c6470);
}

.spc-checkout-line-total {
	flex: 0 0 auto;
	font-weight: 600;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.spc-checkout-totals { margin-top: 1rem; }
.spc-checkout-total-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	margin: 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.spc-checkout-note {
	margin: .5rem 0 0;
	font-size: .85em;
	color: var(--spc-muted, #5c6470);
}

.spc-checkout-submit { margin-top: 1.25rem; cursor: pointer; }
.spc-checkout-submit:disabled { opacity: .6; cursor: progress; }

/* ---------------------------------------------------------------
   Notices
   --------------------------------------------------------------- */
.spc-checkout-notice {
	margin: 0 0 1.25rem;
	padding: .8rem 1rem;
	border-radius: var(--spc-radius, 4px);
	background: var(--spc-surface-subtle, rgba(0,0,0,.05));
}
.spc-checkout-notice.is-error {
	color: var(--spc-danger, #b32d2e);
	background: color-mix(in srgb, var(--spc-danger, #b32d2e) 8%, transparent);
}

.spc-checkout-empty {
	margin: 0;
	padding: 3rem 1rem;
	text-align: center;
	color: var(--spc-muted, #5c6470);
	border: 1px dashed var(--spc-border, rgba(0,0,0,.14));
	border-radius: var(--spc-radius-lg, 8px);
}

/* ---------------------------------------------------------------
   Narrow screens: one column, and half-width fields go full width
   so labels and values are never cramped.
   --------------------------------------------------------------- */
@media (max-width: 1024px) {
	.spc-checkout-form { flex-direction: column; gap: 32px; }
	.spc-checkout--two-column .spc-checkout-main,
	.spc-checkout--two-column .spc-checkout-aside {
		flex: 1 1 100% !important;
		width: 100%;
		position: static !important;
	}
}

@media (max-width: 600px) {
	.spc-field--50 { flex: 1 1 100%; }
}

@media (pointer: coarse) {
	.spc-field input,
	.spc-field textarea { min-height: 44px; }
	.spc-checkout-terms input { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
	.spc-field input,
	.spc-field textarea,
	.spc-checkout-submit { transition-duration: 1ms !important; }
}

/* ---------------------------------------------------------------
   Thank you
   --------------------------------------------------------------- */
.spc-thankyou-title { margin: 0 0 .5rem; }
.spc-thankyou-intro { margin: 0 0 1rem; color: var(--spc-muted, #5c6470); }
.spc-thankyou-ref {
	margin: 0 0 1.5rem;
	font-variant-numeric: tabular-nums;
}
.spc-thankyou-details { margin-top: 1.75rem; }
.spc-thankyou-details h3 { margin: 0 0 .4rem; font-size: 1em; }
.spc-thankyou-details p { margin: 0; color: var(--spc-muted, #5c6470); line-height: 1.6; }

/* ---------------------------------------------------------------
   Discount code
   --------------------------------------------------------------- */
.spc-discount { margin-top: 1.25rem; }
.spc-discount-label {
	display: block;
	margin-bottom: 6px;
	font-size: .9em;
	font-weight: 600;
}
.spc-discount-row { display: flex; gap: 8px; }
.spc-discount-input {
	box-sizing: border-box;
	flex: 1 1 auto;
	min-width: 0;
	padding: .6rem .7rem;
	font: inherit;
	color: inherit;
	text-transform: uppercase;
	background: transparent;
	border: 1px solid var(--spc-border-strong, rgba(0,0,0,.24));
	border-radius: var(--spc-radius, 4px);
}
.spc-discount-input::placeholder { text-transform: none; }

.spc-discount-apply,
.spc-discount-remove {
	flex: 0 0 auto;
	padding: .6rem 1rem;
	font: inherit;
	cursor: pointer;
	color: inherit;
	background: var(--spc-surface-subtle, rgba(0,0,0,.05));
	border: 0;
	border-radius: var(--spc-radius, 4px);
	transition: background-color var(--spc-speed, 160ms) var(--spc-ease, ease);
}
.spc-discount-apply:hover,
.spc-discount-remove:hover { background: var(--spc-surface-hover, rgba(0,0,0,.09)); }
.spc-discount-apply:disabled { opacity: .6; cursor: progress; }

/* An applied code reads as a fact, not an input. */
.spc-discount-applied {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: .55rem .75rem;
	background: var(--spc-surface-subtle, rgba(0,0,0,.05));
	border-radius: var(--spc-radius, 4px);
}
.spc-discount-code { font-weight: 600; letter-spacing: .03em; }
.spc-discount-remove { padding: .25rem .6rem; font-size: .85em; background: none; }

.spc-discount-message { margin: 6px 0 0; font-size: .85em; line-height: 1.35; }
.spc-discount-message:empty { display: none; }
.spc-discount-message.is-error { color: var(--spc-danger, #b32d2e); }

/* ---------------------------------------------------------------
   Delivery
   --------------------------------------------------------------- */
.spc-delivery {
	margin: 1.75rem 0 0;
	padding: 0;
	border: 0;
	min-width: 0; /* fieldsets get a min-content floor otherwise */
}
.spc-delivery legend { padding: 0; }

.spc-delivery-subtitle {
	margin: 0 0 8px;
	font-size: .85em;
	color: var(--spc-muted, #5c6470);
}

/* Grouped: one bordered container, hairline dividers between rows.
   Reads as a single control rather than a stack of separate cards. */
.spc-delivery--grouped .spc-delivery-group {
	border: 1px solid var(--spc-border, rgba(0,0,0,.14));
	border-radius: var(--spc-radius-lg, 8px);
	overflow: hidden;
}
.spc-delivery--grouped .spc-delivery-option {
	margin: 0;
	border: 0;
	border-bottom: 1px solid var(--spc-border, rgba(0,0,0,.14));
	border-radius: 0;
	box-shadow: none;
}
.spc-delivery--grouped .spc-delivery-option:last-child { border-bottom: 0; }
.spc-delivery--grouped .spc-delivery-option:hover {
	border-color: var(--spc-border, rgba(0,0,0,.14));
	background: var(--spc-surface-subtle, rgba(0,0,0,.03));
}
.spc-delivery--grouped .spc-delivery-option.is-selected {
	box-shadow: none;
	border-color: var(--spc-border, rgba(0,0,0,.14));
}

.spc-delivery-option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: .9rem 1rem;
	cursor: pointer;
	transition: background-color var(--spc-speed, 160ms) var(--spc-ease, ease),
	            border-color var(--spc-speed, 160ms) var(--spc-ease, ease);
}
.spc-delivery-option input {
	flex: 0 0 auto;
	margin: 0;
	width: 18px;
	height: 18px;
	accent-color: var(--spc-accent, #6c3ce9);
}
.spc-delivery-option:focus-within {
	outline: 2px solid var(--spc-accent, #6c3ce9);
	outline-offset: -2px;
}

/* Cards: separate bordered rows, for when the grouped look is not wanted. */
.spc-delivery--cards .spc-delivery-option {
	margin-bottom: 8px;
	border: 1px solid var(--spc-border, rgba(0,0,0,.14));
	border-radius: var(--spc-radius, 4px);
}
.spc-delivery--cards .spc-delivery-option:hover { border-color: var(--spc-accent, #6c3ce9); }
.spc-delivery--cards .spc-delivery-option.is-selected {
	border-color: var(--spc-accent, #6c3ce9);
	box-shadow: inset 0 0 0 1px var(--spc-accent, #6c3ce9);
}

.spc-delivery-icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--spc-muted, #5c6470);
}
.spc-delivery-icon svg { display: block; width: 22px; height: 22px; }
.spc-delivery-icon i,
.spc-delivery-icon .eicon { font-size: 20px; line-height: 1; }

.spc-delivery-body { flex: 1 1 auto; min-width: 0; }
.spc-delivery-name {
	display: block;
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}
.spc-delivery-eta,
.spc-delivery-desc {
	display: block;
	margin-top: 2px;
	font-size: .85em;
	color: var(--spc-muted, #5c6470);
}

/* Price as a pill: sits apart from the label without competing with it. */
.spc-delivery-cost {
	flex: 0 0 auto;
	padding: .3rem .6rem;
	font-size: .95em;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	background: var(--spc-surface-subtle, rgba(0,0,0,.05));
	border-radius: var(--spc-radius, 4px);
}

/* ---------------------------------------------------------------
   Totals rows
   --------------------------------------------------------------- */
.spc-checkout-total-row[hidden] { display: none; }
.spc-checkout-total-row { padding: 4px 0; }
.spc-total-discount { color: var(--spc-accent, #6c3ce9); }
.spc-total-discount-code,
.spc-total-delivery-label {
	font-weight: 400;
	font-size: .85em;
	color: var(--spc-muted, #5c6470);
}
.spc-total-grand {
	margin-top: 8px;
	padding-top: 10px;
	border-top: 1px solid var(--spc-border, rgba(0,0,0,.14));
	font-size: 1.1em;
}

@media (pointer: coarse) {
	.spc-discount-input,
	.spc-discount-apply { min-height: 44px; }
	.spc-delivery-option { padding-top: 1rem; padding-bottom: 1rem; }
	.spc-delivery-option input { width: 22px; height: 22px; }
}

@media (max-width: 480px) {
	/* Stack the pill under the label rather than squeezing both. */
	.spc-delivery-option { align-items: flex-start; }
	.spc-delivery-cost { align-self: center; }
}
