/**
 * Pollux Labs Quick Poll – popup / modal styles.
 *
 * Wraps the poll card in an overlay dialog. Depends on frontend.css for the
 * poll itself. On small screens the dialog becomes a bottom sheet.
 */

.plqp-popup[hidden] {
	display: none;
}

.plqp-popup {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.25rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.plqp-popup__overlay {
	position: fixed;
	inset: 0;
	background: rgba(10, 14, 28, 0.6);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: plqp-overlay-in 0.25s ease-out;
}

.plqp-popup__dialog {
	position: relative;
	width: 100%;
	max-width: 520px;
	margin: auto;
	animation: plqp-popup-in 0.3s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.plqp-popup__dialog .plqp-poll {
	margin: 0;
	max-width: none;
}

.plqp-popup__dialog .plqp-card {
	border-top: 4px solid var(--plqp-accent, #2563eb);
	box-shadow: 0 24px 60px rgba(10, 14, 28, 0.28), 0 4px 14px rgba(10, 14, 28, 0.14);
	max-height: calc(100vh - 4.5rem);
	max-height: calc(100dvh - 4.5rem);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.plqp-popup__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 1;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	line-height: 1;
	color: var(--plqp-muted, #5b6472);
	background: var(--plqp-option-bg, #f7f9fc);
	border: 1px solid var(--plqp-border, #e2e6ee);
	border-radius: 50%;
	cursor: pointer;
	transition: transform 0.1s ease, background-color 0.15s ease, color 0.15s ease;
}

.plqp-popup__close:hover {
	color: var(--plqp-fg, #1f2330);
	background: var(--plqp-option-hover, #eef2f9);
}

.plqp-popup__close:active {
	transform: scale(0.94);
}

.plqp-popup__close:focus-visible {
	outline: 2px solid var(--plqp-accent, #2563eb);
	outline-offset: 2px;
}

/* Leave room for the close button. The intro title clears it when present;
   otherwise the question legend (the first line) needs the inset instead. */
.plqp-popup__dialog .plqp-intro__title,
.plqp-popup__dialog .plqp-q__legend {
	padding-right: 2.5rem;
}

.plqp-popup__dialog .plqp-intro:has(.plqp-intro__title) ~ .plqp-q .plqp-q__legend {
	padding-right: 0;
}

/* Lock background scroll while the popup is open. */
body.plqp-popup-open {
	overflow: hidden;
}

@media (prefers-color-scheme: dark) {
	.plqp-popup__overlay {
		background: rgba(0, 0, 0, 0.65);
	}

	.plqp-popup__close {
		color: #a6adbb;
		background: #232838;
		border-color: #2c3242;
	}

	.plqp-popup__close:hover {
		color: #e7eaf1;
		background: #2a3144;
	}
}

@keyframes plqp-overlay-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes plqp-popup-in {
	from {
		opacity: 0;
		transform: translateY(18px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.plqp-popup__overlay,
	.plqp-popup__dialog {
		animation: none;
	}
}

/* Bottom sheet on small screens. */
@media (max-width: 560px) {
	.plqp-popup {
		padding: 0;
		align-items: flex-end;
	}

	.plqp-popup__dialog {
		max-width: none;
		margin: auto 0 0;
		animation-name: plqp-popup-up;
	}

	.plqp-popup__dialog .plqp-card {
		border-radius: var(--plqp-radius, 16px) var(--plqp-radius, 16px) 0 0;
		border-left: none;
		border-right: none;
		border-bottom: none;
		max-height: calc(100vh - 2.5rem);
		max-height: calc(100dvh - 2.5rem);
	}

	.plqp-popup__close {
		top: 10px;
		right: 10px;
	}
}

@keyframes plqp-popup-up {
	from {
		opacity: 0;
		transform: translateY(40px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
