/* X10 game search UI — autocomplete panel + results view.
   Companion of x10-search.js; reuses the lobby tokens from x10-lobby-skin.css
   (--casino-card, --casino-accent, --x10-tile-radius, --x10-card-w). */

/* ── Search box additions ────────────────────────────────────── */

body .x10-search-box { position: relative; }
body .x10-search-input[aria-controls="x10-sx-panel"] { padding-right: 42px; }

.x10-sx-clearbtn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
}
.x10-sx-clearbtn[hidden] { display: none; }
.x10-sx-clearbtn:hover { background: rgba(233,167,34,.2); color: var(--casino-accent, #E9A722); }
.x10-sx-clearbtn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.x10-sx-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Autocomplete panel ──────────────────────────────────────── */

.x10-sx-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 300;
    max-height: 70vh;
    max-height: min(520px, 62dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: #0B1E33;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0,0,0,.55);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}
.x10-sx-panel[hidden] { display: none; }

.x10-sx-label {
    padding: 8px 10px 4px;
    color: rgba(255,255,255,.55);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.x10-sx-note {
    margin: 2px 4px 4px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(233,167,34,.12);
    color: #F2D58C;
    font-size: 12px;
    font-weight: 600;
}

.x10-sx-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 6px 10px;
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease;
}
.x10-sx-opt.is-active,
.x10-sx-opt:hover { background: rgba(255,255,255,.07); }
.x10-sx-opt.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 3px;
    background: var(--casino-accent, #E9A722);
}
.x10-sx-opt:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

.x10-sx-thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--casino-card, #1B324E);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
.x10-sx-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.x10-sx-provicon {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(233,167,34,.14);
    color: var(--casino-accent, #E9A722);
}

.x10-sx-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.x10-sx-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}
.x10-sx-title b { color: var(--casino-accent, #E9A722); font-weight: 800; }
.x10-sx-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255,255,255,.62);
    font-size: 11px;
    font-weight: 500;
}
.x10-sx-go { color: rgba(255,255,255,.5); font-size: 20px; line-height: 1; }
.x10-sx-tag {
    padding: 2px 6px;
    border-radius: 6px;
    background: #E5383B;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .04em;
}

.x10-sx-all {
    position: sticky;
    bottom: -6px;
    z-index: 1;
    justify-content: center;
    min-height: 46px;
    margin: 4px -6px -6px;
    padding: 0 16px;
    background: #0B1E33;
    border-top: 1px solid rgba(255,255,255,.1);
    border-radius: 0 0 13px 13px;
    color: var(--casino-accent, #E9A722);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.x10-sx-state { padding: 18px 14px; text-align: center; color: rgba(255,255,255,.7); font-size: 12px; }
.x10-sx-state p { margin: 0 0 10px; }
.x10-sx-state-title { color: #fff; font-size: 14px; font-weight: 700; }

.x10-sx-btn {
    min-height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: var(--casino-accent, #E9A722);
    color: #001021;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 160ms ease;
}
.x10-sx-btn:hover { background: var(--casino-accent-hover, #F2B94A); }
.x10-sx-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.x10-sx-btn--ghost { background: rgba(255,255,255,.08); color: #fff; }
.x10-sx-btn--ghost:hover { background: rgba(255,255,255,.14); }

/* Loading skeleton */
.x10-sx-skel { display: flex; align-items: center; gap: 12px; height: 52px; padding: 6px 10px; }
.x10-sx-skel-thumb,
.x10-sx-skel-lines i,
.x10-sx-skelcard-img,
.x10-sx-skelcard i {
    display: block;
    background: linear-gradient(110deg, #142538 20%, #1D3550 48%, #142538 75%);
    background-size: 240% 100%;
    animation: x10-sx-shimmer 1.4s ease-in-out infinite;
}
.x10-sx-skel-thumb { width: 48px; height: 40px; border-radius: 8px; }
.x10-sx-skel-lines { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.x10-sx-skel-lines i { height: 8px; width: 70%; border-radius: 4px; }
.x10-sx-skel-lines i + i { width: 40%; height: 6px; }
@keyframes x10-sx-shimmer { from { background-position: 200% 0; } to { background-position: -20% 0; } }

/* ── Results view ────────────────────────────────────────────── */

.x10-casino-container.x10-sx-active > :not(.x10-search-wrapper):not(#x10-sx-results) { display: none !important; }

.x10-sx-results { padding-bottom: 24px; }

.x10-sx-rhead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 12px;
}
.x10-sx-rtitle {
    margin: 0;
    font-size: clamp(15px, 2vw, 20px);
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.x10-sx-rcount { margin: 4px 0 0; color: rgba(255,255,255,.65); font-size: 12px; font-weight: 600; }

.x10-sx-rnote {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(233,167,34,.12);
    color: #F2D58C;
    font-size: 12px;
    font-weight: 600;
}

.x10-sx-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.x10-sx-chiplabel { color: rgba(255,255,255,.55); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.x10-sx-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--casino-card, #1B324E);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease;
}
.x10-sx-chip small { color: var(--casino-accent, #E9A722); font-size: 11px; font-weight: 800; }
.x10-sx-chip:hover { background: var(--casino-card-hover, #234062); }
.x10-sx-chip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

body .x10-sx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--x10-card-w, 112px), 1fr));
    gap: 18px 10px;
}
@media (max-width: 479px) {
    body .x10-sx-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 8px; }
}
body .x10-sx-grid .x10-game-card { width: 100%; min-width: 0; max-width: none; }

.x10-sx-skelcard { display: flex; flex-direction: column; gap: 6px; }
.x10-sx-skelcard-img { width: 100%; aspect-ratio: 5 / 4; border-radius: var(--x10-tile-radius, 12px); }
.x10-sx-skelcard i { height: 8px; width: 80%; border-radius: 4px; }
.x10-sx-skelcard i + i { width: 50%; height: 6px; }

.x10-sx-rstate {
    padding: 36px 16px;
    border-radius: var(--x10-tile-radius, 12px);
    background: var(--casino-card, #1B324E);
    text-align: center;
    color: rgba(255,255,255,.7);
    font-size: 13px;
}
.x10-sx-rstate[hidden] { display: none; }
.x10-sx-rstate p { margin: 0 0 12px; }

@media (prefers-reduced-motion: reduce) {
    .x10-sx-skel-thumb,
    .x10-sx-skel-lines i,
    .x10-sx-skelcard-img,
    .x10-sx-skelcard i { animation: none; }
    .x10-sx-opt, .x10-sx-chip, .x10-sx-btn, .x10-sx-clearbtn { transition: none; }
}

/* The legacy "Results · N games" line counts lobby cards only; the results view has its own accurate count. */
.x10-casino-container.x10-sx-active .x10-results-summary { display: none; }

/* Result cards carry data-src (the favourites code reads it to save the artwork URL),
   but they load eagerly via src, so cancel the lobby's blur-until-lazy-loaded rule. */
body .x10-sx-grid .x10-game-image[data-src] { filter: none; transform: none; }
body .x10-sx-grid .x10-game-link:hover .x10-game-image[data-src] { transform: scale(1.05); }

@media (max-width: 400px) {
    .x10-sx-all { font-size: 11px; letter-spacing: 0; padding: 0 10px; line-height: 1.25; }
}

/* Artwork that genuinely failed to load: neutral tile instead of an endless skeleton. */
body .x10-sx-grid .x10-game-thumb.x10-image-failed {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23ffffff' stroke-opacity='.35' stroke-width='2.5' stroke-linejoin='round'%3E%3Ccircle cx='24' cy='24' r='15'/%3E%3Cpath d='M20 17.5v13l11-6.5z'/%3E%3C/svg%3E") center / 34% no-repeat,
        radial-gradient(ellipse at 50% 40%, #234062 0%, var(--casino-card, #1B324E) 70%);
}
body .x10-sx-grid .x10-game-thumb.x10-image-failed .x10-game-image { visibility: hidden; }
body .x10-sx-grid .x10-game-thumb.x10-image-failed::after { display: none; }

/* Provider scope chips (buttons) + lobby links */
button.x10-sx-chip { border: 0; font-family: inherit; cursor: pointer; }
.x10-sx-chip.is-on { background: var(--casino-accent, #E9A722); color: #001021; }
.x10-sx-chip.is-on small { color: #001021; }
.x10-sx-chip--link { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18); color: rgba(255,255,255,.85); }
.x10-sx-chip--link:hover { background: rgba(255,255,255,.07); }
