/* Sprechblase Widget Styles
 *
 * Full-section speech bubble widget with customizable positioning and mask images.
 *
 * Layout: the widget is a 2x2 CSS Grid (top/bottom rows, left/right columns).
 * Bubble and info-tooltip are placed into cells via grid-row/grid-column based
 * on their modifier classes. The bubble/tooltip horizontal collision is
 * avoided in PHP by flipping the tooltip column when it matches the bubble's.
 */

/* Widget Container - Full Section */
.sprechblase-widget {
	position: relative;
	width: 100%;
	height: 100vh;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	background-attachment: fixed;

	display: grid;
	/* minmax(0, 1fr) prevents an intrinsically-wide grid item (e.g. the active
	   tooltip with its nowrap content) from pushing its column wider than 50%
	   and shoving the bubble out of place. */
	grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
	grid-template-rows: 1fr 1fr;
	box-sizing: border-box;
	padding: 0 5%;
}

/* Background Overlay */
.sprechblase-widget::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: transparent;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

/* Speech Bubble Container - now a grid item instead of absolute */
.sprechblase-bubble {
	position: relative;
	background-color: transparent;
	background-image: linear-gradient(var(--site-color));
	background-repeat: no-repeat;
	z-index: 10;
	margin: 0;
}

/* Custom Color Override */
.sprechblase-bubble--custom-color {
	background-image: linear-gradient(var(--bubble-color));
	background-color: transparent;
}

/* Bubble Content */
.sprechblase-content {
	position: relative;
	padding: 48px;
	width: 100%;
}

/* When there is no bubble, the bare content block spans the whole grid. */
.sprechblase-widget > .sprechblase-content {
	grid-row: 1 / -1;
	grid-column: 1 / -1;
	align-self: center;
	justify-self: center;
	max-width: 90%;
}

/* ========================================
	BREADCRUMB
	======================================== */

/* Breadcrumb Container */
.sprechblase-breadcrumb {
	margin-bottom: 12px;
}

.sprechblase-breadcrumb__nav {
	line-height: 1.4;
	color: var(--site-contrast-color, var(--text));
	opacity: 0.8;
	font-size: var(--h6-font-size) !important;
}

.sprechblase-breadcrumb__nav a {
	color: var(--site-contrast-color, var(--text));
	text-decoration: none;
	transition: opacity 0.2s ease;
}

.sprechblase-breadcrumb__nav a:hover {
	opacity: 0.7;
	text-decoration: underline;
}

.breadcrumb_last{
	font-weight: 700 !important;
}

.sprechblase-breadcrumb__nav .breadcrumb_last {
	font-weight: 600;
}

/* Headline */
.sprechblase-headline {
	color: var(--site-contrast-color, var(--text));
	margin: 0 0 15px 0;
}

/* Text */
.sprechblase-text {
	color: var(--site-contrast-color, var(--text));
	margin: 0 0 25px 0;
}

.sprechblase-text p {
	color: var(--site-contrast-color, var(--text));
}

/* Buttons Container */
.sprechblase-buttons {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	flex-direction: column;
	gap: 16px;
	justify-content: flex-start;
}

/* ========================================
	INFO TOOLTIP - now a grid item instead of absolute
	======================================== */

/* Info Tooltip Container */
.sprechblase-info-tooltip {
	z-index: 20;
	border-radius: 10px;
	border: 1.5px solid rgba(255, 255, 255, 0.40);
	background-color: rgba(17, 17, 17, 0.80);
	display: flex;
	flex-direction: row;
	padding: 10px;
	column-gap: 10px;
	margin: 5%;
	/* Never exceed the column; allows content to wrap instead of pushing bubble. */
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/* When active, allow content to wrap within the column instead of overflowing. */
.sprechblase-info-tooltip.active .sprechblase-info-content {
	white-space: normal;
	min-width: 0;
}

/* Position via grid — PHP guarantees this never shares a column with the bubble. */
.sprechblase-info-tooltip--top-left {
	grid-row: 1;
	grid-column: 1;
	align-self: start;
	justify-self: start;
	margin-top: max(132px, 8%); /* safe area below any fixed site header */
}

.sprechblase-info-tooltip--top-right {
	grid-row: 1;
	grid-column: 2;
	align-self: start;
	justify-self: end;
	margin-top: max(132px, 8%);
	flex-direction: row-reverse;
}

.sprechblase-info-tooltip--bottom-left {
	grid-row: 2;
	grid-column: 1;
	align-self: end;
	justify-self: start;
	margin-bottom: max(132px, 8%);
}

.sprechblase-info-tooltip--bottom-right {
	grid-row: 2;
	grid-column: 2;
	align-self: end;
	justify-self: end;
	margin-bottom: max(132px, 8%);
	flex-direction: row-reverse;
}

/* Info Icon */
.sprechblase-info-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.2s ease;
}

