/* ==========================================================================
   SEARCH TAB
   The matches inside Potify, and the way out to YouTube and SoundCloud. The
   outside results reuse the .search-* rules in style.css; everything here is
   .sx-*. All colour comes from the profile's --accent.
   ========================================================================== */

/* ---------- The box ---------- */
.sx-box {
    position: relative;
    margin-top: 4px;
}
.sx-box input[type="text"] {
    display: block;
    width: 100%;
    height: 50px;
    padding: 0 48px 0 44px;
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 25px;
    font-family: inherit;
    font-size: 16px;                 /* under 16px and iOS zooms in on focus */
}
.sx-box input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}
.sx-box-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--fg-3);
    pointer-events: none;
    transition: color 0.2s;
}
.sx-box:focus-within .sx-box-icon { color: var(--accent); }
.sx-clear {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    padding: 0;
    display: grid;
    place-items: center;
    background: rgba(var(--tint-rgb), 0.08);
    color: var(--fg-2);
    border-radius: 50%;
}
.sx-clear:hover { background: rgba(var(--tint-rgb), 0.16); color: var(--fg); }
.sx-clear.hidden { display: none; }

/* ---------- Before anything is typed ---------- */
.sx-intro { margin-top: 18px; }
.sx-intro.hidden { display: none; }
.sx-hint {
    margin-top: 34px;
    padding: 0 18px;
    text-align: center;
    color: var(--fg-3);
}
.sx-hint .icon { color: var(--accent); opacity: 0.8; }
.sx-hint p { margin: 10px auto 0; max-width: 320px; font-size: 0.88rem; line-height: 1.45; }
.sx-recent.hidden { display: none; }
.sx-recent-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.sx-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-3);
}
.sx-recent-head .text-btn { padding: 0; }
.sx-recent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sx-chip {
    max-width: 100%;
    min-height: 36px;
    padding: 0 14px;
    background: var(--surface-2);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, transform 0.1s;
}
.sx-chip:hover { border-color: rgba(var(--accent-rgb), 0.6); color: var(--accent); }
.sx-chip:active { transform: scale(0.96); }

/* ---------- Matches inside Potify ---------- */
#sx-local.hidden, .sx-section.hidden, .sx-none.hidden, .sx-more.hidden { display: none; }
.sx-section { margin-top: 20px; }
.sx-section .section-title { margin-bottom: 8px; }
.sx-count { font-weight: 500; color: var(--fg-3); }
.sx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sx-row {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 10px;
    transition: background 0.15s;
}
.sx-row:hover { background: var(--hover); }
/* Same stacked-cards cover as on the Playlists tab: a playlist, not a song. */
.sx-row-playlist .list-cover {
    border-radius: 10px;
    margin: 6px 6px 0 0;
    box-shadow:
        3px -3px 0 -1px var(--bg),
        3px -3px 0 0 var(--fg-4),
        6px -6px 0 -1px var(--bg),
        6px -6px 0 0 rgba(var(--tint-rgb), 0.16);
}
.sx-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 8px;
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    font-weight: normal;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
}
.sx-main:active { transform: scale(0.99); }
.sx-main:focus-visible, .sx-row .row-action-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sx-cover-blank {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--surface-3);
    color: var(--fg-3);
}
.sx-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sx-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--fg);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.sx-sub { font-size: 0.78rem; color: var(--fg-2); }
.sx-hit {
    background: none;
    color: var(--accent);
    font-weight: 700;
}
.sx-go { flex: 0 0 auto; margin-left: auto; color: var(--fg-3); }
.sx-row.is-playing .sx-title { color: var(--accent); }
.sx-row.is-playing { background: rgba(var(--accent-rgb), 0.1); }
.sx-more { margin-top: 6px; padding: 6px 8px; }
.sx-none {
    margin: 26px 0 0;
    text-align: center;
    color: var(--fg-2);
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

/* ---------- The way out ---------- */
.sx-outside { margin-top: 22px; }
.sx-outside.hidden { display: none; }
.sx-outside-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color 0.2s, background 0.2s;
}
/* When Potify had nothing, this is the next step rather than a footnote. */
.sx-outside-card.is-primary {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: rgba(var(--accent-rgb), 0.45);
}
.sx-outside-text { display: flex; flex-direction: column; gap: 3px; }
.sx-outside-title { font-size: 1rem; font-weight: 700; color: var(--fg); }
.sx-outside-sub { font-size: 0.85rem; line-height: 1.35; color: var(--fg-2); overflow-wrap: anywhere; }
.sx-outside-card .search-sources { margin-top: 0; }
.sx-outside-card .success-btn { height: 46px; padding: 0 20px; }
.sx-outside-card .success-btn:disabled { opacity: 0.55; cursor: default; }
.sx-outside .search-panel { margin-top: 14px; }

/* "Don't have a link? Search for it" on the Upload tab. */
.inline-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.inline-link:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
    .sx-row, .sx-chip, .sx-outside-card, .sx-box-icon { transition: none; }
}

/* ---------- Search at the top of the Library ---------- */
.library-search {
    max-width: 760px;
    margin-bottom: 18px;
}
/* The tab used to open on this hint; the Library below says it instead. */
.library-search .sx-hint { display: none; }
/* Your library / Potipository: two halves, with a pill that slides to the
   chosen one. */
.sx-scope {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    margin: 10px 0 4px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
}
.sx-scope-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: var(--r-pill);
    background: var(--sheet);
    box-shadow: var(--shadow-1);
    transition: transform 0.45s var(--ease-spring);
}
.sx-scope[data-scope="all"] .sx-scope-thumb {
    transform: translateX(100%);
}
.sx-scope-btn {
    position: relative;
    z-index: 1;
    padding: 7px 16px;
    background: transparent;
    color: var(--fg-3);
    border-radius: var(--r-pill);
    font-size: 0.82rem;
    font-weight: 700;
    transition: color 0.2s;
}
.sx-scope-btn:hover { background: transparent; color: var(--fg-2); }
.sx-scope-btn[aria-checked="true"] { color: var(--fg); }
.sx-widen { margin: 4px 0 0 -8px; }
