/**
 * Stepwise Product Bundles — frontend styles.
 *
 * Everything is scoped under .swb-bundle and driven by CSS variables so a shop
 * can re-skin the builder without touching this file. Fonts are inherited from
 * the active theme on purpose — the plugin shouldn't fight the store's identity.
 */

.swb-bundle {
	--swb-bg: #fbfaf7;
	--swb-surface: #ffffff;
	--swb-ink: #3a362f;
	--swb-muted: #857f74;
	--swb-line: #e8e2d6;
	--swb-accent: #7e8a6f;         /* sage */
	--swb-accent-ink: #4f5942;
	--swb-accent-soft: #eef1e8;
	--swb-powder: #e7cfc9;         /* warm powder for the savings moment */
	--swb-powder-ink: #9c5f52;
	--swb-radius: 14px;
	--swb-radius-sm: 9px;
	--swb-gap: 18px;

	color: var(--swb-ink);
	font-family: inherit;
	line-height: 1.5;
	max-width: 1080px;
	margin-inline: auto;
}

.swb-bundle *,
.swb-bundle *::before,
.swb-bundle *::after { box-sizing: border-box; }

/* ---- header & banner ---------------------------------------------------- */

.swb-banner-img { width: 100%; height: auto; border-radius: var(--swb-radius); display: block; }
.swb-head { margin: 18px 0 10px; }
.swb-title { margin: 0 0 .35em; font-size: 1.6rem; line-height: 1.15; }
.swb-intro { color: var(--swb-muted); max-width: 62ch; }

/* ---- progress stepper --------------------------------------------------- */

