/*
 * Whiteboard – Stylesheet
 * Wird per <link> ausschließlich innerhalb eines Shadow-DOM-Trees geladen.
 * Dadurch ist dieses CSS strikt gekapselt: es kann von außen weder
 * beeinflusst werden noch nach außen "auslaufen".
 * Schriftart wird bewusst NICHT gesetzt (außer 'inherit'), damit die
 * Typografie des jeweiligen WordPress-Themes übernommen wird.
 */

:host {
	all: initial;
	display: block;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	/* Bewusst OHNE "paint"/"size", damit ein per JS gesetzter
	   Fallback-Vollbildmodus (position: fixed) nicht durch dieses
	   Element als Containing Block eingefangen wird. */
	contain: layout style;
	isolation: isolate;
	position: relative;
	font-family: inherit;
	color: #1f2328;
	--wb-accent: #2563eb;
	--wb-accent-contrast: #ffffff;
	--wb-border: #e2e4e9;
	--wb-border-strong: #c9cdd6;
	--wb-bg: #ffffff;
	--wb-bg-soft: #f7f8fa;
	--wb-text: #1f2328;
	--wb-text-muted: #6b7280;
	--wb-radius: 12px;
	--wb-radius-sm: 8px;
	--wb-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.06);
	--wb-transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
	:host {
		--wb-border: #33363f;
		--wb-border-strong: #42454f;
		--wb-bg: #1c1e24;
		--wb-bg-soft: #24262e;
		--wb-text: #eceef1;
		--wb-text-muted: #9aa0ab;
		color: #eceef1;
	}
}

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

.wb-app {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 320px;
	background: var(--wb-bg);
	border: 1px solid var(--wb-border);
	border-radius: var(--wb-radius);
	box-shadow: var(--wb-shadow);
	overflow: hidden;
	font-size: 14px;
	line-height: 1.4;
}

/* ---------- Toolbar ---------- */

.wb-toolbar {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 8px 10px;
	background: var(--wb-bg-soft);
	border-bottom: 1px solid var(--wb-border);
	scrollbar-width: thin;
}

.wb-toolbar::-webkit-scrollbar {
	height: 6px;
}
.wb-toolbar::-webkit-scrollbar-thumb {
	background: var(--wb-border-strong);
	border-radius: 4px;
}

.wb-group {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 0 8px;
	flex: 0 0 auto;
}

.wb-group + .wb-group {
	border-left: 1px solid var(--wb-border);
}

.wb-btn {
	all: unset;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: var(--wb-radius-sm);
	cursor: pointer;
	color: var(--wb-text);
	transition: background var(--wb-transition), color var(--wb-transition), transform var(--wb-transition);
	box-sizing: border-box;
}

.wb-btn svg {
	width: 18px;
	height: 18px;
	pointer-events: none;
}

.wb-btn:hover {
	background: rgba(37, 99, 235, 0.08);
}

.wb-btn:active {
	transform: scale(0.94);
}

.wb-btn:focus-visible {
	outline: 2px solid var(--wb-accent);
	outline-offset: 1px;
}

.wb-btn[aria-pressed="true"] {
	background: var(--wb-accent);
	color: var(--wb-accent-contrast);
}

.wb-btn[disabled] {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: none;
}

/* Farbwahl */

.wb-swatch {
	all: unset;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	box-shadow: 0 0 0 1px var(--wb-border) inset;
	transition: transform var(--wb-transition), box-shadow var(--wb-transition);
	flex: 0 0 auto;
}

.wb-swatch:hover {
	transform: scale(1.12);
}

.wb-swatch[aria-pressed="true"] {
	box-shadow: 0 0 0 2px var(--wb-bg), 0 0 0 4px currentColor;
}

.wb-color-custom {
	width: 24px;
	height: 24px;
	padding: 0;
	border: 1px solid var(--wb-border);
	border-radius: 50%;
	cursor: pointer;
	background: none;
	overflow: hidden;
}
.wb-color-custom::-webkit-color-swatch-wrapper { padding: 0; }
.wb-color-custom::-webkit-color-swatch { border: none; border-radius: 50%; }
.wb-color-custom::-moz-color-swatch { border: none; border-radius: 50%; }

/* Strichstärke */

.wb-range-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wb-range {
	width: 84px;
	accent-color: var(--wb-accent);
	cursor: pointer;
}

