/*
 * Боковая панель каталога.
 *
 * Открывается из шапки, живёт на всех страницах города. Разметка своя
 * (префикс sp-), от старой панели остались только классы .side-panel и
 * .header-overlay — на них завязано открытие в script.js.
 */

.sp {
    --sp-ink: #14132B;
    --sp-muted: #77768F;
    --sp-line: #EAEAF3;
    --sp-soft: #F6F6FB;
    --sp-brand: #4F4BFF;
    --sp-brand-light: #6C69FF;
    --sp-tint: #EFEFFF;

    width: 428px;
    max-width: 92%;
    background: #fff;
    border-radius: 0 26px 26px 0;
    box-shadow: 40px 0 100px -60px rgba(20, 19, 43, .95);
    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--sp-ink);
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility .32s;
}

.sp *,
.sp *::before,
.sp *::after {
    box-sizing: border-box;
}

.sp a {
    text-decoration: none;
    color: inherit;
}

.sp button {
    font-family: inherit;
    cursor: pointer;
}

.sp :focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 75, 255, .35);
    border-radius: 10px;
}

/* Колонка целиком: шапка и подвал приклеены, список прокручивается. */
.sp .side-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sp-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 16px 16px;
    scrollbar-width: thin;
    scrollbar-color: #D6D5E6 transparent;
}

.sp-body::-webkit-scrollbar {
    width: 8px;
}

.sp-body::-webkit-scrollbar-thumb {
    background: #D6D5E6;
    border-radius: 8px;
    border: 2px solid #fff;
}

/* ── Шапка панели ─────────────────────────────────────────────────── */

.sp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 12px;
}

.sp-head__logo {
    line-height: 0;
}

.sp-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 1px solid var(--sp-line);
    border-radius: 12px;
    background: #fff;
    color: var(--sp-muted);
    transition: color .18s ease, border-color .18s ease, transform .18s ease;
}

.sp-close:hover {
    color: var(--sp-brand);
    border-color: #C9C7FF;
    transform: rotate(90deg);
}

/* ── Поиск по каталогу ────────────────────────────────────────────── */

.sp-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 16px 12px;
}

.sp-search__icon {
    position: absolute;
    left: 15px;
    color: #9C9BB4;
    pointer-events: none;
}

.sp-search input {
    width: 100%;
    height: 46px;
    padding: 0 40px 0 40px;
    border: 1px solid var(--sp-line);
    border-radius: 14px;
    background: var(--sp-soft);
    font-family: inherit;
    font-size: 14px;
    color: var(--sp-ink);
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.sp-search input::placeholder {
    color: #9C9BB4;
}

.sp-search input::-webkit-search-cancel-button {
    display: none;
}

.sp-search input:focus {
    outline: none;
    background: #fff;
    border-color: var(--sp-brand-light);
    box-shadow: 0 0 0 3px rgba(79, 75, 255, .14);
}

.sp-search__clear {
    position: absolute;
    right: 10px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: #E4E3F2;
    color: #5F5E7A;
    transition: background .18s ease, color .18s ease;
}

.sp-search__clear:hover {
    background: var(--sp-brand);
    color: #fff;
}

/* ── Быстрые ссылки ───────────────────────────────────────────────── */

.sp-quick {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.sp-quick__item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 13px 14px;
    border-radius: 16px;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(255, 92, 122, .16) 0%, rgba(255, 92, 122, 0) 55%),
        var(--sp-soft);
    border: 1px solid transparent;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.sp-quick__item:hover {
    transform: translateY(-2px);
    border-color: #DDDCFF;
    box-shadow: 0 16px 30px -22px rgba(20, 19, 43, .8);
}

.sp-quick__item.is-active {
    background: linear-gradient(135deg, #6C69FF, #4F4BFF);
    color: #fff;
}

.sp-quick__title {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.sp-quick__note {
    font-size: 11.5px;
    color: var(--sp-muted);
}

.sp-quick__item.is-active .sp-quick__note {
    color: rgba(255, 255, 255, .75);
}

/* ── Разделы ──────────────────────────────────────────────────────── */

.sp-section + .sp-section {
    margin-top: 4px;
}

.sp-section__head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 14px;
    background: none;
    text-align: left;
    transition: background .18s ease;
}

.sp-section__head:hover {
    background: var(--sp-soft);
}

.sp-section__icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--sp-tint);
    color: var(--sp-brand);
    transition: background .2s ease, color .2s ease;
}

.sp-section.is-open .sp-section__icon {
    background: linear-gradient(135deg, #6C69FF, #4F4BFF);
    color: #fff;
}

.sp-section__title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.sp-section__count {
    flex: 0 0 auto;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--sp-soft);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--sp-muted);
    font-variant-numeric: tabular-nums;
}

.sp-section__caret {
    flex: 0 0 auto;
    color: #A9A8BE;
    transition: transform .28s ease;
}

.sp-section.is-open .sp-section__caret {
    transform: rotate(180deg);
    color: var(--sp-brand);
}

/* Раскрытие без замера высоты в скрипте. */
.sp-section__body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s cubic-bezier(.2, .8, .2, 1);
}

.sp-section.is-open .sp-section__body {
    grid-template-rows: 1fr;
}

.sp-section__inner {
    overflow: hidden;
}

.sp-list {
    padding: 4px 12px 14px 62px;
}

.sp-list--columns {
    column-count: 2;
    column-gap: 14px;
}

.sp-list--columns .sp-link {
    display: block;
    break-inside: avoid;
    padding: 5px 0;
    font-size: 13.5px;
    color: var(--sp-muted);
    transition: color .16s ease, padding-left .16s ease;
}

.sp-list--columns .sp-link:hover {
    color: var(--sp-brand);
    padding-left: 4px;
}

.sp-list--chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.sp-list--chips .sp-link {
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--sp-soft);
    font-size: 13px;
    color: #3D3C5C;
    transition: background .16s ease, color .16s ease;
}

.sp-list--chips .sp-link:hover {
    background: var(--sp-tint);
    color: var(--sp-brand);
}

.sp-link.is-active {
    color: var(--sp-brand);
    font-weight: 700;
}

.sp-list--chips .sp-link.is-active {
    background: var(--sp-tint);
    box-shadow: inset 0 0 0 1px #C9C7FF;
}

.sp-empty {
    margin: 10px 12px;
    padding: 18px;
    border-radius: 16px;
    background: var(--sp-soft);
    color: var(--sp-muted);
    font-size: 13.5px;
    text-align: center;
}

/* ── Подвал ───────────────────────────────────────────────────────── */

.sp-foot {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--sp-line);
    background: #fff;
}

.sp-foot__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--sp-line);
    border-radius: 13px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #3D3C5C;
    transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.sp-foot__btn:hover {
    color: var(--sp-brand);
    border-color: #C9C7FF;
    background: var(--sp-soft);
}

/* ── Экраны ───────────────────────────────────────────────────────── */

@media (max-width: 575px) {
    .sp {
        border-radius: 0 20px 20px 0;
    }

    .sp-head {
        padding: 14px 14px 10px;
    }

    .sp-search {
        margin: 0 14px 10px;
    }

    .sp-body {
        padding: 4px 12px 12px;
    }

    .sp-list {
        padding-left: 14px;
    }

    .sp-list--columns {
        column-count: 1;
    }

    /* Подписи в подвале иначе ломаются на две строки. */
    .sp-foot {
        padding-left: 12px;
        padding-right: 12px;
    }

    .sp-foot__btn {
        padding: 0 8px;
        font-size: 12.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sp,
    .sp * {
        transition: none !important;
    }
}
