/**
 * Otiumo: wyszukiwarka imprez i wyniki (licznik, brak wyników).
 *
 * Jak `otiumo.css`: warstwa `@layer otiumo`, selektory `:where()`, zmienne `--otiumo-*`.
 * Na telefonie (< 782 px, z JavaScriptem) filtry chowają się w panelu otwieranym
 * przyciskiem „Filtry (N)”; bez JavaScriptu filtry są zawsze widoczne.
 */

@layer otiumo {
	:where(.otiumo-search, .otiumo-results) {
		--_otiumo-accent: var(--otiumo-accent, #1c5df5);
		--_otiumo-accent-contrast: var(--otiumo-accent-contrast, #ffffff);
		--_otiumo-radius: var(--otiumo-radius, 12px);
		--_otiumo-border: color-mix(in srgb, currentColor 12%, transparent);
		/* Obrys pól mocniejszy niż linie panelu: pole ma być widać bez fokusu. */
		--_otiumo-control-border: color-mix(in srgb, currentColor 28%, transparent);
		--_otiumo-muted: color-mix(in srgb, currentColor 70%, transparent);
		--_otiumo-soft: color-mix(in srgb, currentColor 4%, transparent);
		box-sizing: border-box;
		font-family: var(--otiumo-font, inherit);
	}

	:where(.otiumo-search) :where(*, *::before, *::after) {
		box-sizing: inherit;
	}

	:where(.otiumo-search) {
		margin-block-end: 2rem;
	}

	:where(.otiumo-search__form) {
		margin: 0;
	}

	:where(.otiumo-search__panel) {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 1rem 1.25rem;
		align-items: start;
		padding: 1.25rem 1.5rem 1.5rem;
		border: 1px solid var(--_otiumo-border);
		border-radius: var(--_otiumo-radius);
		background: var(--otiumo-bg, var(--wp--preset--color--base, Canvas));
		box-shadow: 0 1px 2px color-mix(in srgb, currentColor 5%, transparent), 0 12px 32px -24px color-mix(in srgb, currentColor 30%, transparent);
	}

	/* Pasek: równe kolumny (pola „od–do” mieszczą dwie listy), przyciski w ostatniej kolumnie. */
	:where(.otiumo-search--bar) :where(.otiumo-search__panel) {
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
	}

	:where(.otiumo-search--bar) :where(.otiumo-search__actions) {
		grid-column: -2 / -1;
		justify-content: flex-end;
	}

	:where(.otiumo-search__form) {
		container-type: inline-size;
	}

	/* Szeroki pasek: pola „od–do” na dwie kolumny, pola bez etykiety nad kontrolką równo z kontrolkami. */
	@container (min-width: 50rem) {
		:where(.otiumo-search--bar) :where(fieldset.otiumo-search__field) {
			grid-column: span 2;
		}

		:where(.otiumo-search--bar) :where(.otiumo-search__field--wolne, .otiumo-search__actions) {
			margin-top: 1.5rem;
		}
	}


	:where(.otiumo-search--bar) :where(.otiumo-search__submit) {
		flex: 1 1 auto;
	}

	:where(.otiumo-search__field) {
		display: flex;
		flex-direction: column;
		gap: 0.25rem;
		min-width: 0;
		margin: 0;
		padding: 0;
		border: 0;
	}

	:where(.otiumo-search__field--wolne) {
		flex-direction: row;
		align-items: center;
		gap: 0.5rem;
		min-height: 2.75rem;
	}

	:where(.otiumo-search__label) {
		padding: 0;
		font-size: 0.8125em;
		font-weight: 600;
	}

	:where(legend.otiumo-search__label) {
		margin-block-end: 0.25rem;
	}

:where(.otiumo-search__label--inline) {
		font-weight: 400;
		font-size: 1em;
	}

	:where(.otiumo-search__range) {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.375rem;
	}

	:where(.otiumo-search__part) {
		display: flex;
		flex-direction: column;
		gap: 0.125rem;
		min-width: 0;
	}

	:where(.otiumo-search__sublabel) {
		font-size: 0.8125em;
		color: var(--_otiumo-muted);
	}

	/* Pola „od–do”: podpis obok kontrolki, żeby kontrolki stały w jednej linii z resztą pól. */
	:where(.otiumo-search--bar) :where(.otiumo-search__part) {
		flex-direction: row;
		align-items: center;
		gap: 0.5rem;
	}

	:where(.otiumo-search__control) {
		width: 100%;
		min-width: 0;
		min-height: 2.75rem;
		padding: 0.5rem 0.75rem;
		border: 1px solid var(--_otiumo-control-border);
		border-radius: calc(var(--_otiumo-radius) / 1.5);
		background: var(--otiumo-bg, var(--wp--preset--color--base, Canvas));
		color: inherit;
		font: inherit;
		font-size: 0.9375em;
		transition: border-color 0.15s;
	}

	:where(.otiumo-search__control:hover) {
		border-color: color-mix(in srgb, currentColor 45%, transparent);
	}

	:where(.otiumo-search__checkbox) {
		width: 1.25rem;
		height: 1.25rem;
		margin: 0;
		accent-color: var(--_otiumo-accent);
	}

	:where(.otiumo-search__control, .otiumo-search__checkbox, .otiumo-search__submit, .otiumo-search__toggle, .otiumo-search__clear):focus-visible {
		outline: 2px solid var(--_otiumo-accent);
		outline-offset: 2px;
	}

	:where(.otiumo-search__hint) {
		margin: 0.25rem 0 0;
		font-size: 0.8125em;
		color: var(--_otiumo-muted);
	}

	:where(.otiumo-search__actions) {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 0.75rem;
	}

	:where(.otiumo-search__submit, .otiumo-search__toggle, .otiumo-no-results__clear) {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 2.75rem;
		padding: 0.5rem 1.25rem;
		border: 0;
		border-radius: var(--_otiumo-radius);
		background: var(--_otiumo-accent);
		color: var(--_otiumo-accent-contrast);
		font: inherit;
		font-weight: 600;
		text-decoration: none;
		cursor: pointer;
	}

	/* Przycisk panelu: tylko na telefonie i tylko z JavaScriptem. */
	:where(.otiumo-search__toggle) {
		display: none;
		margin-block-end: 0.75rem;
	}

	:where(.otiumo-search__clear) {
		color: inherit;
		text-decoration: underline;
	}

	@media (max-width: 781px) {
		:where(.otiumo-search.is-enhanced) :where(.otiumo-search__toggle) {
			display: inline-flex;
		}

		:where(.otiumo-search.is-enhanced:not(.is-open)) :where(.otiumo-search__panel) {
			display: none;
		}

		:where(.otiumo-search.is-enhanced.is-open) :where(.otiumo-search__panel) {
			padding: 1rem;
		}

		:where(.otiumo-search__actions) :where(.otiumo-search__submit) {
			flex: 1 1 auto;
		}
	}

	/* Wyniki */
	:where(.otiumo-results__count) {
		margin: 0 0 1.25rem;
		font-size: 0.9375em;
		font-weight: 600;
		color: var(--_otiumo-muted);
	}

	:where(.otiumo-results__count):focus {
		outline: none;
	}

	:where(.otiumo-results__count):focus-visible {
		outline: 2px solid var(--_otiumo-accent);
		outline-offset: 4px;
	}

	:where(.otiumo-no-results) {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
		padding: 1.5rem;
		border: 1px dashed var(--_otiumo-control-border);
		border-radius: var(--_otiumo-radius);
	}

	:where(.otiumo-no-results__hint) {
		margin: 0;
		color: var(--_otiumo-muted);
	}
}
