/*
GeoRankle Results 7.6

Styles the guess history created by results.js.

Primary elements:
- .results-list / #resultsBody
- .guess-row
- .gr32-country-block
- .gr32-clues
- .gr32-distance
*/

/* =========================================================
   Results container
   ========================================================= */

.results-list,
#resultsBody {
    display: flex;
    flex-direction: column;
    gap: 10px;

    width: 100%;
    min-width: 0;
    margin: 18px 0 0;
    padding: 0;

    list-style: none;
}

/* =========================================================
   Distance unit control
   ========================================================= */

.distance-unit-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;

    width: 100%;
    margin: 14px 2px -8px;
}

.distance-unit-toolbar[hidden] {
    display: none;
}

.distance-unit-label {
    color: #64748b;

    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.distance-unit-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;

    padding: 3px;

    border: 1px solid #dbeafe;
    border-radius: 999px;

    background: #eef6ff;

    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.distance-unit-button {
    min-width: 38px;
    min-height: 27px;
    padding: 5px 10px;

    border: 0;
    border-radius: 999px;

    background: transparent;
    color: #64748b;

    font: inherit;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.03em;

    cursor: pointer;

    transition:
        background-color 0.16s ease,
        color 0.16s ease,
        box-shadow 0.16s ease,
        transform 0.16s ease;
}

.distance-unit-button:hover {
    color: #0f6fad;
}

.distance-unit-button:focus-visible {
    outline: 3px solid rgba(18, 146, 242, 0.28);
    outline-offset: 2px;
}

.distance-unit-button.is-active {
    background: #ffffff;
    color: #0878bd;

    box-shadow:
        0 2px 7px rgba(15, 23, 42, 0.12);
}

.distance-unit-button:active {
    transform: scale(0.96);
}

/* =========================================================
   Guess row
   ========================================================= */

.guess-row {
    position: relative;

    display: grid;
    grid-template-columns:
        minmax(170px, 190px)
        minmax(0, 1fr)
        minmax(150px, 170px);
    align-items: center;
    gap: 16px;

    width: 100%;
    min-width: 0;
    padding: 14px 16px;

    overflow: hidden;

    border: 1px solid #e5e7eb;
    border-left: 6px solid #ef4444;
    border-radius: 18px;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #f8fbff
        );

    color: #111827;

    box-shadow:
        0 8px 22px rgba(15, 23, 42, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);

    animation:
        geoRankleGuessRowEnter
        0.34s
        cubic-bezier(0.18, 1.25, 0.35, 1)
        both;

    transition:
        opacity 0.22s ease,
        filter 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease;
}

/* Default / far result */

.guess-row.distance-far,
.guess-row.distance-very-far {
    border-left-color: #ef4444;
}

/* Medium and close result */

.guess-row.distance-medium {
    border-left-color: #fb923c;
}

.guess-row.distance-close {
    border-left-color: #facc15;
}

/* Correct result */

.guess-row.distance-correct {
    border-color: #bbf7d0;
    border-left-color: #22c55e;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #f0fdf4
        );
}

/* Optional non-animated row */

.guess-row.is-restored {
    animation: none;
}

/* =========================================================
   Active flight and pending result
   ========================================================= */

.results-list.has-active-flight
    .guess-row:not(.is-flight-pending),
#resultsBody.has-active-flight
    .guess-row:not(.is-flight-pending) {
    opacity: 0.68;
    filter: saturate(0.72);
}

.guess-row.is-flight-pending {
    border-color: #bfdbfe;
    border-left-color: #1292f2;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #eef8ff
        );

    box-shadow:
        0 10px 26px rgba(18, 146, 242, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.guess-row.is-flight-pending
    .gr32-clues,
.guess-row.is-flight-pending
    .gr32-distance {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.gr32-flight-status {
    grid-column: 2 / -1;
    grid-row: 1;
    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    justify-self: stretch;

    min-height: 50px;
    padding: 10px 16px;

    border: 1px solid #bfdbfe;
    border-radius: 15px;

    background:
        linear-gradient(
            90deg,
            #edf8ff,
            #dff2ff,
            #edf8ff
        );

    background-size: 220% 100%;

    color: #156da8;

    font-size: 15px;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85);

    animation:
        geoRankleFlightShimmer
        1.25s
        linear
        infinite;

    transition:
        opacity 0.16s ease,
        transform 0.16s ease;
}

.gr32-flight-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;
    line-height: 1;

    animation:
        geoRankleFlightIcon
        0.9s
        ease-in-out
        infinite;
}