.sprechblase-info-tooltip--bottom-left .sprechblase-info-icon,
.sprechblase-info-tooltip--bottom-right .sprechblase-info-icon {
	align-self: flex-end;
}

.sprechblase-info-icon svg {
	width: 20px;
	height: 20px;
	color: var(--white);
}

/* Info Content - Hidden by default */
.sprechblase-info-content {
	color: var(--white);
	white-space: nowrap;
	pointer-events: none;
	overflow: hidden;
	display: none;
	justify-content: center;
	align-items: flex-start;
	flex-direction: column;
}

.sprechblase-info-tooltip:hover,
.sprechblase-info-tooltip.active {
	background-color: rgba(17, 17, 17, 0.50);
}

/* Show content when active */
.sprechblase-info-tooltip.active .sprechblase-info-content {
	display: flex;
}

/* Single line handling */
.sprechblase-info-content:has(.sprechblase-info-author:only-child) .sprechblase-info-author,
.sprechblase-info-content:has(.sprechblase-info-gebiete:only-child) .sprechblase-info-gebiete {
	margin-bottom: 0;
}

/* ========================================
	BUBBLE SIZES
	======================================== */

.sprechblase-bubble--xl    { width: 422px; max-width: 100%;}
.sprechblase-bubble--l     { width: 405px; max-width: 100%;}
.sprechblase-bubble--m     { width: 405px; max-width: 100%;}
.sprechblase-bubble--s     { width: 405px; max-width: 100%;}
.sprechblase-bubble--title { width: 750px; max-width: 100%; }

/* ========================================
	HORIZONTAL POSITIONING — grid column + justify-self
	======================================== */

.sprechblase-widget--left .sprechblase-bubble {
	grid-column: 1;
	justify-self: start;
}

.sprechblase-widget--right .sprechblase-bubble {
	grid-column: 2;
	justify-self: end;
}

/* ========================================
	VERTICAL POSITIONING — grid row + align-self
	========================================
	Note: no more top:50% + translateY(-50%); the parallax JS relies on
	combining its own translateY with any existing CSS translate, so keeping
	this free of transform-based centering is what makes the parallax clean.
*/

/* Top Position */
.sprechblase-widget--top .sprechblase-bubble {
	grid-row: 1;
	align-self: start;
	transform-origin: top center;
	border-radius: 60px 60px 150px 150px;
}

/* Middle Position */
.sprechblase-widget--middle .sprechblase-bubble {
	grid-row: 1 / span 2;
	align-self: center;
	border-radius: 60px 60px 150px 150px;
}

/* Bottom Position */
.sprechblase-widget--bottom .sprechblase-bubble {
	grid-row: 2;
	align-self: end;
	transform-origin: bottom center;
	border-radius: 150px 150px 60px 60px;
	/* Preserve the slight visual overhang from the old design (translateY(60px)). */
	margin-bottom: -24px;
}

/* ========================================
	MASK IMAGES - Dynamic from PHP
	======================================== */

/* All bubble sizes use the CSS custom property */
.sprechblase-bubble--xl::before,
.sprechblase-bubble--l::before,
.sprechblase-bubble--m::before,
.sprechblase-bubble--s::before,
.sprechblase-bubble--title::before {
	mask-image: var(--mask-image-url);
	-webkit-mask-image: var(--mask-image-url);
	mask-repeat: no-repeat;
	-webkit-mask-repeat: no-repeat;
	mask-size: 100%;
	-webkit-mask-sie: 100%;
	position: absolute;
	left: 0;
	width: 100%;
	height: 100%;
	content: '';
	background-color: var(--site-color);
}
.sprechblase-bubble--m::before,
.sprechblase-bubble--s::before{
	mask-size: 100%;
	-webkit-mask-size: 100%;
}

/* Custom color for mask pseudo-elements */
.sprechblase-bubble--custom-color.sprechblase-bubble--xl::before,
.sprechblase-bubble--custom-color.sprechblase-bubble--l::before,
.sprechblase-bubble--custom-color.sprechblase-bubble--m::before,
.sprechblase-bubble--custom-color.sprechblase-bubble--s::before,
.sprechblase-bubble--custom-color.sprechblase-bubble--title::before {
	background-color: var(--bubble-color);
}

.sprechblase-widget--top .sprechblase-bubble::before {
	mask-position: bottom;
	-webkit-mask-position: bottom;
	bottom: -90px;
}
.sprechblase-widget--middle .sprechblase-bubble::before {
	mask-position: bottom;
	-webkit-mask-position: bottom;
	bottom: -90px;
}
.sprechblase-widget--bottom .sprechblase-bubble::before {
	mask-position: top;
	-webkit-mask-position: top;
	top: -90px;
}

/* ========================================
	RESPONSIVE — Mobile: 1-column grid, bubble and tooltip never share a row
	======================================== */
