/* UAP Social Box – frontend and backend preview.
 *
 * Typography is deliberately NOT set: font family, size and weight of every
 * text inherit from the theme / Custom CSS of the page (only the editor's
 * own inline formatting overrides that). Colors that are not chosen in the
 * backend stay theme colors as well.
 */

.uap-sb-box {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	justify-content: var(--uap-sb-v-align, center);
	align-items: var(--uap-sb-h-align, center);
	width: var(--uap-sb-width, auto);
	max-width: 100%;
	height: var(--uap-sb-height, auto);
	padding: var(--uap-sb-padding, 16px);
	background-color: var(--uap-sb-bg, transparent);
	border: var(--uap-sb-border-width, 0) solid var(--uap-sb-border-color, transparent);
	border-radius: var(--uap-sb-radius, 0);
	overflow: auto;
}

/* "Hintergrund transparent" (0.5.0): no background at all, neither the chosen
 * color (it stays stored) nor a theme / page color. The id anchor lifts the rule
 * to (1,2,0) above any theme rule on the box. */
.uap-sb-box.uap-sb-bg-transparent:not(#uap-sb-specificity-anchor) {
	background: transparent !important;
	background-image: none !important;
}

.uap-sb-box *,
.uap-sb-box *::before,
.uap-sb-box *::after {
	box-sizing: border-box;
}

.uap-sb-inner {
	display: flex;
	flex-direction: column;
	align-items: var(--uap-sb-h-align, center);
	gap: var(--uap-sb-gap, 12px);
	max-width: 100%;
	min-width: 0;
}

/* Icon groups (0.3.0): up to two groups. Since 0.6.0 every group has its own
 * fixed column: a box with two or more groups lays them out side by side in a
 * grid with one equal column per group (--uap-sb-cols, set by the markup), so the
 * width of a column never depends on its content and nothing that happens in one
 * column (FX, typewriter, text length) moves the other one. Columns start at the
 * top (align-items:start); the height of a group is held while its FX run
 * (frontend.js), so a growing or shrinking text cannot move the other column
 * vertically either. The icon row inside a group stays horizontal or vertical as
 * chosen. group_gap is the distance between the columns. Narrow screens
 * (max-width 600px of the viewport): the columns stand below each other, same
 * rules. A box with one group keeps the former single stack; a group without
 * output is not printed at all. In the popup group 2 always stands below group 1. */
.uap-sb-box .uap-sb-icon-groups {
	display: flex;
	flex-direction: column;
	align-items: var(--uap-sb-h-align, center);
	gap: var(--uap-sb-group-gap, 12px);
	min-width: 0;
	max-width: 100%;
}

.uap-sb-box.uap-sb-groups-multi .uap-sb-inner {
	width: 100%;
}

.uap-sb-box.uap-sb-groups-multi .uap-sb-icon-groups {
	display: grid;
	grid-template-columns: repeat(var(--uap-sb-cols, 2), minmax(0, 1fr));
	align-items: start;
	width: 100%;
	gap: var(--uap-sb-group-gap, 12px);
}

@media (max-width: 600px) {
	.uap-sb-box.uap-sb-groups-multi .uap-sb-icon-groups {
		grid-template-columns: minmax(0, 1fr);
	}
}

.uap-sb-box .uap-sb-group {
	display: flex;
	flex-direction: column;
	align-items: var(--uap-sb-h-align, center);
	gap: var(--uap-sb-gap, 12px);
	min-width: 0;
	max-width: 100%;
}

/* Popup: group 2 below group 1, whatever the icon row direction. */
.uap-sb-box.uap-sb-context-popup .uap-sb-icon-groups {
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: var(--uap-sb-h-align, center);
}

/* Icon row of one group */
.uap-sb-box .uap-sb-icons {
	display: flex;
	gap: var(--uap-sb-gap, 12px);
	max-width: 100%;
	margin: 0;
	padding: 0;
}

.uap-sb-layout-horizontal .uap-sb-icons {
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: var(--uap-sb-h-align, center);
	align-items: center;
}

.uap-sb-layout-vertical .uap-sb-icons {
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: var(--uap-sb-h-align, center);
}

