/*
 * Topic search on the profile page (About You > Interest topics), js/profile-topic-search.js.
 * The results are the page's own .interest-chip chips, so a found topic looks exactly like it
 * does in the list below; this file adds the bar, the filters, the groups and the Undo note.
 */

/* The topics box: shown from the start (the search works before any subcategory is picked) */
#about-you-tab .interest-fields.has-topic-search {
    display: flex;
    position: relative;
}

/* A subcategory has 20 to 60 topics: about five rows show before the list scrolls (the
   page's own rule shows three) */
@media screen and (min-width: 769px) {
    #about-you-tab .interest-fields.has-topic-search #profileInterestChips {
        max-height: 206px;
    }
}

@media screen and (max-width: 768px) {
    #about-you-tab .interest-fields.has-topic-search #profileInterestChips {
        max-height: 236px;
    }
}

/* While searching, the results take the chips' place */
#about-you-tab .interest-fields.is-searching #profileInterestChips,
#about-you-tab .interest-fields.pts-none #profileInterestChips,
#about-you-tab .interest-fields.pts-none .interest-count {
    display: none;
}

#about-you-tab .pts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* ---- The bar: a pill like the Reviews tab's search ---------------------------------------- */
#about-you-tab .pts-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    padding: 0 7px 0 40px;
    border: 1.5px solid #d6e5e2;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
    cursor: text;
    scroll-margin-top: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#about-you-tab .pts-bar:hover {
    border-color: #b5d8d2;
}

#about-you-tab .pts-bar:focus-within {
    border-color: #11a191;
    box-shadow: 0 0 0 4px rgba(17, 161, 145, 0.13), 0 8px 22px -8px rgba(17, 161, 145, 0.3);
}

#about-you-tab .pts-bar.is-disabled {
    background: #f6f8f9;
    border-color: #e1e7eb;
    cursor: default;
}

#about-you-tab .pts-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    width: 17px;
    height: 17px;
    color: #11a191;
    transform: translateY(-50%);
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

#about-you-tab .pts-bar:focus-within .pts-icon {
    transform: translateY(-50%) rotate(-10deg) scale(1.1);
}

#about-you-tab .pts-bar.is-disabled .pts-icon {
    color: #a9b8bd;
}

#about-you-tab .pts-bar .pts-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    outline: none;
    background: transparent;
    box-shadow: none;
    font: inherit;
    font-size: 0.9rem;
    color: #1f2d2b;
    text-overflow: ellipsis;
}

#about-you-tab .pts-bar .pts-input::placeholder {
    color: #8a9c9a;
    opacity: 1;
}

#about-you-tab .pts-bar .pts-input:disabled {
    cursor: default;
}

/* "12 topics" while searching */
#about-you-tab .pts-meta {
    flex: none;
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: #e3f4f1;
    color: #0b6a5f;
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#about-you-tab .pts-meta:empty {
    display: none;
}

#about-you-tab .pts-clear {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b7f7c;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.25s ease;
}

#about-you-tab .pts-clear[hidden] {
    display: none;
}

#about-you-tab .pts-clear svg {
    width: 14px;
    height: 14px;
}

#about-you-tab .pts-clear:hover {
    background: #11a191;
    color: #fff;
    transform: rotate(90deg);
}

#about-you-tab .pts-clear:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.3);
}

#about-you-tab .pts-kbd {
    flex: none;
    margin-right: 7px;
    padding: 3px 7px;
    border: 1px solid #d5e2e0;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #fff;
    color: #7b8f8d;
    font: 600 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#about-you-tab .pts-bar:focus-within .pts-kbd,
#about-you-tab .pts-bar.has-query .pts-kbd,
#about-you-tab .pts-bar.is-disabled .pts-kbd {
    display: none;
}

/* ---- Filters: All, Your subcategories, Your picks | each category ------------------------- */
#about-you-tab .pts-facets {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 -2px;
    padding: 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

#about-you-tab .pts-facets::-webkit-scrollbar {
    display: none;
}

