/* Info tooltip (cairn/info-tooltip) */

.fc-info-tooltip {
	--fc-info-tooltip-shift: 0px;
	--fc-info-tooltip-bg: var(--wp--preset--color--custom-mallorca-blue);
	align-items: center;
	display: inline-flex;
	position: relative;
}

/*
 * Blue rather than the dark grey of the design, so the trigger stays distinct
 * from the logo and the NPS badge beside it.
 */
.fc-info-tooltip__trigger {
	align-items: center;
	background: none;
	border: 0;
	color: var(--wp--preset--color--custom-mallorca-blue);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: var(--wp--preset--font-size--small, 16px);
	gap: 0.6em;
	line-height: 1.2;
	margin: 0;
	padding: 0.25em 0;
}

.fc-info-tooltip__label {
	text-decoration: underline dotted;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.35em;
	white-space: nowrap;
}

.fc-info-tooltip__trigger:focus-visible {
	border-radius: 4px;
	outline: 2px solid var(--wp--preset--color--custom-mallorca-blue);
	outline-offset: 3px;
}

.fc-info-tooltip__icon {
	flex: none;
}

/*
 * The panel opens to the right of the icon, covering the label, with an arrow
 * pointing back at the icon. 24px icon + 18px gap for the arrow.
 */
.fc-info-tooltip__panel {
	background: var(--fc-info-tooltip-bg);
	border-radius: var(--wp--preset--border-radius--medium, 10px);
	color: var(--wp--preset--color--custom-white);
	font-size: 16px;
	left: 42px;
	line-height: 1.45;
	max-width: min(25rem, calc(100vw - 32px));
	opacity: 0;
	padding: var(--wp--preset--spacing--30, 1rem) var(--wp--preset--spacing--40, 1.25rem);
	pointer-events: none;
	position: absolute;
	text-align: center;
	top: 50%;
	transform: translate(var(--fc-info-tooltip-shift), -50%);
	/*
	 * display: none rather than visibility: hidden while closed. A hidden panel
	 * still takes up room, and near the right edge of a phone screen it
	 * widened the whole page into a sideways scroll.
	 *
	 * It fades in (see @starting-style below) but closes instantly. A fade-out
	 * needs display to be transitioned too, and Mobile Safari could reopen the
	 * panel mid fade-out still treating it as hidden, so view.js measured it
	 * as zero-sized and nudged it off the side of the screen.
	 *
	 * Opacity only: sliding the panel in would animate it from where it sits
	 * before view.js nudges it on screen, overflowing the page mid-animation.
	 */
	display: none;
	transition: opacity 0.15s ease-out;
	width: max-content;
	z-index: 20;
}

.fc-info-tooltip__panel::before {
	border-block: 12px solid transparent;
	border-inline-end: 14px solid var(--fc-info-tooltip-bg);
	content: "";
	position: absolute;
	right: 100%;
	top: 50%;
	transform: translateY(-50%);
}

/*
 * Before view.js runs, fall back to hover and focus. Once it has, it owns the
 * open state so a tap can toggle the panel and Escape can dismiss it.
 */
.fc-info-tooltip:not(.is-enhanced):hover .fc-info-tooltip__panel,
.fc-info-tooltip:not(.is-enhanced):focus-within .fc-info-tooltip__panel,
.fc-info-tooltip[data-open="true"] .fc-info-tooltip__panel {
	display: block;
	opacity: 1;
	pointer-events: auto;
}

/* Where the fade starts from on the frame the panel appears. */
@starting-style {
	.fc-info-tooltip:not(.is-enhanced):hover .fc-info-tooltip__panel,
	.fc-info-tooltip:not(.is-enhanced):focus-within .fc-info-tooltip__panel,
	.fc-info-tooltip[data-open="true"] .fc-info-tooltip__panel {
		opacity: 0;
	}
}

/*
 * No room beside the icon on small screens, so the panel sits above it
 * instead, with larger text than the footer's own copy. The arrow is dropped
 * since it would no longer line up.
 *
 * Its right edge is pinned to the trigger's, so it grows leftwards: anything
 * past the left edge is simply off screen, whereas anything past the right
 * edge - even for the instant before view.js nudges it into view - makes
 * mobile browsers widen the whole page, and they never narrow it again.
 */
@media (max-width: 600px) {
	.fc-info-tooltip__trigger {
		padding-block: 0.5em;
	}

	.fc-info-tooltip__panel {
		bottom: calc(100% + 10px);
		font-size: 18px;
		left: auto;
		right: 0;
		top: auto;
		transform: translateX(var(--fc-info-tooltip-shift));
	}

	.fc-info-tooltip__panel::before {
		content: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fc-info-tooltip__panel {
		transition: none;
	}
}

/* Editor preview: just the trigger, since the panel only renders on the front end. */
.fc-info-tooltip.is-placeholder .fc-info-tooltip__trigger {
	cursor: default;
}