.guess-row:not(.is-flight-pending)
    .gr32-flight-status {
    visibility: hidden;
    opacity: 0;
    transform: translateY(-4px);
}

/* =========================================================
   Landing reveal
   ========================================================= */

.guess-row.is-result-revealing {
    opacity: 1;
    filter: none;

    box-shadow:
        0 12px 30px rgba(18, 146, 242, 0.13),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.guess-row.is-result-revealing
    .gr32-clue {
    animation:
        geoRankleClueReveal
        0.34s
        cubic-bezier(0.18, 1.2, 0.35, 1)
        both;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(1) {
    animation-delay: 0.02s;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(2) {
    animation-delay: 0.08s;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(3) {
    animation-delay: 0.14s;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(4) {
    animation-delay: 0.2s;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(5) {
    animation-delay: 0.26s;
}

.guess-row.is-result-revealing
    .gr32-clue:nth-child(6) {
    animation-delay: 0.32s;
}

.guess-row.is-result-revealing
    .gr32-distance {
    animation:
        geoRankleDistanceReveal
        0.42s
        0.26s
        cubic-bezier(0.18, 1.2, 0.35, 1)
        both;
}

.guess-row.is-result-revealing
    .distance-trend {
    animation:
        geoRankleTrendReveal
        0.3s
        0.48s
        cubic-bezier(0.18, 1.2, 0.35, 1)
        both;
}

.guess-row.is-result-revealed {
    opacity: 1;
    filter: none;
}

@keyframes geoRankleFlightShimmer {
    from {
        background-position: 100% 0;
    }

    to {
        background-position: -120% 0;
    }
}

@keyframes geoRankleFlightIcon {
    0%,
    100% {
        transform: translateX(-2px);
    }

    50% {
        transform: translateX(3px);
    }
}

@keyframes geoRankleClueReveal {
    from {
        opacity: 0;
        transform:
            translateY(7px)
            scale(0.92);
    }

    to {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

@keyframes geoRankleDistanceReveal {
    from {
        opacity: 0;
        transform:
            translateY(7px)
            scale(0.9);
    }

    to {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

@keyframes geoRankleTrendReveal {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   Country block
   ========================================================= */

.gr32-country-block {
    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;
}

.gr32-flag {
    display: block;
    flex: 0 0 auto;

    width: 48px;
    height: 32px;

    object-fit: cover;

    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 8px;

    background: #f8fafc;

    box-shadow:
        0 4px 10px rgba(15, 23, 42, 0.14);
}

.gr32-country-text {
    display: flex;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
}

.gr32-country-name {
    min-width: 0;

    overflow: hidden;

    color: #111827;

    font-size: 18px;
    font-weight: 900;
    line-height: 1.25;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.gr32-guess-label {
    color: #64748b;

    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
}

/* =========================================================
   Clue group
   ========================================================= */

.gr32-clues {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;

    min-width: 0;
}

.gr32-clue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-width: 58px;
    min-height: 38px;
    padding: 7px 11px;

    border: 1px solid #dbeafe;
    border-radius: 12px;

    background: #eef6ff;
    color: #1e3a5f;

    font-size: 15px;
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.gr32-continent {
    min-width: 128px;
}

.gr32-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    font-size: 15px;
    line-height: 1;
}

.gr32-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    min-width: 1em;

    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

/* =========================================================
   Clue indicators
   ========================================================= */

.gr32-clue.indicator-correct {
    border-color: #86efac;

    background: #dcfce7;
    color: #166534;
}

.gr32-clue.indicator-up {
    border-color: #93c5fd;

    background: #dbeafe;
    color: #1e40af;
}

.gr32-clue.indicator-down {
    border-color: #fca5a5;

    background: #fee2e2;
    color: #991b1b;
}

.gr32-clue.indicator-none,
.indicator-none {
    opacity: 0.52;
}

/* Optional equal / neutral aliases */

.gr32-clue.indicator-equal {
    border-color: #86efac;

    background: #dcfce7;
    color: #166534;
}

.gr32-clue.indicator-neutral {
    border-color: #cbd5e1;

    background: #f1f5f9;
    color: #475569;
}

/* =========================================================
   Distance badge
   ========================================================= */

.gr32-distance {
    position: relative;

    justify-self: end;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    min-width: 158px;
    min-height: 54px;
    padding: 7px 12px;

    border: 1px solid #fecaca;
    border-radius: 999px;

    background: #fee2e2;
    color: #dc2626;

    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
}

.gr32-distance.has-distance-trend {
    min-height: 68px;
    padding-bottom: 24px;
}

.distance-very-far .gr32-distance,
.distance-far .gr32-distance {
    border-color: #fecaca;

    background: #fee2e2;
    color: #dc2626;
}

.distance-medium .gr32-distance {
    border-color: #fed7aa;

    background: #ffedd5;
    color: #c2410c;
}

.distance-close .gr32-distance {
    border-color: #fde68a;

    background: #fef3c7;
    color: #a16207;
}

.distance-correct .gr32-distance {
    border-color: #86efac;

    background: #dcfce7;
    color: #15803d;
}

.distance-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    font-size: 19px;
    line-height: 1;
}

.distance-value {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;

    min-width: 62px;

    font-size: 15px;
    font-weight: 900;
    line-height: 1.05;
}

.distance-primary {
    font-size: 15px;
    font-weight: 900;
    line-height: 1.05;
}

.distance-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    min-width: 1em;

    font-size: 21px;
    font-weight: 900;
    line-height: 1;
}

.distance-trend {
    position: absolute;
    right: 12px;
    bottom: 6px;
    left: 12px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    padding-top: 4px;

    border-top: 1px solid currentColor;

    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.01em;
}

.distance-trend-closer {
    color: #15803d;
}

.distance-trend-farther {
    color: #b91c1c;
}

.distance-trend-very-close {
    color: #a16207;
}

.distance-trend-same {
    color: #475569;
}

.distance-trend-icon {
    font-size: 11px;
    line-height: 1;
}

.distance-trend-label {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   Entry animation
   ========================================================= */

@keyframes geoRankleGuessRowEnter {
    0% {
        opacity: 0;
        transform:
            translateY(-10px)
            scale(0.97);
    }

    70% {
        opacity: 1;
        transform:
            translateY(2px)
            scale(1.01);
    }

    100% {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 1000px) {
    .guess-row {
        grid-template-columns:
            minmax(160px, 190px)
            minmax(0, 1fr);
    }

    .gr32-distance {
        grid-column: 1 / -1;

        justify-self: stretch;

        width: 100%;
        min-width: 0;
    }
}

/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 700px) {
    .distance-unit-toolbar {
        justify-content: center;

        margin-top: 12px;
    }

    .results-list,
    #resultsBody {
        gap: 9px;

        margin-top: 15px;
    }

    .guess-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;

        padding: 13px 14px;

        border-left-width: 5px;
        border-radius: 16px;
    }

    .gr32-country-block {
        gap: 10px;
    }

    .gr32-flag {
        width: 44px;
        height: 29px;

        border-radius: 7px;
    }

    .gr32-country-name {
        font-size: 17px;
    }

    .gr32-clues {
        display: grid;
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .gr32-clue,
    .gr32-continent {
        width: 100%;
        min-width: 0;
        min-height: 38px;

        padding: 7px 9px;
    }

    .gr32-distance {
        grid-column: auto;

        min-height: 46px;

        font-size: 17px;
    }

    .gr32-distance.has-distance-trend {
        min-height: 64px;
    }

    .gr32-flight-status {
        grid-column: 1;
        grid-row: 2 / span 2;

        width: 100%;
        min-height: 96px;
    }

    .distance-value {
        min-width: 66px;
    }

    .distance-primary {
        font-size: 16px;
    }

    .distance-arrow {
        font-size: 22px;
    }
}

/* =========================================================
   Small mobile screens
   ========================================================= */

@media (max-width: 420px) {
    .guess-row {
        padding: 12px;
    }

    .gr32-country-name {
        font-size: 16px;
    }

    .gr32-guess-label {
        font-size: 12px;
    }

    .gr32-clue {
        min-height: 36px;

        font-size: 14px;
    }

    .gr32-distance {
        min-height: 44px;
        padding: 8px 12px;

        font-size: 16px;
    }

    .distance-icon {
        font-size: 19px;
    }

    .distance-value {
        min-width: 62px;
    }

    .distance-primary {
        font-size: 15px;
    }

}

/* =========================================================
   High contrast
   ========================================================= */

@media (prefers-contrast: more) {
    .guess-row {
        border-top-width: 2px;
        border-right-width: 2px;
        border-bottom-width: 2px;
        border-left-width: 7px;
    }

    .gr32-clue,
    .gr32-distance,
    .gr32-flight-status {
        border-width: 2px;
    }
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .guess-row {
        animation: none;
        transition: none;
    }

    .gr32-flight-status,
    .gr32-flight-status-icon,
    .guess-row.is-result-revealing
        .gr32-clue,
    .guess-row.is-result-revealing
        .gr32-distance,
    .guess-row.is-result-revealing
        .distance-trend {
        animation: none;
    }
}