@media screen and (max-width: 767px) {

	.sprechblase-widget{
		height: 800px;
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 1fr;
		padding: 0;
	}

	/* Bubble spans full row width on mobile. */
	.sprechblase-widget--left .sprechblase-bubble,
	.sprechblase-widget--right .sprechblase-bubble,
	.sprechblase-bubble {
		grid-column: 1;
		justify-self: stretch;
		width: calc(100% - 32px);
		max-width: none;
		margin: 0 16px;
	}

	/* Top bubble -> row 1; middle/bottom bubble -> row 2. */
	.sprechblase-widget--top .sprechblase-bubble {
		grid-row: 1;
		align-self: start;
		border-radius: 60px 60px 40px 40px;
	}
	.sprechblase-widget--middle .sprechblase-bubble,
	.sprechblase-widget--bottom .sprechblase-bubble {
		grid-row: 2;
		align-self: end;
		border-radius: 0 0 30px 30px;
		margin-bottom: 0;
	}

	.sprechblase-widget--middle .sprechblase-bubble .sprechblase-content,
	.sprechblase-widget--bottom .sprechblase-bubble .sprechblase-content {
		padding: 0px 20px 40px 20px;
	}
	.sprechblase-widget--top .sprechblase-bubble .sprechblase-content {
		padding: 40px 20px 0px 20px;
	}

	/* Tooltip: always in the row NOT occupied by the bubble. */
	.sprechblase-widget--top .sprechblase-info-tooltip {
		grid-row: 2;
		align-self: end;
		margin-top: 0;
		margin-bottom: 100px;
	}
	.sprechblase-widget--middle .sprechblase-info-tooltip,
	.sprechblase-widget--bottom .sprechblase-info-tooltip {
		grid-row: 1;
		align-self: start;
		margin-top: 100px;
		margin-bottom: 0;
	}

	/* Keep tooltip horizontal alignment from its position modifier. */
	.sprechblase-info-tooltip--top-left,
	.sprechblase-info-tooltip--top-right,
	.sprechblase-info-tooltip--bottom-left,
	.sprechblase-info-tooltip--bottom-right {
		grid-column: 1;
	}
	.sprechblase-info-tooltip--top-left,
	.sprechblase-info-tooltip--bottom-left {
		justify-self: start;
	}
	.sprechblase-info-tooltip--top-right,
	.sprechblase-info-tooltip--bottom-right {
		justify-self: end;
	}

	.sprechblase-info-icon { width: 20px; height: 20px; }
	.sprechblase-info-icon svg { width: 20px; height: 20px; }

	/* Mobile mask tweaks (unchanged visual behaviour). */
	.sprechblase-widget--middle  .sprechblase-bubble::before,
	.sprechblase-widget--bottom .sprechblase-bubble::before {
		--mask-image-url: url('https://development2.jut-so.de/nnl/wp-content/plugins/jut-so-custom-elementor-widgets/widgets/sprechblase-widget/masks/mobile.svg') !important;
		mask-position: top !important;
		-webkit-mask-position: top !important;
		mask-repeat: no-repeat !important;
		-webkit-mask-repeat: no-repeat !important;
		mask-size: 100% 90px !important;
		-webkit-mask-size: 100% 90px !important;
		bottom: 0 !important;
		height: 90px;
		top: 0px;
		transform: translateY(calc(-100% + 1px));
		border-radius: 0;
	}

	.sprechblase-widget--top .sprechblase-bubble::before {
		--mask-image-url: url('https://development2.jut-so.de/nnl/wp-content/plugins/jut-so-custom-elementor-widgets/widgets/sprechblase-widget/masks/mobile-top.svg') !important;
		mask-position: bottom !important;
		-webkit-mask-position: bottom !important;
		mask-repeat: no-repeat !important;
		-webkit-mask-repeat: no-repeat !important;
		mask-size: 100% 144px !important;
		-webkit-mask-size: 100% 144px !important;
		bottom: auto !important;
		height: 144px;
		top: 100%;
		transform: translateY(-41px);
		border-radius: 0;
	}

	.sprechblase-widget--top .sprechblase-bubble {
		background-size: 100% calc(100% - 40px) !important;
	}

	/* Breadcrumb mobile adjustments */
	.sprechblase-breadcrumb {
		margin-bottom: 10px;
	}
}

@media screen and (max-width: 750px){
	.sprechblase-info-tooltip.active{
		width: 90%;
	}

	.sprechblase-info-content{
		white-space: normal !important;
	}
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
	.sprechblase-bubble {
		min-width: 320px;
	}

	.sprechblase-widget {
		grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr);
	}
}

@media screen and (min-width: 1025px) {
	.sprechblase-bubble {
		min-width: 320px;
	}
}

@media screen and (max-width: 450px){
	.sprechblase-bubble::before {
		border-radius: 0px 0px 0px 0px;
	}
}
