/**
 * Tabs & Map Module Styles (65%/35% layout)
 *
 * @package WP_R2Go4_Detail
 */

/* Eigener Stacking-Context fuer das gesamte Modul.
 *
 * Die z-index-Werte weiter unten (Tabs 100/600, Verlauf 50/500, Scroll-Hinweis
 * 1000) sortieren ausschliesslich die Elemente INNERHALB des Moduls. Ohne einen
 * eigenen Stacking-Context landen sie im globalen Kontext der Seite und legen
 * sich dort ueber die Sticky-Navi des Themes - deren eigener z-index (1200)
 * hilft nicht, weil er in ihrem per transform animierten Wrapper gefangen ist
 * und nach aussen nur dessen (niedrigerer) z-index zaehlt.
 *
 * isolation: isolate erzeugt den Kontext, OHNE dem Modul selbst einen z-index
 * zu geben. Das Modul bleibt damit in der auto-Ebene - also genau da, wo die
 * Karte heute schon liegt, und die verhaelt sich korrekt.
 *
 * Bewusst nur hier und NICHT im Gallery-Modul: dessen Lightbox (z-index 99999)
 * muss die ganze Seite ueberdecken und darf deshalb ausbrechen. */
.wp-r2go4-tabs-map-module {
	width: 100%;
	isolation: isolate;
}

/* Grid Layout 65% / 35% */
.wp-r2go4-tabs-map-grid {
	display: grid;
	grid-template-columns: 65% 35%;
	gap: 0;
	align-items: stretch;
}

/* Tabs Section */
.wp-r2go4-tabs-map-tabs {
	min-width: 0;
	position: relative;
	z-index: 100;
}

/* Map Section - Full bleed to screen edge */
.wp-r2go4-tabs-map-map {
	position: relative;
	margin-right: calc(-50vw + 50%);
	margin-top: calc(var(--wp-r2go4-padding-top, 80px) * -1);
	margin-bottom: calc(var(--wp-r2go4-padding-bottom, 80px) * -1);
	min-height: calc(100% + var(--wp-r2go4-padding-top, 80px) + var(--wp-r2go4-padding-bottom, 80px));
}

.wp-r2go4-tabs-map-map-wrapper,
.wp-r2go4-tabs-map-map .wp-r2go4-details-map {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
}