.uap-sb-box .uap-sb-item {
	display: flex;
	align-items: center;
	min-width: 0;
	margin: 0;
	padding: 0;
}

/* The link (or, without link, the div) holds the glyph and the optional text
 * next to it; the text is part of the link. */
.uap-sb-box .uap-sb-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--uap-sb-text-gap, 8px);
	min-width: 0;
	max-width: 100%;
	text-decoration: none;
	border: 0;
	box-shadow: none;
}

.uap-sb-text-right .uap-sb-icon { flex-direction: row; }
.uap-sb-text-left .uap-sb-icon { flex-direction: row-reverse; }
.uap-sb-text-below .uap-sb-icon { flex-direction: column; }
.uap-sb-text-above .uap-sb-icon { flex-direction: column-reverse; }

/* The color lives on the inner glyph, not on the <a>. Link rules of the
 * theme / Custom CSS (they target a elements, up to (0,9,1) with
 * !important on the target site) therefore only reach the icon when no own
 * color is chosen: without a choice the glyph inherits the theme link color. */
.uap-sb-box .uap-sb-glyph {
	display: block;
	flex: 0 0 auto;
	width: var(--uap-sb-icon-size, 32px);
	height: var(--uap-sb-icon-size, 32px);
	font-size: var(--uap-sb-icon-size, 32px);
	line-height: 0;
	color: inherit;
	transition: color 0.15s ease;
}

.uap-sb-box.uap-sb-has-icon-color .uap-sb-glyph {
	color: var(--uap-sb-icon-color);
}

.uap-sb-box.uap-sb-has-icon-hover-color a.uap-sb-icon:hover .uap-sb-glyph,
.uap-sb-box.uap-sb-has-icon-hover-color a.uap-sb-icon:focus-visible .uap-sb-glyph {
	color: var(--uap-sb-icon-hover-color);
}

.uap-sb-box .uap-sb-glyph svg {
	display: block;
	width: 100%;
	height: 100%;
}

.uap-sb-box .uap-sb-custom-icon {
	display: block;
	width: 100%;
	height: 100%;
	background-color: currentColor;
	-webkit-mask-image: var(--uap-sb-custom-mask);
	mask-image: var(--uap-sb-custom-mask);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
}

/* QR popup (0.6.0): the QR codes are their own fixed element (see the popup
 * rules below), images in their original colors, square in the chosen size, no
 * link. They wrap inside the free screen area. */
.uap-sb-qr-popup {
	box-sizing: border-box;
	flex: 0 0 auto;
	max-width: 100%;
	max-height: 100%;
	pointer-events: auto;
}

.uap-sb-qr-popup .uap-sb-qr {
	display: flex;
	flex-wrap: wrap;
	gap: var(--uap-sb-gap, 12px);
	margin: 0;
	padding: 0;
}

.uap-sb-qr-popup .uap-sb-qr-item {
	margin: 0;
	padding: 0;
	max-width: 100%;
}

