/* How Far (/how-far): the world map and, beside it, the question, the guess (slider and field), the result and the
   rounds. Tiles and buttons come from the app kit; the canvas and its zoom buttons from css/apps/atlas-map.css. */

.how-far-play {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.75fr);
    gap: var(--ak-space-3);
    width: 100%;
    min-height: 460px;
}

.how-far-map-wrap .atlas-map.how-far-map {
    cursor: grab;
}

.how-far-map-wrap .atlas-map.how-far-map:active {
    cursor: grabbing;
}

.how-far-side {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
    min-width: 0;
    min-height: 0;
    padding: var(--ak-space-3);
    border-radius: 12px;
    background: var(--ak-panel);
    border: 1px solid var(--ak-border);
}

.how-far-question {
    margin: 0;
    color: var(--ak-text);
    font-size: var(--ak-fs-md, 1rem);
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.how-far-question b {
    font-weight: 800;
}

.how-far-question .how-far-a {
    color: #d23a2e;
}

.how-far-question .how-far-b {
    color: #2367c4;
}

:root[data-theme="dark"] .how-far-question .how-far-a {
    color: #ff8a80;
}

:root[data-theme="dark"] .how-far-question .how-far-b {
    color: #8ab8ff;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .how-far-question .how-far-a {
        color: #ff8a80;
    }

    :root:not([data-theme="light"]) .how-far-question .how-far-b {
        color: #8ab8ff;
    }
}

/* The field with its unit, and under it Guess (or Next round) across the panel. */
.how-far-entry {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
}

.how-far-field {
    display: flex;
    align-items: center;
    gap: var(--ak-space-2);
}

.how-far-field .ak-field {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

.how-far-unit {
    flex: none;
    min-width: 2ch;
    color: var(--ak-muted);
    font-weight: 700;
}

.how-far-entry .ak-btn {
    width: 100%;
    justify-content: center;
}

.how-far-status {
    margin: 0;
    min-height: 1.4em;
    color: var(--ak-text);
    font-weight: 600;
    font-size: var(--ak-fs-sm);
    overflow-wrap: anywhere;
}

.how-far-status[data-tone="good"] {
    color: var(--ak-success);
}

.how-far-status[data-tone="bad"] {
    color: var(--ak-danger);
}

.how-far-status strong,
.how-far-status-line {
    display: block;
}

.how-far-status strong {
    font-size: var(--ak-fs-md, 1rem);
    font-weight: 800;
}

.how-far-list {
    flex: 1 1 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
}

.how-far-list:empty {
    display: none;
}

.how-far-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "n pair pts" "n line line";
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
    padding: 7px 4px;
    border-bottom: 1px solid var(--ak-border);
    font-size: var(--ak-fs-sm);
}

.how-far-row:last-child {
    border-bottom: 0;
}

.how-far-row-n {
    grid-area: n;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--how-far-score, var(--ak-muted));
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
}

.how-far-row-pair {
    grid-area: pair;
    min-width: 0;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.how-far-row-pts {
    grid-area: pts;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.how-far-row-line {
    grid-area: line;
    color: var(--ak-muted);
    font-variant-numeric: tabular-nums;
}

.how-far-row-bar {
    display: block;
    height: 4px;
    margin-top: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--ak-text) 12%, transparent);
    overflow: hidden;
}

.how-far-row-bar i {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--how-far-score, var(--ak-accent));
}

.how-far-row.is-current .how-far-row-pair {
    text-decoration: underline;
    text-decoration-color: var(--ak-accent);
    text-underline-offset: 3px;
}

/* On a phone the map goes first and the panel under it. */
@media (max-width: 800px) {
    .how-far-play {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .how-far-map-wrap {
        aspect-ratio: 4 / 3;
        max-height: 60vh;
    }

    .how-far-side {
        padding: var(--ak-space-2);
    }

    .how-far-list {
        flex: none;
        max-height: 260px;
    }
}

/* In the app layout on a computer the map and the panel take the stage's whole height under the tiles. */
@media (min-width: 801px) {
    body.filter-app-mode .ak-app > .filter-landing-stage.how-far-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
    }

    body.filter-app-mode .how-far-stage .how-far-play {
        flex: 1 1 0;
        height: 100%;
        min-height: 420px;
    }
}

/* In the app layout on a phone the map takes the height the panel under it leaves: no empty band above or below. */
@media (max-width: 800px) {
    body.filter-app-mode .ak-app > .filter-landing-stage.how-far-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
    }

    body.filter-app-mode .how-far-stage .how-far-play {
        flex: 1 1 0;
        height: 100%;
        grid-template-rows: minmax(260px, 1fr) auto;
    }

    body.filter-app-mode .how-far-stage .how-far-map-wrap {
        aspect-ratio: auto;
        max-height: none;
        min-height: 260px;
    }
}

/* 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 map take the stage's height left it 0 pixels tall there. Then the map keeps its own shape and the stage scrolls; with the controls hidden the stage fills the screen and the rules above apply. */
@media (max-width: 960px) {
    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .filter-landing-stage.how-far-stage > .game-board-panel {
        flex: none;
    }

    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .how-far-stage .how-far-play {
        flex: none;
        height: auto;
    }
}

@media (max-width: 800px) {
    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .how-far-stage .how-far-play {
        grid-template-rows: none;
    }

    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .how-far-stage .how-far-map-wrap {
        aspect-ratio: 4 / 3;
        max-height: 60vh;
        min-height: 0;
    }
}
