/*
GeoRankle Autocomplete 7.0

Clean light autocomplete panel for country search.

Used by:
- autocomplete.js
- #countryInput
- #autocompleteBox

Design:
- Always light, independent of system dark mode
- White suggestion rows
- Soft yellow only for hover and active selection
- Clear keyboard focus and mobile support
*/

.autocomplete-wrapper {
    position: relative;

    width: 100%;
    min-width: 0;
}

.autocomplete-wrapper input {
    width: 100%;
    min-width: 0;
}

/* =========================================================
   Suggestion panel
   ========================================================= */

.autocomplete-box {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 1000;

    display: none;

    width: 100%;
    max-height: min(320px, 50vh);

    margin: 0;
    padding: 6px;

    overflow-x: hidden;
    overflow-y: auto;

    border: 1px solid #dfe7ef;
    border-radius: 18px;

    background: rgba(255, 255, 255, 0.99);
    color-scheme: light;

    box-shadow:
        0 24px 52px rgba(15, 23, 42, 0.18),
        0 8px 18px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.98);

    overscroll-behavior: contain;
    scrollbar-gutter: stable;

    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.autocomplete-box.is-open {
    display: block;
}

/* =========================================================
   Suggestion item
   ========================================================= */

.autocomplete-item,
.guess-section .autocomplete-item,
.game-controls .autocomplete-item,
.guess-controls .autocomplete-item {
    position: relative;

    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;
    min-width: 0;
    min-height: 50px;

    margin: 0;
    padding: 10px 13px;

    overflow: hidden;

    border: 1px solid transparent;
    border-radius: 12px;

    appearance: none;
    -webkit-appearance: none;

    background: #ffffff;
    color: #253247;

    font: inherit;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    text-align: left;

    cursor: pointer;

    box-shadow: none;
    filter: none;
    text-shadow: none;

    transform: none;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

/*
Prevent primary-button decoration inherited from ui.css.
*/

.autocomplete-item::before,
.guess-section .autocomplete-item::before,
.game-controls .autocomplete-item::before,
.guess-controls .autocomplete-item::before {
    display: none;
}

/*
Subtle row divider.
*/

.autocomplete-item::after {
    content: "";

    position: absolute;
    right: 13px;
    bottom: 0;
    left: 57px;

    height: 1px;

    background: #edf1f5;

    pointer-events: none;
}

.autocomplete-item:last-child::after {
    display: none;
}

/* =========================================================
   Hover
   ========================================================= */

.autocomplete-item:hover:not(:disabled),
.guess-section .autocomplete-item:hover:not(:disabled),
.game-controls .autocomplete-item:hover:not(:disabled),
.guess-controls .autocomplete-item:hover:not(:disabled) {
    border-color: #f1df93;

    background:
        linear-gradient(
            90deg,
            #fffef7,
            #fffbe8
        );

    color: #1f2937;

    box-shadow:
        0 4px 12px rgba(245, 196, 0, 0.08);

    filter: none;
    transform: translateX(1px);
}

/* =========================================================
   Keyboard-active / selected row
   ========================================================= */

.autocomplete-item.active,
.autocomplete-item[aria-selected="true"],
.guess-section .autocomplete-item.active,
.guess-section .autocomplete-item[aria-selected="true"],
.game-controls .autocomplete-item.active,
.game-controls .autocomplete-item[aria-selected="true"],
.guess-controls .autocomplete-item.active,
.guess-controls .autocomplete-item[aria-selected="true"] {
    border-color: #efd052;

    background:
        linear-gradient(
            90deg,
            #fff8cb,
            #fffdf2
        );

    color: #1f2937;

    box-shadow:
        inset 4px 0 0 #ffd400,
        0 5px 14px rgba(245, 196, 0, 0.1);

    filter: none;
    transform: none;
}

.autocomplete-item.active:hover,
.autocomplete-item[aria-selected="true"]:hover {
    border-color: #e7c42b;

    background:
        linear-gradient(
            90deg,
            #fff5b8,
            #fffbe3
        );
}

/* =========================================================
   Focus and disabled
   ========================================================= */

.autocomplete-item:focus {
    outline: none;
}

.autocomplete-item:focus-visible {
    z-index: 1;

    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: -2px;
}

.autocomplete-item:disabled {
    cursor: default;
    opacity: 0.52;
    transform: none;
}

/* =========================================================
   Flag
   ========================================================= */

.autocomplete-item img {
    display: block;
    flex: 0 0 auto;

    width: 32px;
    height: 21px;

    object-fit: cover;

    border: 1px solid rgba(15, 23, 42, 0.09);
    border-radius: 5px;

    background: #f8fafc;

    box-shadow:
        0 2px 6px rgba(15, 23, 42, 0.14);
}

/* =========================================================
   Country name
   ========================================================= */

.autocomplete-item span {
    min-width: 0;

    overflow: hidden;

    color: inherit;

    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   Empty / information state
   ========================================================= */

.autocomplete-empty,
.autocomplete-message {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 50px;
    padding: 12px 14px;

    color: #64748b;
    background: #ffffff;

    font-size: 14px;
    font-weight: 750;
    line-height: 1.35;
    text-align: center;
}

/* =========================================================
   Scrollbar
   ========================================================= */

.autocomplete-box {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.autocomplete-box::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-box::-webkit-scrollbar-track {
    background: transparent;
}

.autocomplete-box::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;

    background: #cbd5e1;
    background-clip: padding-box;
}

.autocomplete-box::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
    background-clip: padding-box;
}

/* =========================================================
   Force light appearance even when the OS uses dark mode
   ========================================================= */

@media (prefers-color-scheme: dark) {
    .autocomplete-box {
        border-color: #dfe7ef;

        background: rgba(255, 255, 255, 0.99);
        color-scheme: light;

        box-shadow:
            0 24px 52px rgba(15, 23, 42, 0.22),
            0 8px 18px rgba(15, 23, 42, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.98);
    }

    .autocomplete-item,
    .guess-section .autocomplete-item,
    .game-controls .autocomplete-item,
    .guess-controls .autocomplete-item {
        border-color: transparent;

        background: #ffffff;
        color: #253247;

        box-shadow: none;
        filter: none;
        text-shadow: none;
    }

    .autocomplete-item::after {
        background: #edf1f5;
    }

    .autocomplete-item:hover:not(:disabled),
    .guess-section .autocomplete-item:hover:not(:disabled),
    .game-controls .autocomplete-item:hover:not(:disabled),
    .guess-controls .autocomplete-item:hover:not(:disabled) {
        border-color: #f1df93;

        background:
            linear-gradient(
                90deg,
                #fffef7,
                #fffbe8
            );

        color: #1f2937;

        box-shadow:
            0 4px 12px rgba(245, 196, 0, 0.08);
    }

    .autocomplete-item.active,
    .autocomplete-item[aria-selected="true"],
    .guess-section .autocomplete-item.active,
    .guess-section .autocomplete-item[aria-selected="true"],
    .game-controls .autocomplete-item.active,
    .game-controls .autocomplete-item[aria-selected="true"],
    .guess-controls .autocomplete-item.active,
    .guess-controls .autocomplete-item[aria-selected="true"] {
        border-color: #efd052;

        background:
            linear-gradient(
                90deg,
                #fff8cb,
                #fffdf2
            );

        color: #1f2937;

        box-shadow:
            inset 4px 0 0 #ffd400,
            0 5px 14px rgba(245, 196, 0, 0.1);
    }

    .autocomplete-item img {
        border-color: rgba(15, 23, 42, 0.09);
        background: #f8fafc;
    }

    .autocomplete-empty,
    .autocomplete-message {
        color: #64748b;
        background: #ffffff;
    }

    .autocomplete-box {
        scrollbar-color: #cbd5e1 transparent;
    }

    .autocomplete-box::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        background-clip: padding-box;
    }

    .autocomplete-box::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
        background-clip: padding-box;
    }
}

