/*!
 * Starosta Filters — інтерфейс каталогу.
 * Тема задає вигляд змінними --stf-* (див. :root нижче); класи — з префіксом stf-.
 */

:root {
	--stf-accent: #1b1320;          /* обране значення, головна кнопка */
	--stf-accent-text: #fff;
	--stf-ink: #1b1320;             /* текст */
	--stf-muted: #6e6272;           /* лічильники, підписи */
	--stf-line: #e9dfe6;            /* розділювачі */
	--stf-line-strong: #d5c6d0;     /* рамки полів і чекбоксів */
	--stf-bg: #fff;
	--stf-soft: #f7f3f6;            /* тло поля пошуку, ховер */
	--stf-radius: 8px;
	--stf-radius-s: 5px;
	--stf-font: inherit;
	--stf-size: 15px;
	--stf-size-s: 13px;
	--stf-control: 44px;            /* висота кнопок і полів */
	--stf-row: 32px;                /* висота рядка значення (на телефоні — не менше 40) */
	--stf-focus: 0 0 0 3px rgba(161, 42, 147, .35);
	--stf-offset: 0px;              /* висота липкої шапки теми */
	--stf-drawer-top: 6vh;
}

.stf-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- панель ---------- */

.stf-panel { font: var(--stf-size)/1.35 var(--stf-font); color: var(--stf-ink); }
.stf-panel__head, .stf-panel__foot { display: none; }
.stf-panel__empty { color: var(--stf-muted); margin: 0; }

