/* Расширенный поиск в каталоге лодок. Подключается модулем inc/advanced-filter.php */

.af {
    --af-accent: #43b4f9;
    --af-line: #e2e7ea;
    --af-ink: #40484d;
    --af-muted: #8a949a;
    margin: 0 0 18px;
}

/* ---------- кнопка раскрытия ---------- */

.af__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 16px;
    border: 1px solid var(--af-accent);
    border-radius: 8px;
    background: #fff;
    color: var(--af-ink);
    font: 600 15px/1.2 "Google Sans", Arial, sans-serif;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.af__toggle:hover,
.af__toggle:focus-visible {
    border-color: var(--af-accent);
    outline: 0;
}

.af[data-open] .af__toggle {
    border-color: var(--af-accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.af__toggle-icon {
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18M6 12h12M10 19h4' stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5h18M6 12h12M10 19h4' stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") no-repeat center / contain;
    flex: 0 0 auto;
}

.af__toggle-text {
    flex: 1 1 auto;
}

.af__badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    background: var(--af-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.af__chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-3px) rotate(45deg);
    transition: transform 200ms ease;
    flex: 0 0 auto;
}

.af[data-open] .af__chevron {
    transform: translateY(2px) rotate(-135deg);
}

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

.af__panel {
    padding: 20px 18px 16px;
    border: 1px solid var(--af-accent);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: #fbfdfe;
}

.af__panel[hidden] {
    display: none;
}

.af__hint {
    margin: 0 0 16px;
    color: var(--af-muted);
    font-size: 13px;
}

/* ---------- выбор пирса ---------- */

.af__pier {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0 0 20px;
}

.af__pier-label {
    color: var(--af-ink);
    font-size: 13px;
    font-weight: 600;
}

/*
 * Свой список вместо нативного select: пирсов можно выбрать несколько,
 * а нативный множественный выбор на телефоне неудобен до неприличия.
 */
.af__pier-field {
    position: relative;
    display: inline-flex;
}

.af__pier-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
    max-width: 100%;
    padding: 10px 38px 10px 18px;
    border: 1px solid var(--af-line);
    border-radius: 999px;
    background: #fff;
    color: var(--af-ink);
    font: 13px/1.2 "Google Sans", Arial, sans-serif;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease;
}

.af__pier-button:hover,
.af__pier-button:focus-visible,
.af__pier-button[aria-expanded="true"] {
    border-color: var(--af-accent);
    outline: 0;
}

.af__pier-button>span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.af__pier-button::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 9px;
    height: 9px;
    margin-top: -6px;
    border-right: 2px solid var(--af-ink);
    border-bottom: 2px solid var(--af-ink);
    transform: rotate(45deg);
    transition: transform 160ms ease;
    pointer-events: none;
}

.af__pier-button[aria-expanded="true"]::after {
    margin-top: -2px;
    transform: rotate(-135deg);
}

.af__pier-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    min-width: 100%;
    width: max-content;
    max-width: min(320px, calc(100vw - 40px));
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--af-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px -12px rgba(24, 42, 54, .35);
}

.af__pier-list[hidden] {
    display: none;
}

.af__pier-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--af-ink);
    font-size: 13px;
    cursor: pointer;
    margin: 0;
    font-weight: normal;
}

.af__pier-option:hover {
    background: #f1f5f7;
}

.af__pier-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.af__pier-option-name {
    flex: 1 1 auto;
}

.af__pier-option-count {
    color: var(--af-muted);
    font-size: 12.5px;
}

/* класс ставит скрипт — так подсветка работает и в браузерах без :has() */
.af__pier-option.is-picked,
.af__pier-option:has(input:checked) {
    background: #dceffb;
}

.af__pier-option:has(input:focus-visible) {
    box-shadow: inset 0 0 0 2px var(--af-accent);
}

.af__pier-clear {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #c9d1d5;
    cursor: pointer;
    position: relative;
    flex: 0 0 auto;
    transition: background-color 160ms ease;
}

.af__pier-clear:hover,
.af__pier-clear:focus-visible {
    background: #8a949a;
    outline: 0;
}

.af__pier-clear::before,
.af__pier-clear::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 11px;
    height: 2px;
    margin: -1px 0 0 -5.5px;
    background: #fff;
}

.af__pier-clear::before {
    transform: rotate(45deg);
}

.af__pier-clear::after {
    transform: rotate(-45deg);
}

.af__pier-clear[hidden] {
    display: none;
}

.af__pier-map {
    color: var(--af-muted);
    font-size: 14px;
}

.af__pier-map a,
.af__pier-map a:visited {
    color: var(--af-accent);
    text-decoration: underline;
}

.af__pier-map a:hover {
    color: var(--af-ink);
}

.af__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px 26px;
}

.af__group--wide {
    grid-column: 1 / -1;
}

.af__legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--af-ink);
    font-size: 13px;
    font-weight: 600;
}

.af__legend-icon {
    width: 22px;
    height: 22px;
    background: var(--af-muted);
    -webkit-mask: var(--af-icon) no-repeat center / contain;
    mask: var(--af-icon) no-repeat center / contain;
    flex: 0 0 auto;
}

.af__output {
    margin-left: auto;
    color: var(--af-accent);
    font-weight: 700;
}

/* ---------- чипы категорий ---------- */

