/* ==========================================================================
   Bible Gateway Hover Popup — Liquid Glass
   ========================================================================== */

/* ── Processed link indicator ── */
.bgw-hover-link {
	cursor: pointer;
	text-decoration-style: dotted;
}

/* ── Popup container ── */
.bgw-hover-popup {
	position: absolute;
	z-index: 999999;
	width: min(420px, calc(100vw - 24px));
	max-height: 420px;
	display: flex;
	flex-direction: column;

	/* Hidden by default */
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px) scale(0.97);
	transition:
		opacity 0.22s ease,
		transform 0.22s ease,
		visibility 0.22s;
	pointer-events: none;
}

.bgw-hover-popup.bgw-hover-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* ── Inner card — liquid glass ── */
.bgw-hover-inner {
	display: flex;
	flex-direction: column;
	max-height: 420px;
	overflow: hidden;
	border-radius: 18px;

	/* Liquid glass layers — opaque enough for red-letter contrast */
	background:
		linear-gradient(
			135deg,
			rgba(255, 255, 255, 0.95) 0%,
			rgba(248, 248, 252, 0.92) 50%,
			rgba(255, 255, 255, 0.95) 100%
		);
	backdrop-filter: blur(28px) saturate(180%) brightness(1.05);
	-webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.05);

	/* Border — subtle glass edge */
	border: 1px solid rgba(255, 255, 255, 0.55);
	box-shadow:
		0 0 0 0.5px rgba(0, 0, 0, 0.04),        /* hairline outer */
		0 8px 32px rgba(0, 0, 0, 0.12),           /* soft drop */
		0 2px 8px rgba(0, 0, 0, 0.06),            /* close contact */
		inset 0 1px 0 rgba(255, 255, 255, 0.5);   /* inner highlight */
}

/* ── Header ── */
.bgw-hover-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px 8px;
	flex-shrink: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.bgw-hover-ref {
	font-weight: 700;
	font-size: 0.9rem;
	color: #1d1d1f;
	letter-spacing: -0.01em;
}

.bgw-hover-close {
	background: rgba(0, 0, 0, 0.06);
	border: none;
	border-radius: 50%;
	width: 26px;
	height: 26px;
	font-size: 1.1rem;
	line-height: 1;
	color: #86868b;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, color 0.15s;
}

.bgw-hover-close:hover {
	background: rgba(0, 0, 0, 0.1);
	color: #1d1d1f;
}

/* ── Body (scripture content) ── */
.bgw-hover-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 12px 16px;
	font-size: 0.92rem;
	line-height: 1.65;
	color: #1d1d1f;

	/* Thin scrollbar */
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.bgw-hover-body::-webkit-scrollbar {
	width: 5px;
}
.bgw-hover-body::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.15);
	border-radius: 3px;
}
.bgw-hover-body::-webkit-scrollbar-track {
	background: transparent;
}

/* Clean up Bible Gateway markup inside the popup */
.bgw-hover-body .chapternum {
	font-weight: 700;
	font-size: 0.85em;
	vertical-align: super;
	line-height: 0;
	margin-right: 2px;
}

.bgw-hover-body .versenum {
	font-weight: 600;
	font-size: 0.75em;
	vertical-align: super;
	line-height: 0;
	color: #86868b;
	margin-right: 1px;
}

.bgw-hover-body .woj {
	color: #8b0000;
	font-weight: 500;
}

.bgw-hover-body h3,
.bgw-hover-body h4 {
	font-size: 0.95rem;
	margin: 0.8em 0 0.3em;
}

.bgw-hover-body p {
	margin: 0 0 0.6em;
}

/* Hide footnotes / cross-refs inside popup */
.bgw-hover-body .crossreference,
.bgw-hover-body .footnote {
	display: none;
}

/* ── Footer ── */
.bgw-hover-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 16px 12px;
	flex-shrink: 0;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.bgw-hover-attr {
	font-size: 0.72rem;
	color: #86868b;
}
.bgw-hover-attr strong {
	color: #6e6e73;
}