.uap-sb-qr-popup .uap-sb-qr .uap-sb-qr-img {
	display: block;
	width: var(--uap-sb-qr-size, 120px);
	max-width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

/* Button (0.4.0): theme button style. Only classes (button wp-element-button)
 * and no own design; the rule protects the layout of the box. */
.uap-sb-box .uap-sb-button {
	max-width: 100%;
	box-sizing: border-box;
	overflow-wrap: anywhere;
}

/* Rich text (box text) and the plain texts next to the icons */
.uap-sb-rich {
	min-width: 0;
	max-width: 100%;
	overflow-wrap: anywhere;
}

.uap-sb-intro {
	width: 100%;
}

.uap-sb-text-content p {
	margin: 0 0 1em;
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
}

.uap-sb-text-content > :last-child,
.uap-sb-text-content p:last-child {
	margin-bottom: 0;
}

.uap-sb-text-content p.uap-sb-empty-line-height {
	margin: 0 !important;
}

/* The line-gap span keeps height/margin inline; display is class-owned
 * because wp_kses_post() removes display declarations from saved text. */
.uap-sb-text-content .uap-sb-line-gap {
	display: block !important;
}

.uap-sb-rich.uap-sb-text-vertical-center {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-self: stretch;
}

/* Link presentation chosen in the editor. The id anchor
 * :not(#uap-sb-specificity-anchor) lifts these rules to (1,3,1)/(1,4,1),
 * above the strongest link rule of the target site's Custom CSS
 * (a:not(...)x9 = (0,9,1), !important). Without a choice nothing is set and
 * the theme / Custom CSS link styling applies. */
.uap-sb-box:not(#uap-sb-specificity-anchor) .uap-sb-links-custom-color a:not([x-apple-data-detectors]) {
	color: var(--uap-sb-link-color) !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor) .uap-sb-links-custom-hover a:not([x-apple-data-detectors]):hover,
.uap-sb-box:not(#uap-sb-specificity-anchor) .uap-sb-links-custom-hover a:not([x-apple-data-detectors]):focus {
	color: var(--uap-sb-link-hover-color) !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor) .uap-sb-links-underlined a:not([x-apple-data-detectors]) {
	text-decoration: underline !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor) .uap-sb-links-not-underlined a:not([x-apple-data-detectors]) {
	text-decoration: none !important;
}

/* Texts next to the icons: the shared settings of the box act through
 * classes / variables on the box. The chosen color sits on the text itself,
 * never on the glyph (it keeps its own color); without a choice the text
 * inherits the link color of the theme / Custom CSS. The id anchor lifts the
 * rules above the link rules of the target site's Custom CSS ((0,9,1),
 * !important): color (1,4,0), hover (1,5,1), underline (1,3,0). */
.uap-sb-box:not(#uap-sb-specificity-anchor).uap-sb-itext-custom-color .uap-sb-icon .uap-sb-icon-text {
	color: var(--uap-sb-itext-color) !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor).uap-sb-itext-custom-hover a.uap-sb-icon:hover .uap-sb-icon-text,
.uap-sb-box:not(#uap-sb-specificity-anchor).uap-sb-itext-custom-hover a.uap-sb-icon:focus-visible .uap-sb-icon-text {
	color: var(--uap-sb-itext-hover-color) !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor).uap-sb-itext-underlined .uap-sb-icon {
	text-decoration: underline !important;
}

.uap-sb-box:not(#uap-sb-specificity-anchor).uap-sb-itext-not-underlined .uap-sb-icon {
	text-decoration: none !important;
}

/* Text-FX (UAP Bio runtime) */
.uap-sb-text-fx-panel,
.uap-sb-text-fx-target {
	position: relative;
	width: 100%;
	min-width: 0;
	max-width: 100%;
}

.uap-sb-text-has-fx .uap-sb-text-fx-target.tooloon-fx1-door-target {
	will-change: transform;
}

.uap-sb-text-has-fx .uap-sb-text-fx-target.tooloon-fx5-flight-target {
	will-change: transform, opacity;
}

.uap-sb-box .uap-sb-fx-content-pending,
.uap-sb-box .uap-sb-fx-content-pending * {
	visibility: hidden !important;
	pointer-events: none !important;
}

.uap-sb-box [data-uap-sb-fx-typewriter="1"].uap-sb-text-fx-running .uap-sb-text-fx-target,
.uap-sb-box [data-uap-sb-fx-typewriter="1"].uap-sb-text-fx-running .uap-sb-text-fx-target * {
	caret-color: transparent !important;
}

.uap-sb-box [data-uap-sb-fx-typewriter="1"].uap-sb-text-fx-running .uap-sb-text-fx-target::after {
	content: none !important;
	border: 0 !important;
	animation: none !important;
}

.uap-sb-box [data-uap-sb-fx-typewriter="1"] [class*="cursor"],
.uap-sb-box [data-uap-sb-fx-typewriter="1"] [class*="caret"],
.uap-sb-box [data-uap-sb-fx-typewriter="1"] [class*="Cursor"],
.uap-sb-box [data-uap-sb-fx-typewriter="1"] [class*="Caret"] {
	display: none !important;
}

/* Popup: the icon groups (icon popup) and the QR codes (QR popup, 0.6.0), fixed at
 * the chosen screen position, always visible, not closable. Popups on the same
 * position share one container and are stacked in .uap-sb-popup-stack (icon popup
 * first, QR popup below, 12 px apart). A popup steps aside at once (see the end of
 * this block). The fixed container spans the viewport minus the
 * edge distance and places the row with flex alignment; it never takes
 * pointer events itself, so it cannot block the page, and it cannot widen
 * the page (fixed elements add no scrollable overflow on mobile). The layout
 * properties are defended with the id anchor (1,1,0) against theme rules;
 * the target site's Custom CSS only styles a / button elements. */
.uap-sb-popup:not(#uap-sb-specificity-anchor) {
	position: fixed !important;
	top: var(--uap-sb-popup-offset, 24px) !important;
	right: var(--uap-sb-popup-offset, 24px) !important;
	bottom: var(--uap-sb-popup-offset, 24px) !important;
	left: var(--uap-sb-popup-offset, 24px) !important;
	z-index: 99999 !important;
	display: flex !important;
	margin: 0 !important;
	padding: 0 !important;
	width: auto !important;
	height: auto !important;
	max-width: none !important;
	transform: none !important;
	pointer-events: none !important;
	overflow: visible !important;
}

.uap-sb-popup-stack {
	display: flex;
	flex-direction: column;
	flex: 0 0 auto;
	gap: 12px;
	max-width: 100%;
	max-height: 100%;
	pointer-events: none;
}

.uap-sb-popup-pos-top-left .uap-sb-popup-stack,
.uap-sb-popup-pos-middle-left .uap-sb-popup-stack,
.uap-sb-popup-pos-bottom-left .uap-sb-popup-stack { align-items: flex-start; }
.uap-sb-popup-pos-top-center .uap-sb-popup-stack,
.uap-sb-popup-pos-center .uap-sb-popup-stack,
.uap-sb-popup-pos-bottom-center .uap-sb-popup-stack { align-items: center; }
.uap-sb-popup-pos-top-right .uap-sb-popup-stack,
.uap-sb-popup-pos-middle-right .uap-sb-popup-stack,
.uap-sb-popup-pos-bottom-right .uap-sb-popup-stack { align-items: flex-end; }

.uap-sb-popup-stack > .uap-sb-box {
	flex: 0 0 auto;
	width: auto;
	max-width: 100%;
	max-height: 100%;
	height: auto;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	overflow: visible;
	pointer-events: auto;
}

.uap-sb-popup-pos-top-left { justify-content: flex-start; align-items: flex-start; }
.uap-sb-popup-pos-top-center { justify-content: center; align-items: flex-start; }
.uap-sb-popup-pos-top-right { justify-content: flex-end; align-items: flex-start; }
.uap-sb-popup-pos-middle-left { justify-content: flex-start; align-items: center; }
.uap-sb-popup-pos-center { justify-content: center; align-items: center; }
.uap-sb-popup-pos-middle-right { justify-content: flex-end; align-items: center; }
.uap-sb-popup-pos-bottom-left { justify-content: flex-start; align-items: flex-end; }
.uap-sb-popup-pos-bottom-center { justify-content: center; align-items: flex-end; }
.uap-sb-popup-pos-bottom-right { justify-content: flex-end; align-items: flex-end; }

/* The popup steps aside at once (no fade, no transition; 0.6.7) while a PRESS KIT
 * popup or the full screen view (lightbox) of UAP Gallery is open and is back at
 * once when it is closed. Hidden it is invisible (opacity 0, visibility:hidden),
 * cannot be clicked and leaves the tab order. The state is read from the markers
 * those plug-ins really set: PRESS KIT (frontend.js, syncBodyOverlayState()) toggles the
 * class uap-pk-open on <body> while an overlay is not hidden; UAP Gallery
 * (frontend.js, openLightbox()/closeLightbox()) toggles tfg-lightbox-open on <html>.
 * Specificity: the base rule (1,1,0) carries the visible state;
 * the hidden rules (1,2,1) beat it, and the Custom CSS only styles a / button.
 * All of it !important like the other popup layout rules. */
.uap-sb-popup:not(#uap-sb-specificity-anchor) {
	opacity: 1 !important;
	visibility: visible !important;
}

body.uap-pk-open .uap-sb-popup:not(#uap-sb-specificity-anchor),
html.tfg-lightbox-open .uap-sb-popup:not(#uap-sb-specificity-anchor) {
	opacity: 0 !important;
	visibility: hidden !important;
}


/* 0.6.7: While a box inserted by the shortcode is in view (frontend.js sets
 * uap-sb-sc-visible on <html>), the icons of the popup are hidden one by one:
 * lowest first on the way out (delay --uap-sb-sc-out, 60 ms per icon, set by
 * frontend.js), highest first on the way back (--uap-sb-sc-in). Fixed fade: 200 ms.
 * Only the icon items of the icon popup (.uap-sb-item); the QR popup is not touched.
 * The staggering exists only while frontend.js keeps uap-sb-sc-animate on <html>
 * (set at the change, removed when it is over) and never while PRESS KIT popup,
 * gallery full screen or footer panel is open: those hide the whole popup at once
 * (rule on .uap-sb-popup above), and here the items then switch without any
 * transition, also after a shortcode box was in view before. The :not() conditions
 * are the same markers as above. Specificity: hidden state (1,3,1), staggered rules
 * (1,6,2) / (1,7,2); all !important; the Custom CSS only styles a / button. */
html.uap-sb-sc-visible .uap-sb-popup:not(#uap-sb-specificity-anchor) .uap-sb-item {
	opacity: 0 !important;
	visibility: hidden !important;
}

html.uap-sb-sc-animate:not(.tfg-lightbox-open) body:not(.uap-pk-open):not(.uap-ft-menu-panel-open) .uap-sb-popup:not(#uap-sb-specificity-anchor) .uap-sb-item {
	transition: opacity 200ms ease var(--uap-sb-sc-in, 0ms), visibility 0s linear var(--uap-sb-sc-in, 0ms) !important;
}

html.uap-sb-sc-animate.uap-sb-sc-visible:not(.tfg-lightbox-open) body:not(.uap-pk-open):not(.uap-ft-menu-panel-open) .uap-sb-popup:not(#uap-sb-specificity-anchor) .uap-sb-item {
	transition: opacity 200ms ease var(--uap-sb-sc-out, 0ms), visibility 0s linear calc(var(--uap-sb-sc-out, 0ms) + 200ms) !important;
}

/* 0.6.1: Locking the page scroll (body overflow:hidden of the PRESS KIT popup)
 * removes a classic scrollbar, the viewport gets wider and a popup anchored to
 * the right (or centered) would jump sideways while it steps aside (measured:
 * 15 px). frontend.js keeps the scrollbar width of the unlocked page in
 * --uap-sb-sbw; while a popup steps aside the right edge keeps it, so the icons
 * stay where they were. (1,2,1) beats the base rule (1,1,0), all !important. */
body.uap-pk-open .uap-sb-popup:not(#uap-sb-specificity-anchor),
html.tfg-lightbox-open .uap-sb-popup:not(#uap-sb-specificity-anchor) {
	right: calc(var(--uap-sb-popup-offset, 24px) + var(--uap-sb-sbw, 0px)) !important;
}

/* 0.6.1: A popup at a bottom position never goes over the footer of the page
 * (UAP Footer, else the theme footer): frontend.js sets --uap-sb-lift to the
 * height of the footer part that is in view, so the bottom edge of the popup
 * stack keeps the edge distance (--uap-sb-popup-offset) to the footer, like to
 * the window edge. Top and middle positions do not use it. (1,2,0) beats the
 * base rule (1,1,0) and the scrollbar rule above only differs in `right`. */
.uap-sb-popup.uap-sb-popup-pos-bottom-left:not(#uap-sb-specificity-anchor),
.uap-sb-popup.uap-sb-popup-pos-bottom-center:not(#uap-sb-specificity-anchor),
.uap-sb-popup.uap-sb-popup-pos-bottom-right:not(#uap-sb-specificity-anchor) {
	bottom: calc(var(--uap-sb-popup-offset, 24px) + var(--uap-sb-lift, 0px)) !important;
}

body.uap-pk-open .uap-sb-popup:not(#uap-sb-specificity-anchor) .uap-sb-popup-stack > *,
html.tfg-lightbox-open .uap-sb-popup:not(#uap-sb-specificity-anchor) .uap-sb-popup-stack > * {
	pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.uap-sb-box .uap-sb-glyph {
		transition: none;
	}
}
