/* =====================================================
   Wettbewerb Auswertung — Styles
   Alle Selektoren mit .wa- Prefix
   ===================================================== */

.wa-wrapper {
	--wa-bar-color:        #5c3d8a;          /* JF-Lila */
	--wa-bar-winner-color: #cc0068;          /* JF-Pink */
	--wa-bar-winner-glow:  rgba(204, 0, 104, 0.4);
	--wa-btn-bg:           #5c3d8a;
	--wa-btn-hover:        #4a2e73;
	--wa-border-color:     #e0e0e0;
	--wa-chart-height:     340px;
	--wa-transition:       2.5s cubic-bezier(0.22, 1, 0.36, 1);
	--wa-bar-radius:       6px 6px 0 0;

	font-family: inherit;
	max-width: 960px;
	margin: 0 auto;
	padding: 1.5rem;
	box-sizing: border-box;
}

/* ===== Passwort-Gate ===== */

.wa-gate {
	display: flex;
	justify-content: center;
	padding: 2rem 1rem;
}

.wa-gate-box {
	background: #f9f9f9;
	border: 1px solid var(--wa-border-color);
	border-radius: 8px;
	padding: 1.75rem 2rem;
	text-align: center;
	max-width: 360px;
	width: 100%;
}

.wa-gate-label {
	margin: 0 0 1rem;
	font-weight: 600;
	font-size: 1rem;
}

.wa-gate-row {
	display: flex;
	gap: 0.5rem;
}

.wa-pw-input {
	flex: 1 1 0;
	padding: 0.55rem 0.75rem;
	font-size: 1rem;
	border: 1px solid #ccc;
	border-radius: 4px;
}

.wa-pw-input:focus {
	outline: 2px solid var(--wa-btn-bg);
	outline-offset: 1px;
	border-color: var(--wa-btn-bg);
}

.wa-gate-error {
	margin: 0.75rem 0 0;
	color: #c0392b;
	font-size: 0.9rem;
}

/* ===== Controls ===== */

.wa-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	justify-content: center;
	margin-bottom: 2rem;
}

.wa-select {
	flex: 1 1 220px;
	padding: 0.55rem 0.75rem;
	font-size: 1rem;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
}

.wa-btn {
	flex: 0 0 auto;
	padding: 0.6rem 1.4rem;
	font-size: 1rem;
	font-weight: 600;
	background: var(--wa-btn-bg);
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.2s, opacity 0.2s;
	white-space: nowrap;
}

.wa-btn:hover:not(:disabled) {
	background: var(--wa-btn-hover);
}

.wa-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ===== Chart container ===== */

.wa-chart {
	display: flex;
	align-items: flex-end;
	gap: clamp(6px, 2vw, 28px);
	height: var(--wa-chart-height);
	padding-bottom: 3rem;   /* Platz für Beschriftung */
	position: relative;
	border-bottom: 2px solid var(--wa-border-color);
	overflow: visible;
}

/* Kein Platz und keine Linie wenn der Chart noch leer ist */
.wa-chart:empty {
	height: 0;
	min-height: 0;
	padding-bottom: 0;
	border-bottom: none;
}

/* ===== Balken-Spalte ===== */

.wa-bar-col {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	height: 100%;
	position: relative;
}

/* Inner wrapper: volle Höhe, Balken wächst von unten nach oben */
.wa-bar-inner {
	flex: 1;
	width: 100%;
	display: flex;
	align-items: flex-end;
}

/* ===== Der Balken ===== */

.wa-bar {
	width: 100%;
	height: 0%;                            /* JS setzt den Startwert */
	background: var(--wa-bar-color);
	border-radius: var(--wa-bar-radius);
	transition: height var(--wa-transition);
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 0.5rem;
	box-sizing: border-box;
	overflow: hidden;
}

.wa-bar--winner {
	background: var(--wa-bar-winner-color);
	box-shadow: 0 0 20px var(--wa-bar-winner-glow);
}

/* Stimmenzahl oben im Balken */
.wa-vote-count {
	font-size: clamp(0.7rem, 1.8vw, 0.9rem);
	font-weight: 700;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
	line-height: 1;
	transition: opacity 0.6s 2s;   /* blendet gegen Ende der Balken-Animation ein */
	opacity: 0;
}

/* Sichtbar sobald der Balken eine Mindesthöhe hat */
.wa-bar--visible .wa-vote-count {
	opacity: 1;
}

/* ===== Beschriftung unter dem Balken ===== */

.wa-bar-label {
	position: absolute;
	bottom: -2.8rem;
	left: 0;
	right: 0;
	text-align: center;
	font-size: clamp(0.6rem, 1.4vw, 0.8rem);
	line-height: 1.25;
	word-break: break-word;
	hyphens: auto;
	transition: opacity 0.5s ease, transform 0.5s ease;
	opacity: 1;
	transform: translateY(0);
}

.wa-bar-label strong {
	display: block;
}

.wa-bar-label--hidden {
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
}

.wa-bar-label--winner {
	font-weight: 700;
	color: #a00050;
}

/* ===== Nachrichten (Loading, Fehler, leer) ===== */

.wa-message {
	padding: 1.25rem 0;
	text-align: center;
	color: #555;
	font-style: italic;
}

.wa-message--error {
	color: #c0392b;
	font-style: normal;
	font-weight: 600;
}

/* ===== Vollbild-Modus ===== */

.wa-wrapper--fullscreen {
	--wa-chart-height:  auto;

	position: fixed;
	inset: 0;
	max-width: none;
	width: 100vw;
	height: 100dvh;
	margin: 0;
	padding: 1.25rem 2.5rem 1.25rem;
	background: #fff;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	color: #111;
}

