/*
 * Bowling Scoring Online - frontend styles.
 * Default lane box is 960 x 540 px (16:9).
 */

/* Mörkt läge är standard – riktig bakgrund så att vit text aldrig hamnar på vit sida. */
.bso-container,
.bso-theme-dark {
	--bso-text: #e8ecf3;
	--bso-muted: #9aa3b2;
	--bso-bg: transparent;
	--bso-btn-bg: #23262d;
	--bso-btn-text: #e8ecf3;
	--bso-btn-active-bg: #1687d2;
	--bso-btn-active-text: #ffffff;
	--bso-border: #3a3f49;
	--bso-lane-bg: #000;
	--bso-panel: rgba(255, 255, 255, 0.05);
	--bso-panel-bg: #1b1e24;
	--bso-label-bg: rgba(0, 0, 0, 0.7);
	--bso-label-text: #fff;
	color-scheme: dark;
}

.bso-container {
	max-width: 100%;
	margin: 0 auto;
	padding: 1rem;
	color: var(--bso-text);
	background: transparent;
}

.bso-theme-light {
	--bso-text: #14161a;
	--bso-muted: #5b6270;
	--bso-bg: transparent;
	--bso-btn-bg: #fff;
	--bso-btn-text: #14161a;
	--bso-btn-active-bg: #14161a;
	--bso-btn-active-text: #fff;
	--bso-border: #c8ccd4;
	--bso-lane-bg: #fff;
	--bso-panel: rgba(0, 0, 0, 0.04);
	--bso-panel-bg: #ffffff;
	--bso-label-bg: rgba(255, 255, 255, 0.9);
	--bso-label-text: #14161a;
	color-scheme: light;
}

.bso-hall-title {
	color: var(--bso-text);
	text-align: center;
	margin-bottom: 1rem;
	font-size: 1.75rem;
}

.bso-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: center;
	justify-content: center;
	margin-bottom: 1rem;
}

.bso-selector,
.bso-theme-switch {
	color: var(--bso-text);
}

.bso-selector span {
	margin-right: 0.5rem;
	font-weight: 600;
}

.bso-selector button,
.bso-theme-switch button {
	margin: 0 0.25rem;
	padding: 0.4rem 0.9rem;
	background: var(--bso-btn-bg);
	color: var(--bso-btn-text);
	border: 1px solid var(--bso-border);
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.bso-selector button:hover,
.bso-selector button.active,
.bso-theme-switch button:hover,
.bso-theme-switch button.active {
	background: var(--bso-btn-active-bg);
	color: var(--bso-btn-active-text);
	border-color: var(--bso-btn-active-bg);
}


/* Lane picker */
.bso-lane-picker {
	max-width: 900px;
	margin: 0 auto 1rem;
	padding: 0.75rem 1rem;
	background: var(--bso-panel);
	border: 1px solid var(--bso-border);
	border-radius: 8px;
	color: var(--bso-text);
}

.bso-lane-picker-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.6rem;
	font-weight: 600;
}

.bso-lane-picker-head button {
	padding: 0.2rem 0.7rem;
	font-size: 0.85rem;
	background: var(--bso-btn-bg);
	color: var(--bso-btn-text);
	border: 1px solid var(--bso-border);
	border-radius: 4px;
	cursor: pointer;
}

.bso-lane-picker-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.bso-lane-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.6rem;
	border: 1px solid var(--bso-border);
	border-radius: 999px;
	cursor: pointer;
	font-size: 0.9rem;
	user-select: none;
}

.bso-lane-chip input {
	margin: 0;
}

.bso-container * {
	box-sizing: border-box;
}

/* Antal banor per rad styrs av --bso-cols (sätts av JS, funkar även på mobil). */
.bso-container .bso-lanes {
	display: grid !important;
	gap: 1rem;
	width: 100%;
	justify-content: center;
	grid-template-columns: repeat(var(--bso-cols, 3), minmax(0, 1fr)) !important;
}

