/**
 * Sihtkoha otsing: riik, piirkond või hotell ühest väljast.
 *
 * Kasutab vanemteema dropdown-muutujaid (--th-dropdown-*), et
 * väli ja vasted näeksid välja täpselt nagu ülejäänud
 * otsinguvorm. Vaste ise on .field-dropdown-option, nii et
 * hover ja valitud olek tulevad vanemteemast - siin on ainult
 * see, mida juurde on vaja.
 */


/* ==================================================
OTSINGUVÄLI
================================================== */

.th-destination-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;

    margin: 12px 12px 4px;
    padding: 0 12px;

    border: 1px solid var(--th-dropdown-border, #d8e0e3);
    border-radius: 12px;
    background: #fff;

    transition: border-color .2s ease, box-shadow .2s ease;
}

.th-destination-search:focus-within {
    border-color: var(--th-dropdown-accent, #e67536);
    box-shadow: 0 0 0 3px rgba(230, 117, 54, .12);
}

.th-destination-search-icon {
    display: flex;
    flex: 0 0 18px;
    color: #8a98a7;
}

.th-destination-search-icon svg {
    width: 18px;
    height: 18px;
}

.th-destination-search-input {
    flex: 1 1 auto;
    min-width: 0;

    height: 44px;
    padding: 0;

    border: 0;
    background: transparent;

    color: var(--th-dropdown-text, #173743);
    font: inherit;
    font-size: 15px;
}

.th-destination-search-input:focus {
    outline: none;
}

.th-destination-search-input::placeholder {
    color: #8a98a7;
}

/* Brauseri oma ristike läheks meie omaga topelt. */
.th-destination-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.th-destination-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    padding: 0;

    border: 0;
    border-radius: 50%;
    background: #eef2f4;

    color: #5d6f79;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;

    transition: background .2s ease, color .2s ease;
}

.th-destination-search-clear:hover {
    background: var(--th-dropdown-selected, #fcf0ea);
    color: var(--th-dropdown-accent, #e67536);
}

.th-destination-search-clear[hidden] {
    display: none;
}


/* Laadimise vihje: õhuke riba välja all. */
.th-destination-search::after {
    content: "";

    position: absolute;
    right: 12px;
    bottom: -1px;
    left: 12px;
    height: 2px;

    border-radius: 2px;
    background: var(--th-dropdown-accent, #e67536);

    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    transition: opacity .2s ease;
}

.th-destination-search.is-loading::after {
    opacity: .45;
    animation: th-destination-loading 1s ease-in-out infinite;
}

@keyframes th-destination-loading {
    0%   { transform: scaleX(0);   transform-origin: left center; }
    50%  { transform: scaleX(1);   transform-origin: left center; }
    100% { transform: scaleX(0);   transform-origin: right center; }
}

@media (prefers-reduced-motion: reduce) {

    .th-destination-search.is-loading::after {
        animation: none;
        transform: scaleX(1);
    }
}


/* ==================================================
VASTED
================================================== */

.th-destination-results {
    max-height: 340px;
    padding: 4px 8px 8px;
    overflow-y: auto;
}

.th-destination-results[hidden] {
    display: none;
}

/*
 * Rubriigisilt on sama mis tavaloendis ("Populaarsed
 * sihtkohad"), aga vastete vahel ei ole 25px õhku vaja.
 */
.th-destination-results .th-popular-destination-label {
    padding: 14px 16px 6px !important;
    text-align: left !important;
}

.th-destination-results .th-popular-destination-label:first-child {
    padding-top: 6px !important;
}


/*
 * Vaste.
 *
 * Nupu tekst on ainult nimi, sest vanemteema võtab nähtava
 * väärtuse option.textContent'ist. Asukoht ja tärnid tulevad
 * ::after kaudu data-meta pealt - pseudoelement ei lähe
 * textContent'i sisse.
 */
.th-destination-result {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;

    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;

    line-height: 1.3;
}

.th-destination-result[data-meta]::after {
    content: attr(data-meta);

    display: block;
    color: #8a98a7;
    font-size: 12px;
    font-weight: 400;
}

.th-destination-result.is-country {
    font-weight: 600;
}

.th-destination-result.is-hotel::after {
    color: #7d8c96;
}


.th-destination-empty {
    margin: 0;
    padding: 20px 16px;

    color: #8a98a7;
    font-size: 13px;
    text-align: center;
}


/* ==================================================
MOBIIL

Paneel on täisekraan, seega otsing jääb üles kinni ja
nimekiri kerib selle all.
================================================== */

@media (max-width: 991px) {

    .th-destination-search {
        position: sticky;
        top: 0;
        z-index: 2;

        margin: 8px 16px 4px;
    }

    .th-destination-results {
        max-height: none;
        padding: 4px 12px 16px;
    }
}