.wb-size-dot {
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}
.wb-size-dot span {
	display: block;
	border-radius: 50%;
	background: currentColor;
}

/* Zoom-Anzeige */

.wb-zoom-label {
	all: unset;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 34px;
	min-width: 46px;
	padding: 0 6px;
	border-radius: var(--wb-radius-sm);
	cursor: pointer;
	color: var(--wb-text-muted);
	font: inherit;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	transition: background var(--wb-transition), color var(--wb-transition);
}
.wb-zoom-label:hover { background: rgba(37, 99, 235, 0.08); color: var(--wb-text); }
.wb-zoom-label:focus-visible { outline: 2px solid var(--wb-accent); outline-offset: 1px; }

/* Select (Hintergrund) */

.wb-select {
	all: unset;
	display: inline-flex;
	align-items: center;
	height: 34px;
	padding: 0 10px;
	border-radius: var(--wb-radius-sm);
	color: var(--wb-text);
	cursor: pointer;
	font: inherit;
	font-size: 13px;
	background: transparent;
	transition: background var(--wb-transition);
}
.wb-select:hover { background: rgba(37, 99, 235, 0.08); }
.wb-select:focus-visible { outline: 2px solid var(--wb-accent); outline-offset: 1px; }

/* ---------- Canvas-Bühne ---------- */

.wb-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	background: var(--wb-bg);
	touch-action: none;
	cursor: crosshair;
}

.wb-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.wb-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wb-text-muted);
	font-size: 14px;
	pointer-events: none;
	opacity: 0.8;
	transition: opacity var(--wb-transition);
	text-align: center;
	padding: 0 20px;
}

.wb-placeholder.is-hidden {
	opacity: 0;
}

/* Text-Eingabe-Overlay */

.wb-text-input {
	position: absolute;
	z-index: 5;
	min-width: 60px;
	min-height: 1.2em;
	background: rgba(255, 255, 255, 0.85);
	border: 1px dashed var(--wb-accent);
	border-radius: 4px;
	padding: 2px 4px;
	font-family: inherit;
	line-height: 1.2;
	outline: none;
	white-space: pre;
	cursor: text;
}

@media (prefers-color-scheme: dark) {
	.wb-text-input { background: rgba(28, 30, 36, 0.85); }
}

.wb-text-input:empty::before {
	content: attr(data-placeholder);
	color: var(--wb-text-muted);
	pointer-events: none;
}

/* Toast / Statusmeldung */

.wb-toast {
	position: absolute;
	bottom: 14px;
	left: 50%;
	transform: translateX(-50%) translateY(8px);
	background: rgba(20, 22, 27, 0.92);
	color: #fff;
	padding: 8px 14px;
	border-radius: var(--wb-radius-sm);
	font-size: 13px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--wb-transition), transform var(--wb-transition);
	z-index: 10;
}

.wb-toast.is-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* ---------- Vollbild ---------- */

/*
 * Wird umgeschaltet, sobald document.fullscreenElement dem Host-Element
 * entspricht (native Fullscreen API). Da :host außerhalb der eigentlichen
 * Fullscreen-Elementkette liegt, steuern wir die Optik über eine Klasse
 * auf dem inneren .wb-app statt über :fullscreen.
 */
.wb-app.is-fullscreen {
	border-radius: 0;
	border: none;
	height: 100%;
	width: 100%;
}

/*
 * CSS-Fallback für Browser/Umgebungen, in denen die native Fullscreen API
 * blockiert ist (z. B. durch eine restriktive Permissions-Policy in
 * verschachtelten Page-Builder-Vorschau-Frames). Die Klasse wird auf dem
 * Host-Element (Light DOM) gesetzt; :host(...) erlaubt es, dieses Element
 * trotzdem ausschließlich aus unserem gekapselten Stylesheet heraus zu
 * steuern – es wird kein globales CSS erzeugt.
 */
:host(.wb-fallback-fullscreen) {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	z-index: 2147483647 !important;
	margin: 0 !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	.wb-toolbar {
		padding: 6px 8px;
		gap: 4px;
	}
	.wb-group { padding: 0 5px; }
	.wb-btn { width: 32px; height: 32px; }
	.wb-range { width: 56px; }
}

@media (prefers-reduced-motion: reduce) {
	.wb-btn, .wb-swatch, .wb-toast, .wb-placeholder {
		transition: none;
	}
}
