/**
 * Стили фильтра по баджам (иконка у заголовка + список баджей).
 * Используется на страницах: Все походы, Групповые фото, Archive походы.
 */

/* Строка заголовка: заголовок строго по центру, иконка фильтров — absolute справа */
.cg-archive-title-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.cg-archive-title-row .cg-archive-title {
    margin: 0;
}

.cg-archive-badge-filter-toggle-wrap {
    opacity: 0.7;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cg-archive-badge-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 100px;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}


.cg-archive-badge-filter-toggle.has-active-filter,
.cg-archive-badge-filter-toggle:hover {
    opacity: 1;
    color: #1a252f;
    background: rgba(0, 0, 0, 0.06);
}

.cg-archive-filter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cg-archive-filter-icon svg {
    width: 22px;
    height: 22px;
}

/* Крестик сброса внутри ссылки «Фильтры» — показывается только при выбранном фильтре */
.cg-archive-badge-filter-toggle .cg-archive-filter-reset-icon {
    display: none;
}

.cg-archive-badge-filter-toggle.has-active-filter .cg-archive-filter-reset-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
    color: #e74c3c;
    transition: color 0.2s ease;
}

.cg-archive-badge-filter-toggle.has-active-filter .cg-archive-filter-reset-icon svg {
    width: 18px;
    height: 18px;
}

.cg-archive-badge-filter-toggle.has-active-filter:hover .cg-archive-filter-reset-icon {
    color: #c0392b;
}

/* На мобильной убираем слово «Фильтры», только иконка */
@media (max-width: 640px) {
    .cg-archive-badge-filter-toggle-text {
        display: none;
    }

    .cg-archive-badge-filter-toggle {
        padding: 8px;
    }
}

/* Фильтр по баджам — анимация по высоте при открытии/закрытии (без overflow: hidden, чтобы попапы/тултипы не обрезались) */
.cg-archive-badge-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    max-height: 0;
    padding-top: 0;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding-top 0.25s ease, visibility 0s linear 0.35s;
}

.cg-archive-badge-filter-wrap.is-open .cg-archive-badge-filter,
.cg-archive-badge-filter-wrap.has-active-filter .cg-archive-badge-filter {
    max-height: 280px;
    opacity: 1;
    padding-top: 12px;
    visibility: visible;
    transition-delay: 0s;
}

@media (max-width: 640px) {
    .cg-archive-badge-filter-wrap.is-open .cg-archive-badge-filter,
    .cg-archive-badge-filter-wrap.has-active-filter .cg-archive-badge-filter {
        max-height: 320px;
        padding-top: 12px;
    }
}

/* Кнопки баджей в фильтре */
.cg-badge-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    text-decoration: none;
    color: inherit;
    opacity: 1;
    position: relative;
    margin-bottom: 30px;
}

.cg-badge-filter-btn .cg-badge-filter-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
}

.cg-badge-filter-btn .cg-badge-filter-icon-wrap svg {
    width: 22px;
    height: 22px;
}

.cg-badge-filter-btn .cg-badge-filter-count {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    font-size: 11px;
    color: #888;
    line-height: 1;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
    pointer-events: none;
}

.cg-badge-filter-btn svg {
    width: 22px;
    height: 22px;
}

.cg-badge-filter-btn:hover {
    transform: scale(1.08);
    opacity: 1;
}

.cg-badge-filter-btn.is-active {
    opacity: 1;
    transform: scale(1.2);
}

.cg-badge-filter-btn.is-active svg {
    width: 26px;
    height: 26px;
}

.cg-badge-filter-btn.inactive {
    opacity: 0.4;
}

.cg-badge-filter-btn.inactive:hover {
    opacity: 1;
}

/* Подсказка (tooltip) для кнопок баджей */
.cg-badge-filter-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.cg-badge-filter-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.cg-badge-filter-btn:hover::after,
.cg-badge-filter-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.cg-badge-filter-btn:hover::before {
    transform: translateX(-50%) translateY(0);
}

/* Кнопка «Все» */
.cg-badge-filter-all {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    width: auto;
    padding: 0 18px;
    height: 40px;
    border-radius: 20px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    position: relative;
}

.cg-badge-filter-all.inactive {
    opacity: 0.4;
}

.cg-badge-filter-all.inactive:hover {
    opacity: 1;
}

.cg-badge-filter-all:hover {
    opacity: 1;
}

.cg-badge-filter-all.is-active {
    background: #2c3e50;
    color: #fff;
    opacity: 1;
    transform: scale(1.08);
}

.cg-badge-filter-all::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.cg-badge-filter-all::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.cg-badge-filter-all:hover::after,
.cg-badge-filter-all:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.cg-badge-filter-all:hover::before {
    transform: translateX(-50%) translateY(0);
}

/* Тёмная тема */
[data-theme="dark"] .cg-badge-filter-btn .cg-badge-filter-count {
    color: #888;
}

[data-theme="dark"] .cg-badge-filter-btn .cg-badge-filter-icon-wrap {
    background: var(--stat-bg, #2d3139);
}

[data-theme="dark"] .cg-badge-filter-all {
    color: #e5e7eb;
}

[data-theme="dark"] .cg-badge-filter-all.is-active {
    background: #4b5563;
    color: #f1f3f4;
}

[data-theme="dark"] .cg-archive-badge-filter-toggle {
    color: #e5e7eb;
}

[data-theme="dark"] .cg-archive-badge-filter-toggle.has-active-filter,
[data-theme="dark"] .cg-archive-badge-filter-toggle:hover {
    opacity: 1;
    color: #f1f3f4;
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .cg-archive-badge-filter-toggle.has-active-filter .cg-archive-filter-reset-icon {
    color: #ef4444;
}

[data-theme="dark"] .cg-archive-badge-filter-toggle.has-active-filter:hover .cg-archive-filter-reset-icon {
    color: #f87171;
}