.af__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.af__chip input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.af__chip-body {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--af-line);
    border-radius: 22px;
    background: #fff;
    color: var(--af-ink);
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.af__chip-icon {
    /* задаём только высоту — ширина следует пропорциям самой иконки */
    width: auto;
    height: 24px;
    aspect-ratio: var(--af-ratio, 1.3);
    background: currentColor;
    -webkit-mask: var(--af-icon) no-repeat center / contain;
    mask: var(--af-icon) no-repeat center / contain;
    flex: 0 0 auto;
}

.af__chip-count {
    color: var(--af-muted);
    font-size: 12px;
}

.af__chip-body:hover {
    border-color: var(--af-accent);
}

.af__chip input:checked+.af__chip-body {
    border-color: var(--af-accent);
    background: var(--af-accent);
    color: #fff;
}

.af__chip input:checked+.af__chip-body .af__chip-count {
    color: rgba(255, 255, 255, .8);
}

.af__chip input:focus-visible+.af__chip-body {
    outline: 2px solid var(--af-accent);
    outline-offset: 2px;
}

/* ---------- пороговые кнопки ---------- */

.af__steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.af__step {
    padding: 8px 12px;
    border: 1px solid var(--af-line);
    border-radius: 6px;
    background: #fff;
    color: var(--af-ink);
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.af__step:hover {
    border-color: var(--af-accent);
}

.af__step.is-active {
    border-color: var(--af-accent);
    background: var(--af-accent);
    color: #fff;
}

.af__step:focus-visible {
    outline: 2px solid var(--af-accent);
    outline-offset: 2px;
}

/* ---------- ползунок длины ---------- */

.af__range {
    position: relative;
    height: 34px;
}

.af__range-track {
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: 4px;
    margin-top: -2px;
    border-radius: 2px;
    background: #dfe6ea;
}

.af__range-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 2px;
    background: var(--af-accent);
}

.af__range input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 34px;
    margin: 0;
    background: none;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}

.af__range input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    border: 2px solid var(--af-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    cursor: grab;
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
}

.af__range input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 2px solid var(--af-accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    cursor: grab;
    pointer-events: auto;
}

.af__range input[type="range"]::-moz-range-track {
    background: none;
}

/* ---------- поля цены ---------- */

.af__pair {
    display: flex;
    gap: 10px;
}

.af__field {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid var(--af-line);
    border-radius: 6px;
    background: #fff;
}

.af__field:focus-within {
    border-color: var(--af-accent);
}

.af__field span {
    color: var(--af-muted);
    font-size: 12px;
}

.af__field input {
    width: 100%;
    min-width: 0;
    padding: 9px 0;
    border: 0;
    background: none;
    color: var(--af-ink);
    font-size: 14px;
    outline: 0;
}

.af__switch {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 0;
    color: var(--af-ink);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
}

.af__switch input {
    width: 17px;
    height: 17px;
    accent-color: var(--af-accent);
}

/* ---------- действия ---------- */

.af__actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--af-line);
}

.af__apply.btn.btn-blue {
    padding: 11px 22px;
    font-size: 14px;
}

.af__reset {
    padding: 6px 2px;
    border: 0;
    background: none;
    color: var(--af-muted);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.af__reset:hover {
    color: var(--af-ink);
}

.af__empty {
    display: none;
    margin: 30px 0;
    padding: 22px;
    border-radius: 8px;
    background: #f5f8fa;
    color: var(--af-muted);
    font-size: 15px;
    text-align: center;
}

.af__empty[hidden] {
    display: none;
}

.af__empty.is-visible {
    display: block;
}

/* ---------- мобильный ---------- */

@media (max-width: 767px) {
    .af__panel {
        padding: 16px 14px 14px;
    }

    .af__grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    /*
     * На телефоне «Пирс» и список — в одну строку, ссылка на карту переносится
     * под них: так поле остаётся достаточно широким, чтобы читались длинные
     * названия вроде «Пхукет Яхт Хейвен Марина».
     */
    .af__pier {
        gap: 8px 10px;
        margin-bottom: 18px;
    }

    .af__pier-field {
        flex: 1 1 auto;
        min-width: 0;
    }

    .af__pier-button {
        width: 100%;
        min-width: 0;
        padding: 9px 34px 9px 14px;
        font-size: 14px;
    }

    .af__pier-list {
        max-width: calc(100vw - 32px);
        max-height: 55vh;
    }

    .af__pier-option {
        padding: 11px 12px;
        font-size: 14px;
    }

    .af__pier-map {
        flex: 1 0 100%;
        font-size: 13px;
    }

    .af__chips {
        gap: 6px;
    }

    .af__chip-body {
        min-height: 38px;
        padding: 6px 12px;
        font-size: 12.5px;
    }

    .af__chip-icon {
        height: 20px;
    }

    .af__step {
        min-height: 38px;
        padding: 8px 12px;
    }

    .af__legend {
        margin-bottom: 8px;
    }

    .af__chip-name {
        max-width: 46vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* кнопка результата всегда под рукой */
    .af__actions {
        position: sticky;
        bottom: 0;
        z-index: 2;
        margin: 18px -14px -14px;
        padding: 12px 14px;
        background: #fbfdfe;
        box-shadow: 0 -6px 14px rgba(0, 0, 0, .06);
    }

    .af__apply.btn.btn-blue {
        flex: 1 1 auto;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {

    .af__chevron,
    .af__toggle,
    .af__chip-body,
    .af__step {
        transition: none;
    }
}