#about-you-tab .pts-facets[hidden] {
    display: none;
}

#about-you-tab .pts-facets.fade-right {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

#about-you-tab .pts-facets.fade-left {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
}

#about-you-tab .pts-facets.fade-left.fade-right {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

#about-you-tab .pts-facet {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border: 1px solid #dbe3e8;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    color: #475569;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

#about-you-tab .pts-facet:hover {
    border-color: rgba(17, 161, 145, 0.55);
    color: #0b6a5f;
}

#about-you-tab .pts-facet:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.25);
}

#about-you-tab .pts-facet.is-on {
    border-color: #11a191;
    background: #e5f6f3;
    color: #0b6a5f;
    font-weight: 600;
}

#about-you-tab .pts-facet-n {
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#about-you-tab .pts-facet.is-on .pts-facet-n {
    color: #0d7f73;
}

#about-you-tab .pts-facet-sep {
    flex: none;
    width: 1px;
    height: 18px;
    margin: 0 2px;
    background: #d9e1e6;
}

/* ---- Results: grouped by subcategory ------------------------------------------------------ */
#about-you-tab .pts-results {
    max-height: 236px;
    margin: 0 -2px;
    padding: 2px 2px 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(17, 161, 145, 0.35) transparent;
    animation: pts-in 0.18s ease both;
}

#about-you-tab .pts-results[hidden] {
    display: none;
}

#about-you-tab .pts-results.fade-bottom {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
}

#about-you-tab .pts-results.fade-top {
    -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to top, #000 calc(100% - 22px), transparent);
}

#about-you-tab .pts-results.fade-top.fade-bottom {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22px, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 22px, #000 calc(100% - 22px), transparent);
}

@keyframes pts-in {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: none; }
}

#about-you-tab .pts-group + .pts-group {
    margin-top: 12px;
}

#about-you-tab .pts-group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0 0 7px;
    padding: 0 1px;
    font-size: 0.74rem;
    line-height: 1.3;
}

#about-you-tab .pts-group-name {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    color: #334155;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#about-you-tab .pts-group-cat {
    flex: 0 100 auto;
    min-width: 0;
    overflow: hidden;
    color: #94a3b8;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#about-you-tab .pts-group-cat::before {
    content: "\00b7";
    margin-right: 6px;
}

#about-you-tab .pts-group-tag {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    margin-left: auto;
    padding: 0 8px 0 6px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}

#about-you-tab .pts-group-tag:empty {
    display: none;
}

#about-you-tab .pts-group-tag svg {
    width: 12px;
    height: 12px;
}

#about-you-tab .pts-tag-short {
    display: none;
}

#about-you-tab .pts-group-tag.is-own {
    background: rgba(17, 161, 145, 0.1);
    color: #0b6a5f;
}

#about-you-tab .pts-group-tag.is-new {
    background: rgba(99, 88, 214, 0.09);
    color: #5146b8;
}

#about-you-tab .pts-group-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

/* The words that matched */
#about-you-tab .pts-chip mark {
    padding: 0;
    border-radius: 3px;
    background: rgba(17, 161, 145, 0.18);
    color: inherit;
    box-shadow: 0 0 0 1px rgba(17, 161, 145, 0.18);
}

#about-you-tab .pts-chip.is-top mark {
    background: rgba(255, 255, 255, 0.28);
    box-shadow: none;
}

/* The chip the arrow keys are on */
#about-you-tab .pts-chip.is-active {
    border-color: #11a191;
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.28);
}

#about-you-tab .pts-chip.is-top.is-active {
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.38);
}

/* "+5 more": the rest of a subcategory that is named like the search */
#about-you-tab .pts-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 10px 0 13px;
    border: 1px dashed rgba(17, 161, 145, 0.5);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    color: #0d7f73;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

#about-you-tab .pts-more svg {
    width: 13px;
    height: 13px;
}

#about-you-tab .pts-more:hover {
    border-color: #11a191;
    background: rgba(17, 161, 145, 0.08);
}

