/*!
 * wir-branden AI Label – frontend styles.
 * Design settings arrive as CSS custom properties (inline :root{--wbai-*}); the defaults below are fallbacks.
 * Shared with the admin live preview: .wbai-label, .wbai-label--ai|edited, .wbai-pos-*, .wbai-style-*, .wbai-mode-hover,
 * .wbai-label__icon, .wbai-label__text, .wbai-wrap, .wbai-has-label.
 */

/* ---------- hosts / wrappers ---------- */
.wbai-host,
.wbai-wrap {
	position: relative;
}

/* font-size/line-height 0: the wrapper's baseline is its bottom edge, exactly like a replaced <img>,
   so a copied vertical-align gives the identical line box. The label sets its own font-size in px. */
.wbai-wrap {
	display: inline-block;
	max-width: 100%;
	vertical-align: bottom;
	font-size: 0;
	line-height: 0;
}

.wbai-wrap--block {
	display: block;
}

.wbai-wrap > img,
.wbai-wrap > picture,
.wbai-wrap > video {
	vertical-align: bottom;
}

.wbai-wrap--block > img,
.wbai-wrap--block > video,
.wbai-wrap--block > picture {
	display: block;
}

/* Core image block: wide / full images keep their full width. */
.wp-block-image.alignfull .wbai-wrap,
.wp-block-image.alignwide .wbai-wrap {
	display: block;
	width: 100%;
}