.swb-progress { margin: 8px 0 22px; }
.swb-progress-list {
	list-style: none; margin: 0; padding: 0 0 6px;
	display: flex; gap: 8px; overflow-x: auto;
	scrollbar-width: thin;
}
.swb-progress-item { flex: 0 0 auto; }
.swb-progress-btn {
	display: inline-flex; align-items: center; gap: 8px;
	background: transparent; border: 1px solid var(--swb-line);
	border-radius: 999px; padding: 7px 14px 7px 8px;
	color: var(--swb-muted); cursor: pointer; font: inherit;
	transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.swb-progress-btn[disabled] { cursor: default; opacity: .55; }
.swb-progress-num {
	display: inline-grid; place-items: center;
	width: 24px; height: 24px; border-radius: 50%;
	background: var(--swb-accent-soft); color: var(--swb-accent-ink);
	font-size: .82rem; font-weight: 600;
}
.swb-progress-item.is-current .swb-progress-btn { border-color: var(--swb-accent); color: var(--swb-ink); background: var(--swb-surface); }
.swb-progress-item.is-current .swb-progress-num,
.swb-progress-item.is-done .swb-progress-num { background: var(--swb-accent); color: #fff; }
.swb-progress-item.is-missing .swb-progress-num { background: var(--swb-powder); color: var(--swb-powder-ink); box-shadow: 0 0 0 2px var(--swb-powder); }
.swb-progress-item.is-done .swb-progress-num::after { content: "\2713"; }
.swb-progress-item.is-done .swb-progress-num { font-size: 0; }
.swb-progress-item.is-done .swb-progress-num::after { font-size: .9rem; }
.swb-progress-label { font-size: .9rem; white-space: nowrap; }

/* ---- steps -------------------------------------------------------------- */

.swb-step-head { margin-bottom: 16px; }
.swb-step-eyebrow { margin: 0 0 4px; font-size: .8rem; color: var(--swb-muted); }
.swb-step-title { margin: 0 0 .3em; font-size: 1.28rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swb-step-desc { margin: 0 0 4px; color: var(--swb-muted); max-width: 60ch; }
.swb-step-rule { margin: 0; font-size: .88rem; color: var(--swb-accent-ink); }

.swb-badge { font-size: .68rem; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.swb-badge-required { background: var(--swb-accent); color: #fff; }
.swb-badge-optional { background: var(--swb-accent-soft); color: var(--swb-accent-ink); }

/* ---- product grid ------------------------------------------------------- */

.swb-grid { display: grid; gap: var(--swb-gap); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) {
	.swb-cols-3 { grid-template-columns: repeat(3, 1fr); }
	.swb-cols-4 { grid-template-columns: repeat(3, 1fr); }
	.swb-cols-5 { grid-template-columns: repeat(3, 1fr); }
	.swb-cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
	.swb-cols-4 { grid-template-columns: repeat(4, 1fr); }
	.swb-cols-5 { grid-template-columns: repeat(5, 1fr); }
	.swb-cols-6 { grid-template-columns: repeat(6, 1fr); }
}

.swb-card {
	position: relative; background: var(--swb-surface);
	border: 1px solid var(--swb-line); border-radius: var(--swb-radius);
	padding: 12px; display: flex; flex-direction: column;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.swb-card.is-selected {
	border-color: var(--swb-accent);
	box-shadow: 0 0 0 1px var(--swb-accent), 0 8px 22px -16px rgba(79, 89, 66, .8);
}
.swb-card.is-oos { opacity: .6; }

.swb-card-media { position: relative; border-radius: var(--swb-radius-sm); overflow: hidden; aspect-ratio: 1 / 1; background: var(--swb-accent-soft); }
.swb-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.swb-check {
	position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
	border-radius: 50%; background: var(--swb-accent); opacity: 0; transform: scale(.6);
	transition: opacity .15s ease, transform .15s ease;
}
.swb-check::after { content: "\2713"; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; }
.swb-card.is-selected .swb-check { opacity: 1; transform: scale(1); }

.swb-quickview {
	position: absolute; left: 8px; bottom: 8px;
	background: rgba(255, 255, 255, .92); border: 0; border-radius: 999px;
	padding: 5px 11px; font: inherit; font-size: .78rem; color: var(--swb-ink);
	cursor: pointer; opacity: 0; transition: opacity .15s ease;
}
.swb-card-media:hover .swb-quickview,
.swb-quickview:focus-visible { opacity: 1; }

.swb-card-body { padding: 10px 2px 12px; flex: 1; }
.swb-card-name { margin: 0 0 3px; font-size: .95rem; font-weight: 600; line-height: 1.3; }
.swb-card-sku { margin: 0 0 6px; font-size: .74rem; color: var(--swb-muted); }
.swb-card-price { margin: 0; font-size: 1rem; }

.swb-card-actions { margin-top: auto; }
.swb-card-actions .swb-toggle { width: 100%; }
.swb-card.is-selected .swb-toggle { background: var(--swb-accent); border-color: var(--swb-accent); color: #fff; }

/* quantity stepper */
.swb-qty { display: inline-flex; align-items: center; border: 1px solid var(--swb-line); border-radius: 999px; overflow: hidden; width: 100%; justify-content: space-between; }
.swb-qty button { background: transparent; border: 0; width: 40px; height: 38px; font-size: 1.1rem; cursor: pointer; color: var(--swb-ink); }
.swb-qty button:hover { background: var(--swb-accent-soft); }
.swb-qty-value { min-width: 2ch; text-align: center; font-weight: 600; }

/* limit flash */
@keyframes swb-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.swb-step.swb-limit .swb-step-rule { color: var(--swb-powder-ink); animation: swb-shake .3s ease; font-weight: 600; }

/* ---- summary + actions -------------------------------------------------- */

.swb-summary {
	margin-top: 26px; background: var(--swb-surface);
	border: 1px solid var(--swb-line); border-radius: var(--swb-radius);
	padding: 18px 20px;
}

/* ---- running text recap ------------------------------------------------- */

.swb-recap-heading { margin: 0 0 8px; font-size: .8rem; letter-spacing: .02em; text-transform: uppercase; color: var(--swb-muted); }
.swb-recap { margin-bottom: 14px; }
.swb-recap-row { padding: 8px 0; border-bottom: 1px dashed var(--swb-line); }
.swb-recap-row:last-child { border-bottom: 0; }
.swb-recap-step { margin: 0 0 3px; font-size: .82rem; color: var(--swb-muted); }
.swb-recap-items { list-style: none; margin: 0; padding: 0; }
.swb-recap-item { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 1px 0; }
.swb-recap-name { font-weight: 600; }
.swb-recap-price { color: var(--swb-muted); white-space: nowrap; }
.swb-recap-row.is-missing .swb-recap-step { color: var(--swb-ink); }
.swb-recap-warn { margin: 0; font-size: .84rem; font-weight: 600; color: var(--swb-powder-ink); }
.swb-recap-empty { margin: 0 0 14px; color: var(--swb-muted); font-size: .9rem; }

.swb-summary-lines { display: grid; gap: 6px; margin-bottom: 14px; padding-top: 4px; border-top: 1px solid var(--swb-line); }
.swb-summary-row { display: flex; justify-content: space-between; align-items: baseline; }
.swb-row-subtotal { color: var(--swb-muted); font-size: .95rem; }
.swb-row-save { color: var(--swb-powder-ink); font-weight: 600; }
.swb-row-save .swb-save-amount { background: var(--swb-powder); color: var(--swb-powder-ink); padding: 2px 10px; border-radius: 999px; }
.swb-row-total { font-size: 1.35rem; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--swb-line); }

.swb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.swb-actions .button { flex: 1 1 auto; }
.swb-actions .swb-next, .swb-actions .swb-submit { min-width: 55%; }
.swb-actions .swb-prev { flex: 0 0 auto; }
.swb-submit[disabled] { opacity: .5; cursor: not-allowed; }

.swb-hint { margin: 10px 0 0; font-size: .88rem; color: var(--swb-muted); min-height: 1.2em; }
.swb-hint.is-error { color: var(--swb-powder-ink); }

.swb-empty { color: var(--swb-muted); padding: 18px; background: var(--swb-accent-soft); border-radius: var(--swb-radius-sm); }

/* sticky summary on small screens */
@media (max-width: 600px) {
	.swb-summary {
		position: sticky; bottom: 0; z-index: 5;
		margin-inline: calc(-1 * var(--swb-gap));
		border-radius: var(--swb-radius) var(--swb-radius) 0 0;
		box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, .5);
	}
	.swb-row-subtotal { display: none; }
}

/* ---- quick view modal --------------------------------------------------- */

.swb-modal-overlay {
	position: fixed; inset: 0; background: rgba(40, 37, 32, .5);
	display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100000;
}
.swb-modal-overlay.is-open { display: flex; }
.swb-modal {
	position: relative; background: var(--swb-surface, #fff); color: var(--swb-ink, #3a362f);
	border-radius: 16px; max-width: 720px; width: 100%; max-height: 88vh; overflow: auto; padding: 26px;
}
.swb-modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; color: inherit; }
.swb-qv { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 560px) { .swb-qv { grid-template-columns: 1fr 1fr; } }
.swb-qv-media img { width: 100%; height: auto; border-radius: 12px; }
.swb-qv-title { margin: 0 0 .3em; }
.swb-qv-sku { color: var(--swb-muted); font-size: .8rem; margin: 0 0 .6em; }
.swb-qv-price { font-size: 1.2rem; margin-bottom: .8em; }
.swb-qv-loading { min-height: 180px; }
body.swb-modal-open { overflow: hidden; }

/* ---- cart: nest bundle children under the parent ----------------------- */

.swb-parent-row td.product-name,
.swb-parent-row .wc-block-cart-item__product { font-weight: 700; }

.swb-child-row td.product-name,
.swb-child-row .wc-block-cart-item__product {
	padding-left: 2.4em;
	position: relative;
}
.swb-child-row td.product-name::before {
	content: "\2514";
	position: absolute;
	left: 1em;
	top: 0.1em;
	color: var(--swb-muted, #857f74);
}
.swb-child-row {
	box-shadow: inset 3px 0 0 var(--swb-accent-soft, #eef1e8);
}
.swb-child-row td { background: rgba(126, 138, 111, 0.03); }

/* ---- accessibility ------------------------------------------------------ */

.swb-bundle button:focus-visible,
.swb-bundle a:focus-visible,
.swb-modal button:focus-visible {
	outline: 2px solid var(--swb-accent, #7e8a6f); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.swb-bundle *, .swb-modal * { transition: none !important; animation: none !important; }
	.swb-bundle .swb-root, .swb-bundle { scroll-behavior: auto; }
}