/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 768px) {
    .autocomplete-box {
        top: calc(100% + 6px);

        max-height: min(260px, 42vh);

        padding: 5px;

        border-radius: 15px;
    }

    .autocomplete-item,
    .guess-section .autocomplete-item,
    .game-controls .autocomplete-item,
    .guess-controls .autocomplete-item {
        gap: 10px;

        min-height: 48px;

        padding: 9px 11px;

        border-radius: 11px;

        font-size: 14px;
    }

    .autocomplete-item::after {
        right: 11px;
        left: 50px;
    }

    .autocomplete-item img {
        width: 29px;
        height: 19px;

        border-radius: 4px;
    }
}

/* =========================================================
   Small mobile screens
   ========================================================= */

@media (max-width: 420px) {
    .autocomplete-box {
        max-height: min(240px, 40vh);
    }

    .autocomplete-item,
    .guess-section .autocomplete-item,
    .game-controls .autocomplete-item,
    .guess-controls .autocomplete-item {
        min-height: 46px;
        padding: 8px 10px;
    }
}

/* =========================================================
   High contrast
   ========================================================= */

@media (prefers-contrast: more) {
    .autocomplete-box {
        border-width: 2px;
        border-color: #64748b;
    }

    .autocomplete-item.active,
    .autocomplete-item[aria-selected="true"] {
        border-width: 2px;
        border-color: #8a6f00;

        box-shadow:
            inset 5px 0 0 #ffd400;
    }
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .autocomplete-item {
        transition: none;
    }

    .autocomplete-item:hover {
        transform: none;
    }
}