/**
 * "Also available on Amazon" panel (inc/external-buy.php).
 *
 * .nelvin-ext-buy  = in-card copy: hidden for mouse users (they get the
 *                    floating .nelvin-ext-tip, assets/js/external-buy.js),
 *                    a row inside the card on touch screens / keyboard focus.
 * .nelvin-ext-tip  = card-wide tooltip under the card.
 */

.nelvin-ext-buy {
	container-type: inline-size;
	position: absolute;

	/* Pinned to 0/0: cards in a clipped slider must not widen the page. */
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.nelvin-ext-buy:focus-within {
	position: static;
	width: 100%;
	height: auto;
	margin: 12px 0 0;
	overflow: visible;
	clip: auto;
	white-space: normal;
}

@media (hover: none) {

	.nelvin-ext-buy {
		position: static;
		width: 100%;
		height: auto;
		margin: 12px 0 0;
		overflow: visible;
		clip: auto;
		white-space: normal;
	}
}

/* Product page: always shown below Add to Cart / Buy Now. */
.nelvin-ext-buy.nelvin-ext-buy--inline {
	position: static;
	width: 100%;
	height: auto;
	margin: 0;
	overflow: visible;
	clip: auto;
	white-space: normal;
}

/* Shared content (in-card row + tooltip). */
.nelvin-ext-buy__link {
	position: relative; /* Keeps the absolute sr-only text inside clipped sliders (touch screens). */
	display: flex;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	padding: 8px 8px 8px 12px;
	border: 1px solid var(--nelvin-surface-3);
	border-radius: 12px;
	background: #fff;
	color: var(--nelvin-text);
	text-decoration: none;
}

.nelvin-ext-buy__brand {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.nelvin-ext-buy__eyebrow {
	color: var(--nelvin-subtle);
	font-size: 11px;
	font-weight: 500;
	line-height: 1.2;
	white-space: nowrap;
}

.nelvin-ext-buy__logo {
	display: block;
	width: 68px;
	height: auto;
}

.nelvin-ext-buy__store {
	overflow: hidden;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nelvin-ext-buy__cta {
	display: inline-flex;
	flex-shrink: 0;
	gap: 8px;
	align-items: center;
	box-sizing: border-box;
	height: 36px;
	padding: 0 6px 0 14px;
	border: 1px solid #fcd200;
	border-radius: 8px;
	background: #ffd814;
	box-shadow: 0 1px 2px rgba(15, 17, 17, 0.12);
	color: #0f1111;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.1px;
	white-space: nowrap;
	transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Arrow in a small dark circle. */
.nelvin-ext-buy__cta svg {
	flex-shrink: 0;
	box-sizing: border-box;
	width: 22px;
	height: 22px;
	padding: 6px;
	border-radius: 6px;
	background: #0f1111;
	color: #ffd814;
	transition: transform 0.2s ease;
}

.nelvin-ext-buy__link:focus-visible {
	outline: 2px solid var(--nelvin-primary);
	outline-offset: 2px;
}

/* Product page row: a little larger. */
.nelvin-ext-buy--inline .nelvin-ext-buy__link {
	padding: 12px 12px 12px 16px;
	border-color: var(--nelvin-surface-3);
	border-radius: 8px;
}

.nelvin-ext-buy--inline .nelvin-ext-buy__eyebrow {
	font-size: 12px;
}

.nelvin-ext-buy--inline .nelvin-ext-buy__logo {
	width: 80px;
}

.nelvin-ext-buy--inline .nelvin-ext-buy__cta {
	height: 44px;
	padding: 0 8px 0 20px;
	gap: 12px;
	font-size: 14px;
}

.nelvin-ext-buy--inline .nelvin-ext-buy__cta svg {
	width: 26px;
	height: 26px;
	padding: 7px;
}

.nelvin-ext-buy__link:hover .nelvin-ext-buy__cta,
.nelvin-ext-buy__link:focus-visible .nelvin-ext-buy__cta {
	background: #f7ca00;
	box-shadow: 0 3px 8px rgba(15, 17, 17, 0.16);
}

.nelvin-ext-buy__link:hover .nelvin-ext-buy__cta svg,
.nelvin-ext-buy__link:focus-visible .nelvin-ext-buy__cta svg {
	transform: translate(1px, -1px);
}

/* Narrow cards (2-column phone grid): logo above a full-width button. */
@container (max-width: 240px) {

	.nelvin-ext-buy__link {
		flex-direction: column;
		gap: 8px;
		align-items: stretch;
		padding: 8px;
	}

	.nelvin-ext-buy__brand {
		flex-direction: row;
		gap: 6px;
		align-items: center;
		justify-content: center;
	}

	.nelvin-ext-buy__logo {
		width: 56px;
		margin-top: 4px;
	}

	.nelvin-ext-buy__cta {
		justify-content: center;
		padding-left: 6px;
	}
}

/* Floating tooltip. */
.nelvin-ext-tip {
	container-type: inline-size;
	position: fixed;
	z-index: 45;
	top: 0;
	left: 0;
	box-sizing: border-box;
	padding: 6px;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 12px 32px rgba(51, 51, 51, 0.16), 0 1px 3px rgba(51, 51, 51, 0.08);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
	pointer-events: none;
}

.nelvin-ext-tip.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition-delay: 0s;
	pointer-events: auto;
}

.nelvin-ext-tip.is-above {
	transform: translateY(6px);
}

.nelvin-ext-tip.is-above.is-visible {
	transform: none;
}

/* Arrow pointing at the hovered button. */
.nelvin-ext-tip::before {
	content: "";
	position: absolute;
	top: -6px;
	left: var(--nelvin-ext-arrow, 50%);
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border-radius: 2px;
	background: #fff;
	transform: rotate(45deg);
}

.nelvin-ext-tip.is-above::before {
	top: auto;
	bottom: -6px;
}

/* Invisible bridge over the gap so moving the mouse down keeps it open. */
.nelvin-ext-tip::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 100%;
	left: 0;
	height: 12px;
}

.nelvin-ext-tip.is-above::after {
	top: 100%;
	bottom: auto;
}

.nelvin-ext-tip .nelvin-ext-buy__link {
	border-color: transparent;
}

@media (prefers-reduced-motion: reduce) {

	.nelvin-ext-tip,
	.nelvin-ext-tip.is-visible {
		transform: none;
		transition: none;
	}
}
