/* The Maps tab of a campaign's page (campaign_maps.js): a gallery of the campaign's battlemaps and the dialog that opens one large. The
   tabletop's Play box (partials/campaign_tabletop_play.html) is on the Overview, outside the tab, so it carries the tokens too. */

.campaign-maps,
.cm-tabletop {
    --cm-ink: #ded0b7;
    --cm-accent: #e9be8b;
    --cm-panel: #0e161b;
    --cm-line: rgba(222, 208, 183, 0.28);
    --cm-gap: 1.25rem;
}

.cm-play {
    align-items: center;
    background: linear-gradient(135deg, rgba(233, 190, 139, 0.14), rgba(233, 190, 139, 0.04));
    border: 1px solid var(--cm-line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
}

.cm-play-text {
    flex: 1 1 18rem;
    margin: 0;
}

.cm-play-link {
    flex: 0 0 auto;
    white-space: normal;
}

.cm-play[hidden],
.cm-play-link[hidden] {
    display: none;
}

.cm-play-line {
    display: block;
}

.cm-play-line + .cm-play-line {
    color: var(--cm-accent);
    margin-top: 0.4rem;
}

/* The loading and failure lines above the gallery and in the world box. While busy the line is the site's loading state (option_generation.css:
   `option-section-loading` with `option-generation-spinner`); otherwise it is a line of text. A request that failed is asked for again by the page itself, with the
   spinner shown meanwhile. */
.cm-status,
.cm-world-status {
    color: var(--cm-ink);
    margin: 0 0 1rem;
}

.cm-status:not(.option-section-loading),
.cm-world-status:not(.option-section-loading) {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.cm-status[hidden],
.cm-world-status[hidden] {
    display: none;
}

.cm-status-text {
    margin: 0;
}

.cm-gallery {
    display: grid;
    gap: var(--cm-gap);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}

.cm-card {
    background: var(--cm-panel);
    border: 1px solid var(--cm-line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.cm-card-map {
    appearance: none;
    background: #1b262d;
    border: 0;
    color: var(--cm-ink);
    cursor: zoom-in;
    display: block;
    padding: 0;
    position: relative;
    width: 100%;
}

.cm-card-map:focus-visible {
    outline: 3px solid var(--cm-accent);
    outline-offset: -3px;
}

.cm-canvas {
    background: #1b262d;
    display: block;
    height: auto;
    max-height: 22rem;
    object-fit: contain;
    width: 100%;
}

.cm-card-note {
    background: rgba(14, 22, 27, 0.7);
    font-size: 0.9rem;
    inset: 0;
    align-items: center;
    display: flex;
    justify-content: center;
    padding: 1rem;
    position: absolute;
    text-align: center;
}

.cm-card-pending {
    align-items: center;
    cursor: default;
    display: flex;
    justify-content: center;
    min-height: 10rem;
}

.cm-card-pending .cm-card-note {
    align-items: flex-end;
    background: none;
}

.cm-card-note[hidden] {
    display: none;
}

.cm-card-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    justify-content: space-between;
    padding: 0.85rem 1rem 0;
}

.cm-card-title {
    font-size: 1.1rem;
    margin: 0;
    overflow-wrap: anywhere;
}

.cm-card-kind {
    border: 1px solid var(--cm-line);
    border-radius: 999px;
    color: var(--cm-accent);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.6rem;
    text-transform: uppercase;
}

.cm-card-summary {
    color: rgba(222, 208, 183, 0.75);
    font-size: 0.9rem;
    margin: 0;
    padding: 0.25rem 1rem 0.75rem;
}

/* "Open in the Battlemap Generator": the site's secondary pill (tool_components.css), at the card's foot. */
.cm-card-edit {
    align-self: flex-start;
    margin: 0 1rem 1rem;
}

.cm-card-edit[hidden] {
    display: none;
}

/* The large map */
.cm-viewer {
    background: var(--cm-panel, #0e161b);
    border: 1px solid rgba(222, 208, 183, 0.28);
    border-radius: 8px;
    color: #ded0b7;
    height: min(92vh, 60rem);
    max-width: none;
    padding: 0;
    width: min(96vw, 90rem);
}

.cm-viewer[open] {
    display: flex;
    flex-direction: column;
}

.cm-viewer::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.cm-viewer-header {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    justify-content: space-between;
    padding: 0.75rem 1rem;
}

.cm-viewer-header > div:first-child {
    flex: 1 1 12rem;
    min-width: 0;
}

.cm-viewer-title {
    font-size: 1.25rem;
    margin: 0;
    overflow-wrap: anywhere;
}

.cm-viewer-kind {
    color: rgba(222, 208, 183, 0.75);
    font-size: 0.9rem;
    margin: 0;
}

/* The Battlemap Generator's toolbar buttons, as it draws them (`dungeon-generator` supplies their colours; its page padding and width are not
   wanted here). */
.cm-viewer-tools {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    margin: 0;
    max-width: none;
    padding: 0;
}

.cm-viewer-tools [hidden] {
    display: none;
}

.cm-viewer-tools .dungeon-btn {
    text-align: left;
    white-space: normal;
}

.cm-viewer-stage {
    background: #1b262d;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.cm-viewer-stage .bm-canvas {
    display: block;
    height: 100%;
    touch-action: none;
    width: 100%;
}

@media (max-width: 640px) {
    .campaign-maps {
        padding: 1rem;
    }

    .cm-play {
        padding: 1rem;
    }

    .cm-play-link {
        width: 100%;
    }

    .cm-viewer-tools {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .cm-viewer {
        border-radius: 0;
        height: 100dvh;
        max-height: 100dvh;
        width: 100vw;
    }
}

/* The world map above the gallery (the same module as the tabletop's: web/static/web/tabletop/world_map.js). */
.cm-world {
    margin: 0 0 1.5rem;
}

.cm-world[hidden] {
    display: none;
}

.cm-world-heading {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.cm-world-stage {
    position: relative;
    width: min(100%, 78vh, 820px);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(226, 185, 90, 0.4);
    border-radius: 10px;
    background: #17130e;
}

/* Until the map is drawn the box shows the spinner alone: the stage keeps its size (the map is drawn into it) but is out of sight and
   out of the flow, and the note under it is not shown. */
.cm-world:not(.cm-world-drawn) {
    position: relative;
}

.cm-world:not(.cm-world-drawn) .cm-world-stage {
    position: absolute;
    left: 0;
    right: 0;
    visibility: hidden;
}

.cm-world:not(.cm-world-drawn) .cm-world-note {
    display: none;
}

.cm-world-stage .bm-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
}

.cm-world-note {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    opacity: 0.75;
}

/* a place the player's game has not reached: dimmed, with a line saying so */
.cm-card-locked .cm-card-map {
    cursor: default;
    opacity: 0.6;
}

.cm-card-locked .cm-canvas {
    display: none;
}

.cm-card-locked .cm-card-note {
    position: static;
    padding: 2.2rem 1rem;
    text-align: center;
    font-style: italic;
}
