/**
 * "Written by our team" badge + tooltip, shown inline next to "Prefer
 * us on Google" at the top of the article body (see
 * inc/article-badges.php for the shared row, css/prefer-on-google.css
 * for that button's own styling).
 */

.ic-badge-row {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 0 0 20px;
}

.ic-badge-row .ic-prefer-google-btn {
	margin: 0;
}

.ic-human-badge {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	padding: 7px 14px;
	border: 1px solid #d3e3f3;
	border-radius: 999px;
	background: #f0f6fc;
	color: #1e3a8a;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	font-family: inherit;
}

.ic-human-badge svg {
	flex: 0 0 auto;
	width: 15px;
	height: 15px;
	color: #2563eb;
}

.ic-human-badge span:not(.ic-human-badge__tip) {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ic-human-badge:hover,
.ic-human-badge:focus-visible,
.ic-human-badge.is-open {
	background: #dbeafe;
}

/* Tooltip opens downward: this row sits at the very top of the
   article, right under the title, so an upward-opening tooltip would
   risk clipping above the viewport on both mobile and desktop. */
.ic-human-badge__tip {
	position: absolute;
	left: 0;
	right: auto;
	top: calc(100% + 8px);
	z-index: 20;
	width: 280px;
	max-width: min(90vw, 320px);
	padding: 10px 12px;
	border-radius: 6px;
	background: #1e2937;
	color: #f3f4f6;
	font-size: 0.78rem;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	white-space: normal;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	pointer-events: none;
}

.ic-human-badge__tip::after {
	content: "";
	position: absolute;
	bottom: 100%;
	left: 18px;
	border: 6px solid transparent;
	border-bottom-color: #1e2937;
}

@media (hover: hover) {
	.ic-human-badge:hover .ic-human-badge__tip,
	.ic-human-badge:focus-visible .ic-human-badge__tip {
		opacity: 1;
		visibility: visible;
		transform: none;
	}
}

.ic-human-badge.is-open .ic-human-badge__tip {
	opacity: 1;
	visibility: visible;
	transform: none;
}

@media (prefers-reduced-motion: no-preference) {
	.ic-human-badge__tip {
		transition: opacity 0.15s ease, transform 0.15s ease;
	}
}

/* On narrow phones the badge can sit anywhere in the row once it wraps
   (flex-wrap above) -- anchoring the tooltip to the badge itself and
   just capping its width (the old approach) still let it run off
   whichever screen edge is closer, since a fixed offset from the badge
   doesn't account for the badge's actual position. Anchor to the whole
   row instead (.ic-badge-row has position: relative) and stretch the
   tooltip to the row's own width, which is already safely inset from
   the viewport by the article's own padding -- it can never overflow
   the screen regardless of where the badge itself lands. */
@media (max-width: 480px) {
	.ic-human-badge {
		position: static;
		font-size: 0.8rem;
		padding: 6px 12px;
	}

	.ic-human-badge__tip {
		left: 0;
		right: 0;
		top: 100%;
		width: auto;
		max-width: none;
	}

	.ic-human-badge__tip::after {
		display: none;
	}
}