/* ---------- label ---------- */
.wbai-label {
	--wbai-offset: var(--wbai-margin, 10px);
	position: absolute;
	z-index: 5;
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	box-sizing: border-box;
	max-width: calc(100% - 2 * var(--wbai-offset));
	margin: 0;
	padding: var(--wbai-py, 4px) var(--wbai-px, 8px);
	border: 0;
	border-radius: var(--wbai-radius, 999px);
	background: var(--wbai-bg, rgba(0, 0, 0, 0.7));
	color: var(--wbai-color, #fff);
	font-family: var(--wbai-font, inherit);
	font-size: var(--wbai-font-size, 12px);
	font-style: normal;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: 0.01em;
	text-align: start;
	text-decoration: none;
	text-shadow: none;
	text-transform: none;
	white-space: nowrap;
	unicode-bidi: isolate;
	pointer-events: auto;
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

a.wbai-label:hover,
a.wbai-label:focus {
	color: var(--wbai-color, #fff);
	text-decoration: underline;
}

.wbai-label:focus-visible {
	outline: 2px solid var(--wbai-color, #fff);
	outline-offset: 2px;
}

.wbai-label__icon {
	flex: 0 0 auto;
	width: 1.15em;
	height: 1.15em;
	fill: currentColor;
}

.wbai-label__text {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---------- positions (physical, also in RTL) ---------- */
.wbai-pos-top-left { top: var(--wbai-offset); left: var(--wbai-offset); }
.wbai-pos-top-right { top: var(--wbai-offset); right: var(--wbai-offset); }
.wbai-pos-bottom-left { bottom: var(--wbai-offset); left: var(--wbai-offset); }
.wbai-pos-bottom-right { bottom: var(--wbai-offset); right: var(--wbai-offset); }

/* Keep bottom labels above native / MediaElement video controls. */
.wbai-has-controls > .wbai-pos-bottom-left,
.wbai-has-controls > .wbai-pos-bottom-right {
	bottom: calc(var(--wbai-offset) + 44px);
}

/* ---------- styles ---------- */
.wbai-style-pill { border-radius: 999px; }

.wbai-style-icon {
	padding: var(--wbai-py, 4px);
	border-radius: 999px;
}

.wbai-style-icon .wbai-label__icon {
	width: 1.35em;
	height: 1.35em;
}

.wbai-style-icon .wbai-label__text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.wbai-style-bar {
	right: 0;
	left: 0;
	max-width: none;
	border-radius: 0;
	white-space: normal;
}

.wbai-style-bar.wbai-pos-top-left,
.wbai-style-bar.wbai-pos-top-right { top: 0; }
.wbai-style-bar.wbai-pos-bottom-left,
.wbai-style-bar.wbai-pos-bottom-right { bottom: 0; }
.wbai-style-bar.wbai-pos-top-right,
.wbai-style-bar.wbai-pos-bottom-right { justify-content: flex-end; }

.wbai-has-controls > .wbai-style-bar.wbai-pos-bottom-left,
.wbai-has-controls > .wbai-style-bar.wbai-pos-bottom-right { bottom: 44px; }

/* ---------- hover mode (always visible on touch devices, keyboard focus and in print) ---------- */
.wbai-mode-hover {
	opacity: 0;
	visibility: hidden;
}

.wbai-host:hover > .wbai-mode-hover,
.wbai-wrap:hover > .wbai-mode-hover,
.wbai-has-label:hover > .wbai-mode-hover,
.wbai-host:focus-within > .wbai-mode-hover,
.wbai-wrap:focus-within > .wbai-mode-hover,
.wbai-has-label:focus-within > .wbai-mode-hover,
.wbai-mode-hover:focus {
	opacity: 1;
	visibility: visible;
}

@media (hover: none) {
	.wbai-mode-hover {
		opacity: 1;
		visibility: visible;
	}
}

/* Rendered smaller than the configured minimum width (set by JS). */
.wbai-too-small > .wbai-label {
	display: none;
}

/* ---------- tooltip ---------- */
.wbai-label[data-wbai-tip]::after {
	content: attr(data-wbai-tip);
	position: absolute;
	z-index: 6;
	left: 0;
	top: calc(100% + 6px);
	box-sizing: border-box;
	width: max-content;
	max-width: min(280px, 80vw);
	padding: 0.55em 0.75em;
	border-radius: 6px;
	background: #111;
	color: #fff;
	font-size: max(11px, 0.95em);
	font-weight: 400;
	line-height: 1.4;
	white-space: normal;
	text-align: start;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.wbai-pos-top-right[data-wbai-tip]::after,
.wbai-pos-bottom-right[data-wbai-tip]::after {
	right: 0;
	left: auto;
}

.wbai-pos-bottom-left[data-wbai-tip]::after,
.wbai-pos-bottom-right[data-wbai-tip]::after {
	top: auto;
	bottom: calc(100% + 6px);
}

.wbai-label[data-wbai-tip]:hover::after,
.wbai-label[data-wbai-tip]:focus-visible::after {
	opacity: 1;
	visibility: visible;
}

/* ---------- inline badge ([wbai_label inline="1"]) ---------- */
.wbai-label--inline {
	position: static;
	max-width: 100%;
	vertical-align: middle;
}

/* ---------- post notice ---------- */
.wbai-notice {
	display: flex;
	align-items: flex-start;
	gap: 0.6em;
	box-sizing: border-box;
	margin: 0 0 1.5em;
	padding: 0.8em 1em;
	border-inline-start: 4px solid currentColor;
	border-radius: 4px;
	background: rgba(127, 127, 127, 0.1);
	font-size: 0.9em;
	line-height: 1.5;
}

.wbai-notice--after {
	margin: 1.5em 0 0;
}

.wbai-notice__icon {
	flex: 0 0 auto;
	width: 1.3em;
	height: 1.3em;
	margin-top: 0.1em;
}

.wbai-notice__icon svg {
	display: block;
	width: 100%;
	height: 100%;
	fill: currentColor;
}

.wbai-notice__text {
	margin: 0;
}

/* ---------- accessibility / media ---------- */
@media (prefers-reduced-motion: reduce) {
	.wbai-label,
	.wbai-label::after {
		transition: none;
	}
}

@media (forced-colors: active) {
	.wbai-label {
		border: 1px solid CanvasText;
		background: Canvas;
		color: CanvasText;
		forced-color-adjust: none;
	}
}

@media print {
	.wbai-mode-hover {
		opacity: 1;
		visibility: visible;
	}

	.wbai-label {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}

	.wbai-label::after {
		display: none;
	}
}
