/* Fill the Map (/fill-the-map): the blank map and, beside it, the field (Name them) or the country to place (Puzzle),
   the status and the countries found. Tiles and buttons come from the app kit; the canvas and its zoom buttons from
   css/apps/atlas-map.css. */

.fill-map-play {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.7fr);
    gap: var(--ak-space-3);
    width: 100%;
    min-height: 460px;
}

.fill-map-map-wrap .atlas-map {
    cursor: pointer;
}

.fill-map-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);
}

.fill-map-entry .ak-field {
    width: 100%;
}

.fill-map-entry .ak-field.is-wrong {
    animation: fill-map-shake 0.3s;
    border-color: var(--ak-danger);
}

@keyframes fill-map-shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .fill-map-entry .ak-field.is-wrong { animation: none; }
}

/* Puzzle: the country to place, its name and its shape. */
.fill-map-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.fill-map-card.is-done {
    display: none;
}

.fill-map-prompt {
    margin: 0;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    font-weight: 600;
}

.fill-map-target {
    margin: 0;
    color: var(--ak-text);
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.fill-map-shape {
    display: block;
    width: 160px;
    height: 120px;
}

.fill-map-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ak-space-2);
    width: 100%;
}

.fill-map-left {
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    font-weight: 600;
}

.fill-map-status {
    margin: 0;
    min-height: 1.4em;
    color: var(--ak-text);
    font-weight: 600;
    font-size: var(--ak-fs-sm);
    overflow-wrap: anywhere;
}

.fill-map-status[data-tone="good"] {
    color: var(--ak-success);
    font-weight: 800;
}

.fill-map-status[data-tone="bad"] {
    color: var(--ak-danger);
}

/* The countries found (newest first), then the missed ones once it is over. */
.fill-map-list {
    flex: 1 1 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    font-size: var(--ak-fs-sm);
}

.fill-map-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    border-bottom: 1px solid var(--ak-border);
    font-weight: 600;
}

.fill-map-row:last-child {
    border-bottom: 0;
}

.fill-map-row::before {
    content: "";
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #2fb35f;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.fill-map-row.is-late::before {
    background: #e8b33a;
}

.fill-map-row.is-missed::before {
    background: #e5483b;
}

.fill-map-row.is-head {
    border-bottom: 0;
    padding-top: 10px;
    color: var(--ak-muted);
    font-size: var(--ak-fs-xs, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fill-map-row.is-head::before {
    display: none;
}

/* On a phone the map goes first and the panel under it. */
@media (max-width: 800px) {
    .fill-map-play {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .fill-map-map-wrap {
        aspect-ratio: 4 / 3;
    }

    .fill-map-side {
        padding: var(--ak-space-2);
    }

    .fill-map-shape {
        width: 120px;
        height: 80px;
    }

    .fill-map-list {
        flex: none;
        max-height: 220px;
    }
}

/* 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.fill-map-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
    }

    body.filter-app-mode .fill-map-stage .fill-map-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. */
@media (max-width: 800px) {
    body.filter-app-mode .ak-app > .filter-landing-stage.fill-map-stage > .game-board-panel {
        flex: 1 1 0;
        min-height: 0;
    }

    body.filter-app-mode .fill-map-stage .fill-map-play {
        flex: 1 1 0;
        height: 100%;
        grid-template-rows: minmax(260px, 1fr) auto;
    }

    body.filter-app-mode .fill-map-stage .fill-map-map-wrap {
        aspect-ratio: auto;
        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.fill-map-stage > .game-board-panel {
        flex: none;
    }

    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .fill-map-stage .fill-map-play {
        flex: none;
        height: auto;
    }
}

@media (max-width: 800px) {
    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .fill-map-stage .fill-map-play {
        grid-template-rows: none;
    }

    body.filter-app-mode .ak-app:not(.is-panel-collapsed) > .fill-map-stage .fill-map-map-wrap {
        aspect-ratio: 4 / 3;
        min-height: 0;
    }
}