.stf-filter { border-bottom: 1px solid var(--stf-line); padding: 14px 0; }
.stf-filter:first-child { padding-top: 0; }
.stf-filter:last-child { border-bottom: 0; }
.stf-filter__title { margin: 0; font: inherit; }
.stf-filter__toggle {
	all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%;
	min-height: 28px; cursor: pointer; font-weight: 600; font-size: var(--stf-size); color: var(--stf-ink);
}
.stf-filter__toggle:focus-visible { box-shadow: var(--stf-focus); border-radius: var(--stf-radius-s); }
.stf-filter__toggle > span:first-child { flex: 1; }
.stf-filter__badge {
	min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center;
	background: var(--stf-accent); color: var(--stf-accent-text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.stf-chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; flex: none; }
.stf-filter__toggle[aria-expanded="false"] .stf-chevron { transform: rotate(-90deg); }
.stf-filter__body { padding-top: 10px; }

/* значення */
.stf-values { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.stf-values__item[hidden] { display: none; }
.stf-value {
	display: flex; align-items: center; gap: 10px; min-height: var(--stf-row); padding: 2px 0;
	color: var(--stf-ink); text-decoration: none; border-radius: var(--stf-radius-s); cursor: pointer;
}
.stf-value:hover .stf-value__name { color: var(--stf-accent); }
.stf-value:focus-visible { outline: none; box-shadow: var(--stf-focus); }
.stf-value__name { flex: 1; min-width: 0; }
.stf-value__count { color: var(--stf-muted); font-size: var(--stf-size-s); font-variant-numeric: tabular-nums; }
.stf-value.is-empty { opacity: .45; }

.stf-box {
	flex: none; width: 18px; height: 18px; border: 1.5px solid var(--stf-line-strong); border-radius: 4px; background: var(--stf-bg);
	transition: background-color .12s, border-color .12s;
}
.stf-value[role="radio"] .stf-box { border-radius: 50%; }
.stf-value.is-selected .stf-box {
	background: var(--stf-accent) center/12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.4l3.1 3.1 6.5-7' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E");
	border-color: var(--stf-accent);
}
.stf-value.is-selected .stf-value__name { font-weight: 600; }

/* плитки (об'єм, розмір) */
.stf-values--labels { display: flex; flex-wrap: wrap; gap: 6px; }
.stf-values--labels .stf-value {
	min-height: 36px; padding: 0 12px; gap: 6px; border: 1.5px solid var(--stf-line-strong); border-radius: var(--stf-radius); background: var(--stf-bg);
}
.stf-values--labels .stf-value:hover { border-color: var(--stf-ink); }
.stf-values--labels .stf-value__name { flex: none; }
.stf-values--labels .stf-value.is-selected { border-color: var(--stf-accent); box-shadow: inset 0 0 0 1px var(--stf-accent); }
.stf-values--labels .stf-value.is-selected .stf-value__name { font-weight: 600; }

/* кольори */
.stf-values--swatches { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 6px; }
.stf-values--swatches .stf-value { flex-direction: column; gap: 5px; padding: 4px 2px; min-height: 0; text-align: center; }
.stf-values--swatches .stf-value__name { font-size: 12px; line-height: 1.15; color: var(--stf-muted); }
.stf-swatch {
	width: 30px; height: 30px; border-radius: 50%; background: var(--stf-swatch); flex: none;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: box-shadow .12s;
}
.stf-value.is-selected .stf-swatch { box-shadow: 0 0 0 2px var(--stf-bg), 0 0 0 3.5px var(--stf-accent); }
.stf-value.is-selected .stf-value__name { color: var(--stf-ink); }

.stf-more {
	all: unset; cursor: pointer; margin-top: 8px; font-size: var(--stf-size-s); font-weight: 600; color: var(--stf-accent);
	min-height: 28px; display: inline-flex; align-items: center;
}
.stf-more:focus-visible { box-shadow: var(--stf-focus); border-radius: var(--stf-radius-s); }
.stf-search {
	box-sizing: border-box; width: 100%; height: 38px; margin: 0 0 10px; padding: 0 12px; font: inherit; font-size: 14px;
	border: 1.5px solid transparent; border-radius: var(--stf-radius); background: var(--stf-soft); color: var(--stf-ink);
}
/* Пошук по списку: без кільця фокусу теми й без темної рамки — лише тонка рамка на білому. */
.stf-panel .stf-search:focus, .stf-panel .stf-search:focus-visible { outline: none; box-shadow: none; border-color: var(--stf-line-strong); background: var(--stf-bg); }

/* ціна */
.stf-range__inputs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.stf-range__inputs input {
	box-sizing: border-box; width: 100%; height: 40px; padding: 0 10px; font: inherit; font-size: 15px; font-variant-numeric: tabular-nums;
	border: 1.5px solid var(--stf-line-strong); border-radius: var(--stf-radius); background: var(--stf-bg); color: var(--stf-ink);
	-moz-appearance: textfield;
}
.stf-range__inputs input::-webkit-outer-spin-button, .stf-range__inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stf-range__inputs input:focus { outline: none; border-color: var(--stf-accent); box-shadow: var(--stf-focus); }
.stf-range__dash { color: var(--stf-muted); }
.stf-slider { position: relative; height: 24px; margin: 12px 9px 0; }
.stf-slider__track { position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: var(--stf-line); }
.stf-slider__fill { position: absolute; top: 0; bottom: 0; background: var(--stf-accent); border-radius: 2px; }
.stf-slider__thumb {
	position: absolute; left: -9px; right: -9px; width: calc(100% + 18px); top: 0; height: 24px; margin: 0;
	-webkit-appearance: none; appearance: none; background: none; pointer-events: none;
}
.stf-slider__thumb::-webkit-slider-thumb {
	-webkit-appearance: none; pointer-events: auto; width: 20px; height: 20px; border-radius: 50%;
	background: var(--stf-bg); border: 2px solid var(--stf-accent); cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.stf-slider__thumb::-moz-range-thumb {
	pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--stf-bg); border: 2px solid var(--stf-accent); cursor: grab;
}
.stf-slider__thumb::-webkit-slider-runnable-track { background: none; }
.stf-slider__thumb::-moz-range-track { background: none; }

.stf-search-none { margin: 4px 0 0; font-size: var(--stf-size-s); color: var(--stf-muted); }
.stf-values--swatches { justify-items: start; }
.stf-chip span { display: inline-block; }
.stf-chip span::first-letter { text-transform: uppercase; }

/* ПК: липка панель, вища за екран, гортається сама — нижні фільтри завжди досяжні. */
@media (min-width: 1024px) {
	.stf-panel--sticky, .stf-aside .stf-panel {
		max-height: calc(100vh - var(--stf-offset, 0px) - 32px); overflow-y: auto; overscroll-behavior: contain;
		scrollbar-width: thin; scrollbar-color: var(--stf-line-strong) transparent; padding-right: 6px;
	}
}

/* ---------- кнопки ---------- */

.stf-btn {
	box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: var(--stf-control); padding: 0 18px; border-radius: var(--stf-radius); border: 1.5px solid transparent;
	font: 600 var(--stf-size)/1.1 var(--stf-font); text-decoration: none; cursor: pointer; white-space: nowrap;
	transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.stf-btn:focus-visible { outline: none; box-shadow: var(--stf-focus); }
.stf-btn--primary { background: var(--stf-accent); color: var(--stf-accent-text); }
.stf-btn--primary:disabled { opacity: .5; cursor: default; }
.stf-btn--primary.is-loading { opacity: .75; }
.stf-btn--ghost { background: transparent; color: var(--stf-ink); border-color: var(--stf-line-strong); }
.stf-btn--ghost[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.stf-btn--outline { background: transparent; color: var(--stf-ink); border-color: var(--stf-ink); }
.stf-btn--outline:hover { background: var(--stf-ink); color: var(--stf-bg); }

.stf-icon-btn {
	all: unset; box-sizing: border-box; width: var(--stf-control); height: var(--stf-control); display: grid; place-items: center; cursor: pointer;
	border-radius: 50%; color: var(--stf-ink);
}
.stf-icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.stf-icon-btn:focus-visible { box-shadow: var(--stf-focus); }

/* кнопка «Фільтри» (лише телефон) */
.stf-open {
	box-sizing: border-box; display: none; align-items: center; justify-content: center; gap: 8px; width: 100%;
	min-height: var(--stf-control); padding: 0 16px; border: 1.5px solid var(--stf-line-strong); border-radius: var(--stf-radius);
	background: var(--stf-bg); color: var(--stf-ink); font: 600 14px/1 var(--stf-font); cursor: pointer;
}
.stf-open svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.stf-open:focus-visible { outline: none; box-shadow: var(--stf-focus); }
.stf-open__badge {
	min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center;
	background: var(--stf-accent); color: var(--stf-accent-text); font-size: 12px; font-variant-numeric: tabular-nums;
}

/* ---------- сортування ---------- */

.stf-sort { display: flex; align-items: center; gap: 10px; font: var(--stf-size)/1 var(--stf-font); color: var(--stf-ink); }
.stf-sort__label { color: var(--stf-muted); font-size: 14px; white-space: nowrap; }
.stf-sort__box {
	position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: var(--stf-control); padding: 0 14px;
	border: 1.5px solid var(--stf-line-strong); border-radius: var(--stf-radius); background: var(--stf-bg); font-weight: 500; font-size: 14px;
}
.stf-sort__select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.stf-sort__box:has(.stf-sort__select:focus-visible) { box-shadow: var(--stf-focus); }

/* ---------- чипси ---------- */

.stf-chips { margin: 0 0 18px; }
.stf-chips__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.stf-chip {
	display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border-radius: var(--stf-radius);
	background: var(--stf-accent); color: var(--stf-accent-text); font: 500 14px/1 var(--stf-font); text-decoration: none; white-space: nowrap;
}
.stf-chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; opacity: .8; }
.stf-chip:hover svg { opacity: 1; }
.stf-chip:focus-visible { outline: none; box-shadow: var(--stf-focus); }
.stf-chip--reset { background: transparent; color: var(--stf-accent); font-weight: 600; padding: 0 4px; }

/* ---------- під сіткою ---------- */

.stf-results { position: relative; }
.stf-busy .stf-results [data-stf-grid], .stf-busy .stf-panel:not(.is-open) .stf-panel__body { opacity: .5; transition: opacity .15s; pointer-events: none; }
.stf-footer { display: grid; justify-items: center; gap: 16px; margin-top: 44px; font: var(--stf-size)/1.3 var(--stf-font); color: var(--stf-ink); }
.stf-footer__shown { margin: 0; color: var(--stf-muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.stf-load-more { min-height: 40px; font-size: 14px; }
.stf-load-more.is-loading { opacity: .6; pointer-events: none; }
.stf-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.stf-pager__num, .stf-pager__arrow {
	box-sizing: border-box; min-width: 42px; height: 42px; padding: 0 8px; display: inline-grid; place-items: center;
	border: 1.5px solid var(--stf-line); border-radius: var(--stf-radius); color: var(--stf-ink); text-decoration: none;
	font-weight: 500; font-variant-numeric: tabular-nums;
}
.stf-pager__num:hover { border-color: var(--stf-ink); }
.stf-pager__num.is-current { background: var(--stf-accent); border-color: var(--stf-accent); color: var(--stf-accent-text); }
.stf-pager__arrow { border-color: transparent; }
.stf-pager__arrow:hover { border-color: var(--stf-line); }
.stf-pager__arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stf-pager__dots { min-width: 20px; text-align: center; color: var(--stf-muted); }
.stf-pager a:focus-visible { outline: none; box-shadow: var(--stf-focus); }

.stf-empty { display: grid; justify-items: start; gap: 10px; padding: 40px 0; font: var(--stf-size)/1.45 var(--stf-font); color: var(--stf-ink); }
.stf-empty__title { margin: 0; font-size: 22px; font-weight: 600; }
.stf-empty__text { margin: 0; color: var(--stf-muted); }

/* ---------- телефон: шторка ---------- */

@media (max-width: 1023px) {
	.stf-open { display: inline-flex; }
	.stf-panel {
		position: fixed; z-index: 100000; left: 0; right: 0; bottom: 0; top: var(--stf-drawer-top);
		display: flex; flex-direction: column; background: var(--stf-bg); border-radius: 16px 16px 0 0;
		transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s;
		box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
	}
	.stf-panel.is-open { transform: none; visibility: visible; transition: transform .25s ease; }
	.stf-panel__head {
		display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 20px;
		border-bottom: 1px solid var(--stf-line); flex: none;
	}
	.stf-panel__title { font-size: 18px; font-weight: 600; }
	.stf-panel__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px 20px; -webkit-overflow-scrolling: touch; }
	.stf-panel__foot {
		display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
		border-top: 1px solid var(--stf-line); flex: none; background: var(--stf-bg);
	}
	.stf-value { min-height: max(var(--stf-row), 40px); }
	/* iOS збільшує сторінку при фокусі в полі з шрифтом < 16px */
	.stf-range__inputs input, .stf-search { font-size: 16px; }
	.stf-filter__toggle { min-height: 40px; }
	.stf-more { min-height: 40px; }
	.stf-values--labels .stf-value { min-height: 40px; }
	.stf-chips__list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: calc(-1 * var(--stf-gutter, 0px)); padding-right: var(--stf-gutter, 0px); }
	.stf-chips__list::-webkit-scrollbar { display: none; }
	.stf-chip { min-height: 40px; }
	.stf-sort__label { display: none; }
	.stf-sort, .stf-sort__box { width: 100%; }
	.stf-sort__box { justify-content: center; }
	.stf-pager__num, .stf-pager__arrow { min-width: 40px; height: 40px; }
	.stf-pager { gap: 4px; }
	.stf-overlay { position: fixed; inset: 0; z-index: 99999; background: rgba(20, 12, 24, .45); opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s linear .25s; }
	.stf-drawer-open .stf-overlay { opacity: 1; visibility: visible; transition: opacity .25s; }
	.stf-drawer-open, .stf-drawer-open body { overflow: hidden; }
}

/* Планшет: шторка — бокова панель праворуч, а не на всю ширину */
@media (min-width: 600px) and (max-width: 1023px) {
	.stf-panel { left: auto; top: 0; width: 420px; border-radius: 16px 0 0 16px; transform: translateX(105%); }
	.stf-panel.is-open { transform: none; }
}
.stf-search::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

@media (prefers-reduced-motion: reduce) {
	.stf-panel, .stf-overlay, .stf-chevron { transition: none !important; }
}
