/**
 * Basket Share for WooCommerce — the Share basket button and panel.
 *
 * Deliberately plain: the button takes the theme's own button classes, and the
 * panel inherits the theme's font and text colour. A theme can retune it with
 * these custom properties on .bswc:
 *
 *   --bswc-accent       the Copy link button and focus ring (default #1d1d1b)
 *   --bswc-accent-ink   text on the accent (default #fff)
 *   --bswc-surface      panel background (default #fff)
 *   --bswc-line         borders (default rgba(0,0,0,.16))
 *   --bswc-radius       panel and field corners (default 6px)
 *   --bswc-control-radius  button and field corners (default the panel's)
 */

/* Defaults at zero specificity, so a theme's .bswc { --bswc-accent: … } wins
   whichever stylesheet loads first. */
:where(.bswc) {
	--bswc-accent: #1d1d1b;
	--bswc-accent-ink: #fff;
	--bswc-surface: #fff;
	--bswc-line: rgba(0, 0, 0, 0.16);
	--bswc-muted: color-mix(in srgb, currentColor 68%, transparent);
	--bswc-radius: 6px;
	--bswc-control-radius: var(--bswc-radius);
}

.bswc {
	position: relative;
	box-sizing: border-box;
	max-width: 100%;
}

.bswc *,
.bswc *::before,
.bswc *::after {
	box-sizing: inherit;
}

.bswc [hidden] {
	display: none !important;
}

.bswc__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	cursor: pointer;
}

.bswc__icon {
	flex: none;
}

.bswc.is-busy .bswc__toggle {
	cursor: progress;
}

/* The panel opens in the flow under the button, so it works inside a basket
   form, a side cart or a mini basket without any positioning. */
.bswc__panel {
	width: min(100%, 28rem);
	margin-top: 0.75rem;
	padding: 1rem 1.125rem 1.125rem;
	border: 1px solid var(--bswc-line);
	border-radius: var(--bswc-radius);
	background: var(--bswc-surface);
	box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.25);
	text-align: left;
	animation: bswc-in 0.18s ease-out;
}

@keyframes bswc-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.bswc__panel {
		animation: none;
	}
}

.bswc__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.bswc .bswc__title {
	margin: 0;
	font-size: 1.0625em;
	font-weight: 700;
	line-height: 1.3;
}

.bswc .bswc__close {
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	margin: -0.375rem -0.5rem -0.375rem 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	cursor: pointer;
}

.bswc .bswc__close:hover {
	background: color-mix(in srgb, currentColor 8%, transparent);
}

.bswc .bswc__lead {
	margin: 0.375rem 0 0.875rem;
	color: var(--bswc-muted);
	font-size: 0.875em;
	line-height: 1.45;
}

.bswc__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.bswc .bswc__url {
	display: block;
	width: 100%;
	min-height: 2.75rem;
	margin: 0;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--bswc-line);
	border-radius: var(--bswc-control-radius);
	background: color-mix(in srgb, currentColor 4%, var(--bswc-surface));
	color: inherit;
	font: inherit;
	font-size: 0.875em;
	text-overflow: ellipsis;
}

.bswc .bswc__url:focus {
	border-color: var(--bswc-accent);
	outline: none;
	box-shadow: 0 0 0 1px var(--bswc-accent);
}

.bswc.is-busy .bswc__url {
	background-image: linear-gradient(90deg, transparent, color-mix(in srgb, currentColor 8%, transparent), transparent);
	background-size: 40% 100%;
	background-repeat: no-repeat;
	animation: bswc-busy 1s linear infinite;
}

@keyframes bswc-busy {
	from {
		background-position: -40% 0;
	}
	to {
		background-position: 140% 0;
	}
}

.bswc__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.bswc .bswc__copy,
.bswc .bswc__email {
	display: inline-flex;
	flex: 1 1 9rem;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 2.75rem;
	margin: 0;
	padding: 0 1rem;
	border: 1px solid var(--bswc-accent);
	border-radius: var(--bswc-control-radius);
	font: inherit;
	font-size: 0.9375em;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}

.bswc .bswc__copy {
	background: var(--bswc-accent);
	color: var(--bswc-accent-ink);
}

.bswc .bswc__copy:hover:not(:disabled) {
	background: color-mix(in srgb, var(--bswc-accent) 84%, #000);
}

.bswc .bswc__email {
	background: var(--bswc-surface);
	color: var(--bswc-accent);
}

.bswc .bswc__email:hover:not([aria-disabled]) {
	background: color-mix(in srgb, var(--bswc-accent) 8%, var(--bswc-surface));
}

.bswc .bswc__copy:disabled,
.bswc .bswc__email[aria-disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

.bswc .bswc__copy:focus-visible,
.bswc .bswc__email:focus-visible,
.bswc .bswc__close:focus-visible {
	outline: 2px solid var(--bswc-accent);
	outline-offset: 2px;
}

.bswc .bswc__status {
	min-height: 1.25em;
	margin: 0.625rem 0 0;
	font-size: 0.875em;
	font-weight: 600;
	line-height: 1.4;
}

.bswc .bswc__status:empty {
	min-height: 0;
	margin: 0;
}

.bswc .bswc__status.is-done::before {
	content: "✓ ";
}

.bswc .bswc__status.is-error {
	color: #b42318;
}

.bswc .bswc__expiry {
	margin: 0.5rem 0 0;
	color: var(--bswc-muted);
	font-size: 0.8125em;
}
