/*
 * 9MinGames archive filter presentation.
 * Desktop uses an inline grid. Mobile uses a VisualViewport-aware sheet so
 * the iOS keyboard cannot resize or clip the page layout behind the form.
 */

body.nmg-game-archive .nmg-mobile-filter-disclosure {
	display: block;
	width: 100%;
	min-width: 0;
	max-width: 100%;
}

body.nmg-game-archive .nmg-mobile-filter-toggle {
	display: none;
}

body.nmg-game-archive .nmg-game-filters {
	display: grid;
	grid-template-columns: repeat(4, minmax(150px, 1fr));
	align-items: end;
	gap: 14px;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	margin: 0 0 20px;
	padding: 16px;
	box-sizing: border-box;
	border: 1px solid var(--nmg-border, #26384d);
	border-radius: 14px;
	background: var(--nmg-surface, #0d1929);
}

body.nmg-game-archive .nmg-game-filter {
	display: grid;
	gap: 7px;
	min-width: 0;
}

body.nmg-game-archive .nmg-game-filter label {
	margin: 0;
	color: color-mix(in srgb, var(--nmg-muted, #8e9aad) 90%, white 10%);
	font-size: .72rem;
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: .08em;
	text-transform: uppercase;
}

body.nmg-game-archive .nmg-game-filter input,
body.nmg-game-archive .nmg-game-filter select {
	width: 100%;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0 12px;
	box-sizing: border-box;
	border: 1px solid color-mix(in srgb, var(--nmg-border, #26384d) 82%, white 8%);
	border-radius: 10px;
	background: color-mix(in srgb, var(--nmg-surface, #0d1929) 88%, #07111f);
	color: var(--nmg-text, #f4f7fb);
	font: inherit;
	font-size: .9rem;
	line-height: 1;
	outline: none;
}

body.nmg-game-archive .nmg-game-filter input:focus,
body.nmg-game-archive .nmg-game-filter select:focus {
	border-color: var(--nmg-accent, #6d5dfc);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--nmg-accent, #6d5dfc) 24%, transparent);
}

body.nmg-game-archive .nmg-game-filter-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	grid-column: 1 / -1;
	min-width: 0;
}

body.nmg-game-archive .nmg-game-filter-actions .nmg-button {
	min-height: 42px;
}

@media (max-width: 1100px) and (min-width: 769px) {
	body.nmg-game-archive .nmg-game-filters {
		grid-template-columns: repeat(3, minmax(150px, 1fr));
	}
}

@media (max-width: 768px) {
	html.nmg-filter-sheet-open,
	body.nmg-filter-sheet-open {
		overflow: hidden;
		overscroll-behavior: none;
	}

	body.nmg-game-archive .nmg-mobile-filter-disclosure {
		margin: 0 0 16px;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle {
		display: grid;
		grid-template-columns: 42px minmax(0, 1fr) auto auto;
		align-items: center;
		gap: 11px;
		min-height: 64px;
		padding: 10px 12px;
		box-sizing: border-box;
		border: 1px solid var(--nmg-border, #26384d);
		border-radius: 15px;
		background: var(--nmg-surface, #0d1929);
		color: var(--nmg-text, #f4f7fb);
		cursor: pointer;
		list-style: none;
		-webkit-tap-highlight-color: transparent;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle::-webkit-details-marker { display: none; }
	body.nmg-game-archive .nmg-mobile-filter-toggle::marker { content: ""; }

	body.nmg-game-archive .nmg-mobile-filter-toggle__icon {
		display: grid;
		place-items: center;
		width: 42px;
		height: 42px;
		border-radius: 12px;
		background: color-mix(in srgb, var(--nmg-accent, #6d5dfc) 20%, transparent);
		color: color-mix(in srgb, var(--nmg-accent, #6d5dfc) 76%, white 14%);
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__icon svg,
	body.nmg-game-archive .nmg-mobile-filter-toggle__chevron svg {
		display: block;
		width: 21px;
		height: 21px;
		fill: none;
		stroke: currentColor;
		stroke-width: 1.9;
		stroke-linecap: round;
		stroke-linejoin: round;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__copy {
		display: grid;
		gap: 2px;
		min-width: 0;
		text-align: left;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__copy strong {
		font-size: 1rem;
		font-weight: 800;
		line-height: 1.2;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__copy small {
		color: var(--nmg-muted, #8e9aad);
		font-size: .78rem;
		line-height: 1.25;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__count {
		display: inline-grid;
		place-items: center;
		min-width: 27px;
		height: 27px;
		padding: 0 7px;
		border-radius: 999px;
		background: var(--nmg-accent, #6d5dfc);
		color: #fff;
		font-size: .76rem;
		font-weight: 800;
		line-height: 1;
	}

	body.nmg-game-archive .nmg-mobile-filter-toggle__chevron {
		display: grid;
		place-items: center;
		width: 30px;
		height: 30px;
		color: var(--nmg-muted, #8e9aad);
		transition: transform 180ms ease;
	}

	body.nmg-game-archive .nmg-mobile-filter-disclosure[open] .nmg-mobile-filter-toggle__chevron {
		transform: rotate(180deg);
	}

	body.nmg-game-archive .nmg-mobile-filter-disclosure:not([open]) > .nmg-game-filters {
		display: none;
	}

	/* The open filter becomes a real viewport-owned sheet. */
	body.nmg-game-archive .nmg-mobile-filter-disclosure[open] {
		position: fixed;
		left: var(--nmg-filter-viewport-left, 0px);
		top: var(--nmg-filter-viewport-top, 0px);
		z-index: 100200;
		display: grid;
		grid-template-rows: auto minmax(0, 1fr);
		width: var(--nmg-filter-viewport-width, 100vw);
		height: var(--nmg-filter-viewport-height, 100dvh);
		margin: 0;
		padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
		box-sizing: border-box;
		background: var(--nmg-background, #07111f);
		overflow: hidden;
	}

	body.nmg-game-archive .nmg-mobile-filter-disclosure[open] > .nmg-mobile-filter-toggle {
		position: relative;
		z-index: 2;
		border-radius: 15px;
		box-shadow: 0 10px 30px rgba(0, 0, 0, .24);
	}

	body.nmg-game-archive .nmg-mobile-filter-disclosure[open] > .nmg-game-filters {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		align-content: start;
		gap: 15px;
		min-height: 0;
		height: 100%;
		max-height: 100%;
		align-self: stretch;
		margin: 10px 0 0;
		padding: 16px 4px calc(24px + env(safe-area-inset-bottom));
		border: 0;
		border-radius: 0;
		background: transparent;
		overflow-x: hidden;
		overflow-y: auto;
		overscroll-behavior: contain;
		scroll-padding-block: 20px 140px;
		-webkit-overflow-scrolling: touch;
	}

	body.nmg-game-archive .nmg-game-filter {
		gap: 8px;
	}

	body.nmg-game-archive .nmg-game-filter label {
		font-size: .76rem;
	}

	body.nmg-game-archive .nmg-game-filter input,
	body.nmg-game-archive .nmg-game-filter select {
		height: 48px;
		padding-inline: 13px;
		font-size: 16px;
	}

	body.nmg-game-archive .nmg-game-filter-actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 10px;
		padding-top: 4px;
		background: transparent;
	}

	body.nmg-game-archive .nmg-game-filter-actions .nmg-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 48px;
		margin: 0;
	}

	body.nmg-filter-sheet-open .nmg-mobile-nav {
		display: none;
	}
}
