/* Guess the Country (/guess-the-country): the silhouette (or, after the game, Atlas Pin's world map) and the card of
   guesses beside it. Tiles and buttons come from the app kit; the map's canvas and zoom buttons from
   css/apps/atlas-map.css. */

.gtc-play {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr);
    gap: var(--ak-space-3);
    width: 100%;
    min-height: 460px;
}

/* ----- the picture: the shape, or the map ----- */

.gtc-figure {
    position: relative;
    min-width: 0;
    min-height: 320px;
}

.gtc-shape {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--ak-border);
}

.gtc-shape[hidden],
.gtc-map-box[hidden] {
    display: none;
}

.gtc-map-box {
    position: absolute;
    inset: 0;
}

.gtc-map-wrap {
    position: absolute;
    inset: 0;
}

/* ----- the card ----- */

.gtc-card {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
    min-width: 0;
    padding: var(--ak-space-3);
    border-radius: 12px;
    background: var(--ak-panel);
    border: 1px solid var(--ak-border);
}

.gtc-prompt {
    margin: 0;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    font-weight: 600;
}

.gtc-form {
    display: flex;
    gap: var(--ak-space-2);
}

.gtc-input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1rem;
}

.gtc-guess-btn {
    flex: 0 0 auto;
}

.gtc-form.is-shaking {
    animation: gtc-shake 0.36s ease;
}

@keyframes gtc-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .gtc-form.is-shaking {
        animation: none;
    }
}

.gtc-message {
    margin: 0;
    min-height: 1.4em;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
}

.gtc-message[data-tone="good"] {
    color: var(--ak-success);
    font-weight: 700;
}

.gtc-message[data-tone="bad"] {
    color: var(--ak-danger);
    font-weight: 600;
}

/* Six rows: the country, the distance, the arrow towards the answer, and how close (a bar under the row). */
.gtc-guesses {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gtc-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 28px 3.4em;
    align-items: center;
    gap: var(--ak-space-2);
    min-height: 40px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--ak-field);
    border: 1px solid var(--ak-border);
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.gtc-row::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    bottom: 0;
    width: var(--gtc-pct, 0%);
    height: 4px;
    background: var(--gtc-heat, var(--ak-accent));
}

.gtc-row.is-empty {
    background: transparent;
    border-style: dashed;
}

.gtc-row.is-right {
    border-color: var(--ak-success);
    box-shadow: inset 0 0 0 1px var(--ak-success);
}

.gtc-row-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gtc-row-km {
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    white-space: nowrap;
}

.gtc-row-dir {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
}

.gtc-arrow {
    width: 24px;
    height: 24px;
    fill: var(--ak-text);
    transition: transform 0.4s ease;
}

.gtc-row-pct {
    font-weight: 800;
    text-align: end;
}

/* ----- after the game ----- */

.gtc-result {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
    margin-top: var(--ak-space-1);
}

.gtc-result[hidden] {
    display: none;
}

.gtc-answer {
    display: flex;
    align-items: center;
    gap: var(--ak-space-2);
}

.gtc-flag {
    display: block;
    flex: 0 0 auto;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.gtc-answer-name {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.gtc-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-2);
}

/* How many guesses your wins took: a bar per number, today's in the accent. */
.gtc-dist {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: var(--ak-fs-sm);
    font-variant-numeric: tabular-nums;
}

.gtc-dist-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gtc-dist-n {
    width: 1em;
    color: var(--ak-muted);
    text-align: center;
}

.gtc-dist-bar {
    min-width: 1.6em;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--ak-border);
    color: var(--ak-text);
    font-weight: 700;
    text-align: end;
}

.gtc-dist-bar.is-now {
    background: var(--ak-success);
    color: #fff;
}

/* On a phone the picture goes on top in a shape of its own, the card under it. */
@media (max-width: 800px) {
    .gtc-play {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .gtc-figure {
        min-height: 0;
        aspect-ratio: 4 / 3;
    }

    .gtc-card {
        padding: var(--ak-space-2) var(--ak-space-3);
    }

    .gtc-row {
        min-height: 36px;
        padding: 4px 8px;
    }
}

/* In the app layout on a computer the picture and the card take the stage's whole height under the tiles. */
@media (min-width: 801px) {
    body.filter-app-mode .ak-app > .filter-landing-stage.gtc-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
    }

    body.filter-app-mode .gtc-stage .gtc-play {
        flex: 1 1 0;
        height: 100%;
        min-height: 420px;
    }

    body.filter-app-mode .gtc-stage .gtc-card {
        overflow: auto;
    }
}

/* With the controls hidden on a phone or upright tablet the stage fills the screen: the picture takes the height the
   card under it leaves (at least 160px), and on a short phone the card's list of guesses scrolls inside the card
   instead of the picture scrolling away. */
@media (max-width: 800px) {
    body.filter-app-mode .ak-app.is-panel-collapsed > .filter-landing-stage.gtc-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
        margin-block: 0;
    }

    body.filter-app-mode .ak-app.is-panel-collapsed > .gtc-stage .gtc-play {
        flex: 1 1 0;
        min-height: 0;
        grid-template-rows: minmax(160px, 1fr) minmax(0, auto);
    }

    body.filter-app-mode .ak-app.is-panel-collapsed > .gtc-stage .gtc-figure {
        aspect-ratio: auto;
    }

    body.filter-app-mode .ak-app.is-panel-collapsed > .gtc-stage .gtc-card {
        min-height: 0;
        overflow: auto;
    }
}

/* With the controls shown on a phone or tablet the stage's height follows its content (the shared phone layout), so
   the rules above that let the picture and the card take the stage's height left them 0 pixels tall from 801px.
   There they keep their own height and the stage scrolls. */
@media (max-width: 960px) {
    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .filter-landing-stage.gtc-stage > .game-board-panel {
        flex: none;
    }

    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .gtc-stage .gtc-play {
        flex: none;
        height: auto;
    }
}
