/**
 * Field-level tooltip popovers (Phase G.4).
 *
 * Structure:
 *   .wbam-tip            inline-block positioning anchor
 *     .wbam-tip__icon    small circular info trigger
 *     .wbam-tip__popover absolute card with arrow
 *
 * The popover is hidden by default (via [hidden]) and revealed
 * when the sibling button toggles aria-expanded="true".
 */

.wbam-tip {
	position: relative;
	display: inline-block;
	vertical-align: middle;
	margin-left: 4px;
	line-height: 1;
}

.wbam-tip__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	padding: 0;
	margin: 0;
	border: 1px solid transparent;
	border-radius: 50%;
	background: transparent;
	color: var(--wbam-text-muted);
	cursor: pointer;
	transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.wbam-tip__icon:hover,
.wbam-tip__icon:focus {
	color: var(--wbam-accent);
	background: #f0f6fc;
	outline: none;
}

.wbam-tip__icon:focus-visible {
	box-shadow: 0 0 0 2px var(--wbam-accent);
}

.wbam-tip__icon[aria-expanded="true"] {
	color: var(--wbam-accent);
	background: #f0f6fc;
}

.wbam-tip__icon .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
	line-height: 1;
}

.wbam-tip__popover {
	position: absolute;
	z-index: 99999;
	max-width: 280px;
	width: max-content;
	min-width: 200px;
	padding: 10px 12px;
	background: var(--wbam-bg);
	color: var(--wbam-text);
	border: 1px solid var(--wbam-border-strong);
	border-radius: 4px;
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.12 );
	font-size: 12px;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	white-space: normal;
}

.wbam-tip__popover[hidden] {
	display: none;
}

.wbam-tip__body {
	display: block;
}

.wbam-tip__arrow {
	position: absolute;
	width: 10px;
	height: 10px;
	background: var(--wbam-bg);
	border: 1px solid var(--wbam-border-strong);
	transform: rotate( 45deg );
}

/* Placement: top (default). Popover sits above the icon. */
.wbam-tip[data-placement="top"] .wbam-tip__popover {
	bottom: calc( 100% + 8px );
	left: 50%;
	transform: translateX( -50% );
}

.wbam-tip[data-placement="top"] .wbam-tip__arrow {
	bottom: -6px;
	left: 50%;
	margin-left: -5px;
	border-top: 0;
	border-left: 0;
}

/* Placement: bottom. */
.wbam-tip[data-placement="bottom"] .wbam-tip__popover {
	top: calc( 100% + 8px );
	left: 50%;
	transform: translateX( -50% );
}

.wbam-tip[data-placement="bottom"] .wbam-tip__arrow {
	top: -6px;
	left: 50%;
	margin-left: -5px;
	border-bottom: 0;
	border-right: 0;
}

/* Placement: right. */
.wbam-tip[data-placement="right"] .wbam-tip__popover {
	top: 50%;
	left: calc( 100% + 8px );
	transform: translateY( -50% );
}

.wbam-tip[data-placement="right"] .wbam-tip__arrow {
	top: 50%;
	left: -6px;
	margin-top: -5px;
	border-right: 0;
	border-top: 0;
}

/* Placement: left. */
.wbam-tip[data-placement="left"] .wbam-tip__popover {
	top: 50%;
	right: calc( 100% + 8px );
	transform: translateY( -50% );
}

.wbam-tip[data-placement="left"] .wbam-tip__arrow {
	top: 50%;
	right: -6px;
	margin-top: -5px;
	border-left: 0;
	border-bottom: 0;
}

/* RTL support: flip left/right placements. */
body.rtl .wbam-tip[data-placement="left"] .wbam-tip__popover {
	right: auto;
	left: calc( 100% + 8px );
}

body.rtl .wbam-tip[data-placement="right"] .wbam-tip__popover {
	left: auto;
	right: calc( 100% + 8px );
}