/* Override inline !important leaflet styles - needs higher specificity + !important */
.wp-r2go4-tabs-map-module .wp-r2go4-tabs-map-map .wp-r2go4-map-container.leaflet-container.leaflet-touch,
.wp-r2go4-tabs-map-module .wp-r2go4-tabs-map-map .wp-r2go4-map-container.leaflet-container,
.wp-r2go4-tabs-map-module .wp-r2go4-tabs-map-map .leaflet-container {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

/* Move zoom controls to top-right */
.wp-r2go4-tabs-map-module .leaflet-control-zoom {
	position: absolute !important;
	top: 20px !important;
	right: 20px !important;
	left: auto !important;
	margin: 0 !important;
}

/* Remove shadows from Leaflet controls */
.wp-r2go4-tabs-map-module .leaflet-control-zoom,
.wp-r2go4-tabs-map-module .leaflet-control-zoom a {
	box-shadow: none !important;
}

/* Grayscale map tiles - similar to custom Google Maps style */
.wp-r2go4-tabs-map-module .grayscale-tiles {
	filter: grayscale(100%) sepia(15%) brightness(1.02) contrast(1.05);
}

/* Gradient overlay from left - wider */
.wp-r2go4-tabs-map-map-gradient {
	position: absolute;
	top: 0;
	left: 0;
	width: 600px;
	height: 100%;
	background: linear-gradient(to right, #f2f0ee, rgba(242, 240, 238, 0));
	z-index: 50;
	pointer-events: none;
}

.wp-r2go4-tabs-map-no-location {
	color: #666;
	font-style: italic;
	padding: 40px;
}

/* Scroll hint overlay */
.wp-r2go4-map-scroll-hint {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: rgba(0, 0, 0, 0.7);
	color: #fff;
	padding: 12px 24px;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	z-index: 1000;
	pointer-events: none;
	white-space: nowrap;
}

/* Responsive */
@media (max-width: 1024px) {
	.wp-r2go4-tabs-map-grid {
		grid-template-columns: 1fr;
		gap: 0;
	}

	/* Tabs section above gradient */
	.wp-r2go4-tabs-map-tabs {
		position: relative;
		z-index: 600;
	}

	.wp-r2go4-tabs-map-map {
		margin-right: calc(-50vw + 50%);
		margin-left: calc(-50vw + 50%);
		margin-top: 80px;
		margin-bottom: 0;
		/* Desktop nutzt min-height: calc(100% + Padding), damit die Karte die
		   Tab-Spalte fuellt und ueber den Satzspiegel ragt. Im einspaltigen
		   Layout gibt es keine Nachbarspalte zu fuellen - die Regel wuerde die
		   Karte hier nur ueberhoehen und in den folgenden Block (Galerie)
		   ragen lassen. Darum zuruecksetzen: die Hoehe kommt vom Wrapper. */
		min-height: 0;
	}

	.wp-r2go4-tabs-map-map-wrapper {
		position: relative;
		min-height: 460px;
	}

	/* Gradient from top instead of left */
	.wp-r2go4-tabs-map-map-gradient {
		position: absolute;
		display: block;
		top: 0;
		left: 0;
		right: 0;
		bottom: auto;
		width: 100%;
		height: 200px;
		background: linear-gradient(to bottom, #f2f0ee, rgba(242, 240, 238, 0));
		z-index: 500;
		pointer-events: none;
	}
}

@media (max-width: 768px) {
	/* Tabs section above gradient and map */
	.wp-r2go4-tabs-map-tabs {
		position: relative;
		z-index: 600;
	}

	/* Die Karte soll buendig mit dem Modul enden - kein beiger Streifen darunter.
	   Der negative Margin zieht die Karte ueber das untere Modul-Padding, sodass
	   die beige Modul-Flaeche unter der Karte verschwindet. Den Abstand zum
	   naechsten Block liefert dann dessen eigenes (weisses) oberes Padding.
	   Sicher moeglich, seit die Karte eine feste Hoehe hat (min-height des
	   Wrappers) und nicht mehr ueberhoeht in den Folgeblock ragt. */
	.wp-r2go4-tabs-map-map {
		margin-bottom: calc(var(--wp-r2go4-padding-bottom, 50px) * -1);
	}

	/* Auf dem Handy niedriger: 400px war bei ~390px Viewport-Breite fast
	   quadratisch und wirkte ueberlang. 280px zeigt genug Umgebung, ohne den
	   Rest der Seite wegzudruecken. */
	.wp-r2go4-tabs-map-map-wrapper {
		min-height: 280px;
	}

	/* Gradient smaller on mobile to not overlap content */
	.wp-r2go4-tabs-map-map-gradient {
		height: 80px;
	}
}

/* ============================================
 * Tabs Styles (integrated from tabs module)
 * ============================================ */

/* Tab Navigation */
.wp-r2go4-tabs-nav {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: 8px;
	border-bottom: 1px solid var(--global-palette7, #EDF2F7);
}

.wp-r2go4-tabs-nav-item {
	margin: 0;
	padding: 0;
}

.wp-r2go4-tabs-nav-button {
	background: #ffffff;
	border: 1px solid var(--global-palette7, #EDF2F7);
	border-bottom: none;
	cursor: pointer;
	padding: 12px 24px;
	display: block;
	width: 100%;
	text-align: center;
	transition: all 0.2s ease;
	position: relative;
	bottom: -1px;
	text-transform: none;
	color: var(--wp-r2go4-ci-color-2);
	font-size: inherit;
	font-weight: normal;
}

.wp-r2go4-tabs-nav-button:hover {
	background: var(--global-palette8, #F7FAFC);
	border-color: #e1e1e1;
	border-bottom: none;
	color: var(--wp-r2go4-ci-color-2);
	box-shadow: none;
}

.wp-r2go4-tabs-nav-active .wp-r2go4-tabs-nav-button {
	background: #ffffff;
	border-color: var(--global-palette7, #EDF2F7);
	border-bottom: 1px solid #ffffff;
	color: var(--wp-r2go4-ci-color-1);
	box-shadow: none;
}

/* Tab Content */
.wp-r2go4-tabs-content {
	width: 100%;
}

.wp-r2go4-tabs-panel {
	width: 100%;
	border-right: 1px solid var(--global-palette7, #EDF2F7);
	border-bottom: 1px solid var(--global-palette7, #EDF2F7);
	border-left: 1px solid var(--global-palette7, #EDF2F7);
	background: #ffffff;
}

.wp-r2go4-tabs-panel[hidden] {
	display: none;
}

.wp-r2go4-tabs-panel-content {
	padding: 26px;
}

.wp-r2go4-tabs-panel-content > *:first-child {
	margin-top: 0 !important;
}

.wp-r2go4-tabs-panel-content > *:last-child {
	margin-bottom: 0;
}

.wp-r2go4-tabs-panel-content p {
	margin-bottom: 1em;
}

.wp-r2go4-tabs-panel-content p:first-child {
	margin-top: 0 !important;
}

.wp-r2go4-tabs-panel-content p:last-child {
	margin-bottom: 0;
}

/* Expandable Content - hoehenbasierte Kuerzung.
 *
 * Die feste Einklapp-Hoehe MUSS mit COLLAPSED_HEIGHT in tabs-map.js
 * uebereinstimmen (220px). Sie gilt nur im Desktop-Layout: auf dem Handy ist
 * jeder Tab ein Akkordeon und zeigt beim Aufklappen ohnehin den vollen Text. */
@media (min-width: 769px) {
	/* Alle Tabs gleich hoch eingeklappt -> der Frame ist ueber alle Tabs
	   konstant und waechst erst beim Klick auf "Mehr lesen". */
	.wp-r2go4-expandable-collapsed {
		height: 220px;
		overflow: hidden;
	}

	/* Weicher Auslauf nur, wenn wirklich Inhalt abgeschnitten ist
	   (also nicht bei kurzen Tabs, die nur Freiraum bis 220px haben). */
	.wp-r2go4-expandable-collapsed.wp-r2go4-expandable-has-more {
		position: relative;
	}

	.wp-r2go4-expandable-collapsed.wp-r2go4-expandable-has-more::after {
		content: '';
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 48px;
		background: linear-gradient(rgba(255, 255, 255, 0), #ffffff);
		pointer-events: none;
	}
}

/* "Mehr lesen" / "Weniger lesen".
   Der Button sitzt als Geschwister NEBEN dem Text-Content. Dieser hat
   padding: 26px (siehe .wp-r2go4-tabs-panel-content), der Button erbt das
   nicht. Deshalb hier dieselben 26px links (fluchtet im Satzspiegel) und
   26px unten, damit der Abstand zum Frame-Rand dem oberen Text-Padding
   entspricht. Oben nur 8px, weil der Fade schon optisch Abstand schafft. */
.wp-r2go4-expand-button {
	background: transparent !important;
	border: none !important;
	color: var(--wp-r2go4-ci-color-1) !important;
	cursor: pointer;
	padding: 8px 26px 26px !important;
	margin-top: 8px;
	display: inline-block;
	text-decoration: none !important;
	box-shadow: none !important;
	outline: none !important;
}

.wp-r2go4-expand-button:hover {
	color: var(--wp-r2go4-ci-color-2) !important;
	background: transparent !important;
	box-shadow: none !important;
	outline: none !important;
	border: none !important;
}

/* Platzhalter-Button bei kurzen Tabs: unsichtbar, aber er reserviert die
   Button-Hoehe. So ist der eingeklappte Frame ueber ALLE Tabs gleich hoch und
   springt beim Tab-Wechsel nicht. visibility (nicht display:none) behaelt den
   Layout-Platz und macht den Button zugleich unklickbar. */
.wp-r2go4-expand-button-placeholder {
	visibility: hidden;
}

/* Auf dem Handy (Akkordeon) wird nicht gekuerzt - der Button ist dort unnoetig
   und darf auch keinen Platzhalter-Raum reservieren. */
@media (max-width: 768px) {
	.wp-r2go4-expand-button {
		display: none;
	}
}

/* Accordion Headers (hidden on desktop) */
.wp-r2go4-accordion-header {
	display: none;
}

/* Mobile Optimizations for Tabs */
@media (max-width: 768px) {
	/* Hide tab navigation on mobile */
	.wp-r2go4-tabs-nav {
		display: none;
	}

	/* Show accordion headers on mobile */
	.wp-r2go4-accordion-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #ffffff;
		border: 1px solid var(--global-palette7, #EDF2F7);
		border-bottom: none;
		padding: 16px 20px;
		cursor: pointer;
		color: var(--wp-r2go4-ci-color-2);
		font-weight: 500;
		transition: color 0.2s ease;
	}

	.wp-r2go4-accordion-header:hover {
		background: #ffffff;
	}

	.wp-r2go4-accordion-header-active {
		color: var(--wp-r2go4-ci-color-1);
		background: #ffffff;
	}

	.wp-r2go4-accordion-icon {
		display: inline-block;
		width: 20px;
		height: 20px;
		position: relative;
		transition: transform 0.2s ease;
	}

	.wp-r2go4-accordion-icon::before {
		content: '';
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%) rotate(45deg);
		width: 8px;
		height: 8px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transition: transform 0.2s ease;
	}

	.wp-r2go4-accordion-header-active .wp-r2go4-accordion-icon::before {
		transform: translate(-50%, -50%) rotate(-135deg);
	}

	/* Accordion panels */
	.wp-r2go4-tabs-panel {
		border-top: none;
	}

	.wp-r2go4-tabs-panel:first-child .wp-r2go4-accordion-header {
		border-top: 1px solid var(--global-palette7, #EDF2F7);
	}

	/* Reduced padding for mobile */
	.wp-r2go4-tabs-panel-content {
		padding: 20px;
	}

	/* Hide all panels by default on mobile */
	.wp-r2go4-tabs-panel[hidden] {
		display: block;
	}

	/* All panels start collapsed on mobile */
	.wp-r2go4-tabs-panel {
		border-bottom: none;
	}

	.wp-r2go4-tabs-panel:last-child {
		border-bottom: 1px solid var(--global-palette7, #EDF2F7);
	}

	.wp-r2go4-tabs-panel-content {
		display: none;
	}

	.wp-r2go4-tabs-panel-active .wp-r2go4-tabs-panel-content {
		display: block;
	}

	/* Remove active state from first panel on mobile */
	.wp-r2go4-tabs-panel-active .wp-r2go4-accordion-header {
		color: var(--wp-r2go4-ci-color-2);
	}

	.wp-r2go4-accordion-header-active {
		color: var(--wp-r2go4-ci-color-1) !important;
	}
}
