/**
 * Front end styles for the cart link share panel.
 *
 * Colours are derived from currentColor so the panel picks up whatever the theme is
 * already using, rather than imposing a palette that will clash on somebody's storefront.
 */

.gcf-cart-link {
	--gcf-cl-line: rgba( 0, 0, 0, 0.14 );
	--gcf-cl-surface: rgba( 0, 0, 0, 0.02 );
	--gcf-cl-muted: rgba( 0, 0, 0, 0.6 );
	--gcf-cl-error: #b32d2e;
	--gcf-cl-ok: #1e6b30;
	--gcf-cl-radius: 8px;

	margin: 1.25em 0;
	max-width: 34rem;
}

@supports ( color: color-mix( in srgb, currentColor 10%, transparent ) ) {
	.gcf-cart-link {
		--gcf-cl-line: color-mix( in srgb, currentColor 18%, transparent );
		--gcf-cl-surface: color-mix( in srgb, currentColor 4%, transparent );
		--gcf-cl-muted: color-mix( in srgb, currentColor 65%, transparent );
	}
}

/* Trigger
   ------------------------------------------------------------------ */

.gcf-cart-link__trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 44px;
}

.gcf-cart-link__trigger[disabled] {
	opacity: 0.65;
	cursor: progress;
}

.gcf-cart-link__spinner {
	display: none;
	width: 0.85em;
	height: 0.85em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	opacity: 0.8;
	animation: gcf-cl-spin 0.6s linear infinite;
}

.gcf-cart-link.is-loading .gcf-cart-link__spinner {
	display: inline-block;
}

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

/* Panel
   ------------------------------------------------------------------ */

.gcf-cart-link__panel {
	margin-top: 0.75em;
	padding: 0.9rem 1rem 1rem;
	border: 1px solid var( --gcf-cl-line );
	border-radius: var( --gcf-cl-radius );
	background: var( --gcf-cl-surface );
	animation: gcf-cl-reveal 0.18s ease-out;
}

.gcf-cart-link__panel[hidden] {
	display: none;
}

@keyframes gcf-cl-reveal {
	from {
		opacity: 0;
		transform: translateY( -4px );
	}
}

.gcf-cart-link__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.gcf-cart-link__label {
	display: block;
	margin: 0;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var( --gcf-cl-muted );
}

.gcf-cart-link__close {
	flex: none;
	width: 32px;
	height: 32px;
	margin: -6px -6px 0 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: none;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	opacity: 0.55;
	cursor: pointer;
}

.gcf-cart-link__close:hover,
.gcf-cart-link__close:focus-visible {
	opacity: 1;
}

/* URL row
   ------------------------------------------------------------------ */

.gcf-cart-link__row {
	display: flex;
	gap: 0.5rem;
	align-items: stretch;
}

.gcf-cart-link__url {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 44px;
	padding: 0 0.7em;
	border: 1px solid var( --gcf-cl-line );
	border-radius: 6px;
	background: #fff;
	color: inherit;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
	/* Stops iOS Safari zooming the viewport when the field takes focus. */
	text-overflow: ellipsis;
}

.gcf-cart-link__copy {
	flex: none;
	min-height: 44px;
	white-space: nowrap;
}

.gcf-cart-link__copy.is-done {
	position: relative;
}

/* Share actions
   ------------------------------------------------------------------ */

.gcf-cart-link__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.7rem;
}

.gcf-cart-link__action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 0 0.9em;
	border: 1px solid var( --gcf-cl-line );
	border-radius: 999px;
	background: none;
	color: inherit;
	font-size: 0.85rem;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

.gcf-cart-link__action:hover,
.gcf-cart-link__action:focus-visible {
	border-color: currentColor;
	text-decoration: none;
}

.gcf-cart-link__action[hidden] {
	display: none;
}

.gcf-cart-link__hint {
	margin: 0.7rem 0 0;
	font-size: 0.8rem;
	line-height: 1.4;
	color: var( --gcf-cl-muted );
}

/* Messages
   ------------------------------------------------------------------ */

.gcf-cart-link__message {
	margin: 0.6em 0 0;
	font-size: 0.88rem;
	line-height: 1.4;
}

.gcf-cart-link__message:empty {
	display: none;
}

.gcf-cart-link__message--error {
	color: var( --gcf-cl-error );
}

/* Focus visibility, since themes often strip outlines from buttons.
   ------------------------------------------------------------------ */

.gcf-cart-link :focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Screen reader helper, in case the theme does not define one.
   ------------------------------------------------------------------ */

.gcf-cart-link .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* Narrow screens
   ------------------------------------------------------------------ */

@media ( max-width: 600px ) {
	.gcf-cart-link {
		max-width: none;
	}

	.gcf-cart-link__trigger {
		width: 100%;
	}

	.gcf-cart-link__row {
		flex-direction: column;
	}

	.gcf-cart-link__url {
		/* 16px keeps iOS Safari from zooming in when the field is focused. */
		font-size: 16px;
	}

	.gcf-cart-link__copy {
		width: 100%;
	}

	.gcf-cart-link__action {
		flex: 1 1 auto;
	}

	/* With a native share sheet available, the mail and text links are redundant. */
	.gcf-cart-link__native:not( [hidden] ) ~ .gcf-cart-link__email,
	.gcf-cart-link__native:not( [hidden] ) ~ .gcf-cart-link__sms {
		display: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.gcf-cart-link__panel,
	.gcf-cart-link__spinner {
		animation: none;
	}
}

@media ( prefers-color-scheme: dark ) {
	.gcf-cart-link__url {
		background: rgba( 255, 255, 255, 0.06 );
	}
}