/* Wettbewerbsname oben links */
.wa-competition-name {
	font-size: clamp(0.9rem, 1.8vw, 1.5rem);
	font-weight: 600;
	color: #555;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
	align-self: flex-start;
}

.wa-wrapper--fullscreen .wa-controls {
	display: none;
}

/* Chart: stretch damit Labels im Fluss unter den Balken bleiben */
.wa-wrapper--fullscreen .wa-chart {
	flex: 1;
	height: auto;
	align-items: stretch;
	padding-bottom: 0;
	border-bottom: none;
	gap: clamp(4px, 1.5vw, 22px);
}

/* Labels: im Fluss statt absolut positioniert, feste Höhe für gleiche Balkenbasis */
.wa-wrapper--fullscreen .wa-bar-label {
	position: static;
	bottom: auto;
	left: auto;
	right: auto;
	margin-top: 0.75rem;
	height: 10rem;
	overflow: hidden;
	color: #333;
	font-size: clamp(0.6rem, 1vw, 0.85rem);
}

.wa-wrapper--fullscreen .wa-bar-label--winner {
	color: var(--wa-bar-winner-color);
}

.wa-wrapper--fullscreen .wa-vote-count {
	font-size: clamp(0.75rem, 1.8vw, 1.1rem);
	/* Delay wird per-Balken in JS gesetzt */
}

.wa-wrapper--fullscreen .wa-bar--winner {
	box-shadow: 0 0 30px var(--wa-bar-winner-glow), 0 0 60px rgba(204, 0, 104, 0.15);
}

/* Schließen-Button */
.wa-close-btn {
	position: absolute;
	top: 1rem;
	right: 1rem;
	background: rgba(0, 0, 0, 0.07);
	border: 1px solid rgba(0, 0, 0, 0.15);
	color: #333;
	border-radius: 50%;
	width: 2.75rem;
	height: 2.75rem;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 1.1rem;
	line-height: 1;
	transition: background 0.2s;
	z-index: 10;
}

.wa-close-btn:hover {
	background: rgba(0, 0, 0, 0.15);
}

/* ===== Start-Overlay ===== */

.wa-start-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	z-index: 6;
}

.wa-start-btn {
	font-size: clamp(1.8rem, 3.5vw, 3rem);
	font-weight: 700;
	letter-spacing: 0.06em;
	padding: 1rem 4.5rem;
	background: var(--wa-bar-color);
	color: #fff;
	border: none;
	border-radius: 10px;
	cursor: pointer;
	transition: background 0.2s, transform 0.15s;
}

.wa-start-btn:hover {
	background: var(--wa-btn-hover);
	transform: scale(1.04);
}

.wa-start-btn:active {
	transform: scale(0.97);
}

/* ===== Countdown ===== */

.wa-countdown {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(10rem, 28vw, 22rem);
	font-weight: 900;
	color: var(--wa-bar-winner-color);
	text-shadow:
		0 0 40px var(--wa-bar-winner-glow),
		0 0 80px var(--wa-bar-winner-glow);
	background: #fff;
	z-index: 5;
	pointer-events: none;
	/* Keine Animation hier — nur via --tick Klasse, damit Neustart funktioniert */
}

/* Animation nur auf dieser Klasse, damit Entfernen + Hinzufügen sie neu startet */
.wa-countdown--tick {
	animation: wa-cd-tick 0.92s ease-in-out forwards;
}

@keyframes wa-cd-tick {
	0%   { transform: scale(2.4); opacity: 0;   filter: blur(12px); }
	22%  { transform: scale(1);   opacity: 1;   filter: blur(0);    }
	68%  { transform: scale(1);   opacity: 1;   filter: blur(0);    }
	100% { transform: scale(1.7); opacity: 0;   filter: blur(6px);  }
}

@keyframes wa-cd-in {
	from { transform: scale(1.6); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}

/* ===== Gewinner-Overlay ===== */

.wa-winner-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	background: rgba(255, 255, 255, 0.9);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	z-index: 9;
	cursor: pointer;
	outline: none;
	animation: wa-cd-in 0.5s ease-out forwards;
	text-align: center;
	padding: 2rem;
	box-sizing: border-box;
}

.wa-winner-title {
	font-size: clamp(2.5rem, 6vw, 5rem);
	font-weight: 900;
	color: #111;
	line-height: 1.15;
}

.wa-winner-teilnehmer {
	font-size: clamp(1.2rem, 2.5vw, 2rem);
	font-weight: 400;
	color: #444;
	line-height: 1.4;
}

.wa-winner-hint {
	margin-top: 2rem;
	font-size: clamp(0.8rem, 1.3vw, 1rem);
	color: #999;
	font-style: italic;
}

/* ===== Barrierefreiheit: Bewegung reduzieren ===== */

@media (prefers-reduced-motion: reduce) {
	.wa-bar {
		transition: none;
	}
	.wa-vote-count {
		transition: none;
		opacity: 1;
	}
	.wa-bar-label {
		transition: none;
	}
	.wa-countdown,
	.wa-winner-overlay {
		animation: none;
		filter: none;
	}
}

/* ===== Responsive ===== */

@media (max-width: 600px) {
	.wa-wrapper {
		--wa-chart-height: 240px;
		padding: 1rem 0.75rem;
	}

	.wa-controls {
		flex-direction: column;
	}

	.wa-select,
	.wa-btn {
		width: 100%;
	}

	.wa-bar-label {
		font-size: 0.6rem;
	}
}