.bgw-hover-full {
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--wp--preset--color--primary-blue, #003057);
	text-decoration: none;
	white-space: nowrap;
	transition: opacity 0.15s;
}
.bgw-hover-full:hover {
	opacity: 0.7;
}

/* ── Loading spinner ── */
.bgw-hover-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px 0;
}

.bgw-hover-spinner {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 2.5px solid rgba(0, 0, 0, 0.08);
	border-top-color: var(--wp--preset--color--primary-blue, #003057);
	animation: bgw-spin 0.7s linear infinite;
}

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

/* ── Translation fallback note ── */
.bgw-hover-fallback-note {
	font-size: 0.75rem;
	color: #6e6e73;
	background: rgba(0, 0, 0, 0.04);
	border-radius: 8px;
	padding: 6px 10px;
	margin-bottom: 10px;
	line-height: 1.4;
}
.bgw-hover-fallback-note strong {
	color: #1d1d1f;
}

/* ── Error ── */
.bgw-hover-error {
	text-align: center;
	color: #86868b;
	font-size: 0.85rem;
	padding: 20px 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media screen and (max-width: 600px) {
	.bgw-hover-popup {
		/* On mobile, anchor to bottom of viewport like a sheet */
		position: fixed !important;
		bottom: 0 !important;
		top: auto !important;
		left: 0 !important;
		right: 0 !important;
		width: 100%;
		max-height: 55vh;
		border-radius: 0;
		transform: translateY(100%);
		transition:
			opacity 0.25s ease,
			transform 0.25s ease,
			visibility 0.25s;
	}

	.bgw-hover-popup.bgw-hover-visible {
		transform: translateY(0);
	}

	.bgw-hover-inner {
		border-radius: 18px 18px 0 0;
		max-height: 55vh;
	}

	/* Drag handle visual cue */
	.bgw-hover-header::before {
		content: '';
		position: absolute;
		top: 6px;
		left: 50%;
		transform: translateX(-50%);
		width: 36px;
		height: 4px;
		border-radius: 2px;
		background: rgba(0, 0, 0, 0.12);
	}

	.bgw-hover-header {
		position: relative;
		padding-top: 18px;
	}
}

/* ==========================================================================
   DARK MODE support (if theme toggles a class or prefers-color-scheme)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	.bgw-hover-inner {
		background:
			linear-gradient(
				135deg,
				rgba(40, 40, 45, 0.85) 0%,
				rgba(30, 30, 35, 0.72) 50%,
				rgba(40, 40, 45, 0.80) 100%
			);
		border-color: rgba(255, 255, 255, 0.1);
		box-shadow:
			0 0 0 0.5px rgba(255, 255, 255, 0.05),
			0 8px 32px rgba(0, 0, 0, 0.35),
			0 2px 8px rgba(0, 0, 0, 0.2),
			inset 0 1px 0 rgba(255, 255, 255, 0.08);
	}

	.bgw-hover-ref {
		color: #f5f5f7;
	}

	.bgw-hover-body {
		color: #d1d1d6;
	}

	.bgw-hover-body .versenum {
		color: #a1a1a6;
	}

	.bgw-hover-close {
		background: rgba(255, 255, 255, 0.08);
		color: #a1a1a6;
	}
	.bgw-hover-close:hover {
		background: rgba(255, 255, 255, 0.14);
		color: #f5f5f7;
	}

	.bgw-hover-header,
	.bgw-hover-footer {
		border-color: rgba(255, 255, 255, 0.08);
	}

	.bgw-hover-attr {
		color: #a1a1a6;
	}
	.bgw-hover-attr strong {
		color: #c7c7cc;
	}

	.bgw-hover-full {
		color: #6eb5ff;
	}

	.bgw-hover-fallback-note {
		background: rgba(255, 255, 255, 0.06);
		color: #a1a1a6;
	}
	.bgw-hover-fallback-note strong {
		color: #d1d1d6;
	}
}