#about-you-tab .pts-more.is-active {
    border-style: solid;
    border-color: #11a191;
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.28);
}

/* ---- Messages ------------------------------------------------------------------------------ */
#about-you-tab .pts-msg[hidden],
#about-you-tab .pts-start[hidden] {
    display: none;
}

#about-you-tab .pts-fuzzy {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 0 2px;
    color: #64748b;
    font-size: 0.76rem;
    line-height: 1.4;
}

#about-you-tab .pts-fuzzy svg {
    flex: none;
    width: 15px;
    height: 15px;
    color: #11a191;
}

#about-you-tab .pts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 14px 12px 10px;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.45;
    text-align: center;
}

#about-you-tab .pts-empty svg {
    width: 30px;
    height: 30px;
    margin-bottom: 4px;
    color: #9cbab5;
}

#about-you-tab .pts-empty b {
    max-width: 100%;
    overflow: hidden;
    color: #334155;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#about-you-tab .pts-start {
    margin: 0;
    padding: 0 4px;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.45;
}

/* ---- "Also added … · Undo" ---------------------------------------------------------------- */
#about-you-tab .pts-note {
    position: absolute;
    left: 50%;
    bottom: 12px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 6px 6px 6px 10px;
    border-radius: 12px;
    background: #12302c;
    color: #d8efeb;
    font-size: 0.78rem;
    line-height: 1.35;
    box-sizing: border-box;
    box-shadow: 0 14px 32px -12px rgba(15, 23, 42, 0.55), 0 2px 6px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 8px);
    transition: opacity 0.18s ease, transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.24s;
}

#about-you-tab .pts-note.is-on {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}

#about-you-tab .pts-note-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #11a191;
    color: #fff;
}

#about-you-tab .pts-note-icon svg {
    width: 12px;
    height: 12px;
}

#about-you-tab .pts-note-text {
    min-width: 0;
}

#about-you-tab .pts-note-text b {
    color: #fff;
    font-weight: 600;
}

#about-you-tab .pts-undo {
    flex: none;
    height: 28px;
    padding: 0 11px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #5eead4;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.16s ease;
}

#about-you-tab .pts-undo:hover {
    background: rgba(255, 255, 255, 0.2);
}

#about-you-tab .pts-undo:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #5eead4;
}

#about-you-tab .pts-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
}

/* ---- Phones ---------------------------------------------------------------------------------- */
@media screen and (max-width: 768px) {
    #about-you-tab .pts-bar {
        height: 46px;
    }

    #about-you-tab .pts-facet {
        height: 32px;
    }

    /* As tall as the chips there (36px) */
    #about-you-tab .pts-more {
        height: 36px;
    }

    #about-you-tab .pts-results {
        max-height: min(52vh, 340px);
    }

    /* The subcategory's name needs the width; its category is in the filters above, and the
       tag says "Yours" / "New" */
    #about-you-tab .pts-group-cat,
    #about-you-tab .pts-tag-long {
        display: none;
    }

    #about-you-tab .pts-tag-short {
        display: inline;
    }

    #about-you-tab .pts-note {
        bottom: 10px;
        width: calc(100% - 20px);
        max-width: none;
    }
}

/* Touch screens: no "/" key to show, and iOS zooms into a field under 16px */
@media (hover: none) {
    #about-you-tab .pts-kbd {
        display: none;
    }

    #about-you-tab .pts-bar .pts-input {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #about-you-tab .pts-bar,
    #about-you-tab .pts-icon,
    #about-you-tab .pts-clear,
    #about-you-tab .pts-facet,
    #about-you-tab .pts-more,
    #about-you-tab .pts-undo,
    #about-you-tab .pts-note {
        transition: none;
    }

    #about-you-tab .pts-results {
        animation: none;
    }

    #about-you-tab .pts-bar:focus-within .pts-icon {
        transform: translateY(-50%);
    }

    #about-you-tab .pts-clear:hover {
        transform: none;
    }
}