.bso-container .bso-lane {
	width: 100% !important;
	min-width: 0;
	max-width: 100%;
	aspect-ratio: var(--bso-lane-ratio, 16 / 9);
	background: var(--bso-lane-bg);
	border: 2px solid var(--bso-border);
	border-radius: 8px;
	overflow: hidden;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bso-lane.bso-hidden {
	display: none;
}

.bso-empty {
	text-align: center;
	color: var(--bso-text);
	opacity: 0.8;
}

.bso-container .bso-lane img {
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	object-fit: contain;
	display: block;
	margin: 0;
}

/* Två lager som korsfadar = ingen blink när bilden uppdateras. */
.bso-container .bso-lane .bso-img {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity 0.25s linear;
	backface-visibility: hidden;
}

.bso-container .bso-lane .bso-img.bso-active {
	opacity: 1;
}


/* Mobil: mindre marginaler, valt antal kolumner behålls */
@media (max-width: 768px) {
	.bso-container { padding: 0.5rem; }
	.bso-container .bso-lanes { gap: 0.4rem; }
	.bso-container .bso-lane { border-width: 1px; border-radius: 4px; }
	.bso-selector button,
	.bso-theme-switch button { padding: 0.5rem 0.9rem; font-size: 1rem; }
	.bso-hall-title { font-size: 1.25rem; margin-bottom: 0.5rem; }
}

/* ---------- Inställningsmeny (dropdown) ---------- */
.bso-settings {
	position: relative;
	display: flex;
	justify-content: center;
	margin: 0 0 14px;
	z-index: 20;
}

.bso-container .bso-settings .bso-settings-toggle,
.bso-container .bso-settings button.bso-settings-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0.55rem 1.1rem;
	width: auto !important;
	min-width: 0 !important;
	min-height: 42px !important;
	margin: 0 !important;
	border: 1px solid #0868ad !important;
	border-radius: 999px;
	background: #1687d2 !important;
	background-image: linear-gradient(180deg, #2f9fe0 0%, #1275c4 100%) !important;
	color: #fff !important;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.1;
	font-family: inherit !important;
	text-decoration: none !important;
	text-transform: none !important;
	letter-spacing: 0 !important;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
	transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
	-webkit-appearance: none;
	appearance: none;
}

.bso-container .bso-settings .bso-settings-toggle:hover {
	filter: brightness(1.08);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.26);
}

.bso-container .bso-settings .bso-settings-toggle:active {
	transform: translateY(1px);
}

.bso-container .bso-settings .bso-settings-toggle:focus-visible {
	outline: 2px solid #7cc4f0;
	outline-offset: 2px;
}

.bso-container .bso-settings.bso-open .bso-settings-toggle {
	background: #14161a !important;
	background-image: linear-gradient(180deg, #2b2d31 0%, #08090a 100%) !important;
	border-color: #08090a !important;
}

.bso-container .bso-settings .bso-settings-toggle svg {
	display: block !important;
	width: 20px !important;
	height: 20px !important;
	fill: currentColor !important;
	transition: transform 0.25s ease;
	flex: none;
}

.bso-container .bso-settings.bso-open .bso-settings-toggle svg {
	transform: rotate(90deg);
}

.bso-settings-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	min-width: min(340px, 92vw);
	max-width: 92vw;
	padding: 14px;
	border: 1px solid var(--bso-border);
	border-radius: 12px;
	color: var(--bso-text);
	background: var(--bso-panel-bg);
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
	z-index: 30;
}

.bso-theme-dark .bso-settings-panel {
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

/* Temats stilar får inte skriva över texten i mörkt läge */
.bso-container .bso-hall-title,
.bso-container .bso-settings-panel span,
.bso-container .bso-lane-chip,
.bso-container .bso-empty {
	color: var(--bso-text) !important;
}

.bso-container .bso-lane-chip input {
	accent-color: var(--bso-btn-active-bg);
}

.bso-container .bso-lane-chip:has(input:checked) {
	background: var(--bso-panel);
	border-color: var(--bso-btn-active-bg);
}

.bso-settings-panel[hidden] {
	display: none;
}

.bso-settings-panel .bso-toolbar {
	margin: 0 0 10px;
}

.bso-settings-panel .bso-lane-picker {
	margin: 0;
}

/* Mobil: knapparna för banor per rad hamnar under texten */
@media (max-width: 768px) {
	.bso-settings-panel .bso-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 0.75rem;
	}

	.bso-selector,
	.bso-theme-switch {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 0.5rem;
	}

	.bso-selector span {
		margin-right: 0;
	}

	.bso-selector > button,
	.bso-theme-switch > button {
		margin: 0;
	}

	.bso-selector {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		gap: 0.5rem;
	}

	.bso-selector span {
		grid-column: 1 / -1;
		text-align: center;
	}
}

/* Inget spel – ingen ny bild på 12 min */
.bso-container .bso-lane .bso-noplay {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.78);
	color: #fff;
	font-size: clamp(1rem, 3vw, 2rem);
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.bso-container .bso-lane .bso-noplay[hidden] {
	display: none;
}

/* Full skärm */
.bso-container.bso-is-fullscreen {
	overflow: auto;
	padding: 16px;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
}
.bso-container.bso-is-fullscreen.bso-theme-dark { background: #0f1115; color: #f1f1f1; }
.bso-container.bso-is-fullscreen.bso-theme-light { background: #ffffff; color: #1d2327; }
.bso-container:fullscreen { overflow: auto; }
.bso-container:-webkit-full-screen { overflow: auto; }
