/* The World Map tab of a campaign's page (web/static/web/campaign_world/world_tab.js builds what is in it). It uses the
 * campaign page's palette (campaign_details4.css: dark cards, parchment text, gold accents). The map's own canvases are
 * the Map Generator renderer's (.mg-viewport, .mg-gl, .mg-overlay), whose few layout rules are repeated here because the
 * Map Generator's stylesheet is not on this page. */

.campaign-world-card {
    --cw-gold: #e7bf8f;
    --cw-ink: #ded0b7;
    --cw-glass: rgba(16, 22, 27, 0.86);
    --cw-line: rgba(222, 208, 183, 0.28);
    padding: 1.5rem;
}

.cw-panel {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.cw-loading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem 0 0.5rem;
}

.cw-loading p {
    margin: 0;
}

/* --- What the tab says above the map --- */

.cw-head {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cw-size-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    margin: 0;
    font-size: 0.95rem;
}

.cw-tier {
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--cw-line);
}

.cw-tier-premium {
    color: #1d1407;
    background: var(--cw-gold);
    border-color: var(--cw-gold);
}

.cw-upgrade-text {
    opacity: 0.85;
}

.cw-upgrade {
    color: var(--cw-gold);
    font-weight: 600;
    text-decoration: underline;
}

.cw-notes p {
    margin: 0;
    font-size: 0.88rem;
    opacity: 0.85;
}

.cw-notes .fa-circle-info {
    color: var(--cw-gold);
}

/* --- The map --- */

.cw-map {
    position: relative;
    height: clamp(420px, 72vh, 820px);
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--cw-line);
    background: #0d1418;
}

.cw-map .mg-viewport {
    position: absolute;
    inset: 0;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.cw-map .mg-viewport:active {
    cursor: grabbing;
}

.cw-map .mg-gl,
.cw-map .mg-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.cw-map .mg-overlay {
    pointer-events: none;
}

.cw-tools {
    position: absolute;
    top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 3;
}

.cw-tools-left {
    left: 10px;
}

.cw-tools-right {
    right: 10px;
    justify-content: flex-end;
}

.cw-chip,
.cw-round,
.cw-mode-list,
.cw-scale,
.cw-compass,
.cw-card,
.cw-status {
    background: var(--cw-glass);
    color: var(--cw-ink);
    border: 1px solid var(--cw-line);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.cw-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0 0.8rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.cw-chip:hover,
.cw-round:hover,
.cw-chip:focus-visible,
.cw-round:focus-visible {
    border-color: var(--cw-gold);
    color: #fff;
}

.cw-modes {
    position: relative;
}

.cw-mode-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    padding: 6px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cw-mode-list[hidden] {
    display: none;
}

.cw-mode-list button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 38px;
    padding: 0 0.6rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--cw-ink);
    text-align: left;
    cursor: pointer;
}

.cw-mode-list button:hover,
.cw-mode-list button[aria-checked="true"] {
    background: rgba(242, 193, 78, 0.16);
    color: #fff;
}

.cw-mode-list button i {
    width: 18px;
    color: var(--cw-gold);
}

.cw-zoom {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.cw-round {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1rem;
    cursor: pointer;
}

.cw-scale {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    z-index: 2;
}

.cw-scale:empty {
    display: none;
}

.cw-scale-bar {
    display: inline-block;
    height: 8px;
    border: 2px solid var(--cw-ink);
    border-top: 0;
}

.cw-compass {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    z-index: 2;
}

.cw-compass i {
    transform: rotate(-45deg);
    color: var(--cw-gold);
}

/* --- The card of a place --- */

.cw-card {
    position: absolute;
    left: 10px;
    bottom: 54px;
    width: min(340px, calc(100% - 70px));
    max-height: calc(100% - 120px);
    overflow: auto;
    padding: 0.9rem 1rem 1rem;
    border-radius: 10px;
    z-index: 4;
}

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

.cw-card h3 {
    margin: 0.2rem 2rem 0.6rem 0;
    font-size: 1.2rem;
    color: #fff;
}

.cw-card-kind {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Clear of the close button in the card's corner. */
    margin: 0 2.25rem 0 0;
    font-size: 0.85rem;
    color: #cfc2aa;
}

.cw-card dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.8rem;
    margin: 0 0 0.6rem;
    font-size: 0.9rem;
}

.cw-card dt {
    font-weight: 600;
    opacity: 0.75;
}

.cw-card dd {
    margin: 0;
}

.cw-card-close {
    position: absolute;
    z-index: 1;
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--cw-ink);
    cursor: pointer;
}

.cw-card-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 38px;
    padding: 0 0.8rem;
    border: 1px solid var(--cw-gold);
    border-radius: 999px;
    background: transparent;
    color: var(--cw-gold);
    font-weight: 600;
    cursor: pointer;
}

/* --- What is said over the map: loading, drawing, errors --- */

.cw-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: max-content;
    max-width: min(420px, calc(100% - 32px));
    padding: 1rem 1.25rem;
    border-radius: 10px;
    text-align: center;
    z-index: 5;
}

.cw-status[hidden] {
    display: none;
}

.cw-status p {
    margin: 0;
}

.cw-status .btn {
    white-space: nowrap;
}

/* The short names of the map's buttons, for narrow screens. */
.cw-chip .cw-short {
    display: none;
}

.cw-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(242, 193, 78, 0.25);
    border-top-color: var(--cw-gold);
    border-radius: 50%;
    animation: cw-spin 0.9s linear infinite;
}

@keyframes cw-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .cw-spinner {
        animation-duration: 3s;
    }
}

/* --- The list of the campaign's places --- */

.cw-places-box[hidden] {
    display: none;
}

.cw-places-box h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.cw-places {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cw-place {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.6rem;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--cw-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--cw-ink);
    text-align: left;
    cursor: pointer;
}

.cw-place:hover,
.cw-place:focus-visible {
    border-color: var(--cw-gold);
}

.cw-place .cw-place-number {
    grid-row: span 2;
}

.cw-place-name {
    font-weight: 600;
    color: #fff;
}

.cw-place-kind {
    font-size: 0.8rem;
    opacity: 0.75;
}

.cw-place-number {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid #1d1407;
    border-radius: 50%;
    background: var(--cw-gold, #f2c14e);
    color: #1d1407;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Open country, camps and regions are diamonds on the map, as here. */
.cw-place-number.cw-kind-wilderness,
.cw-place-number.cw-kind-camp,
.cw-place-number.cw-kind-region {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

/* --- Phones and small tablets --- */

@media (max-width: 767px) {
    .campaign-world-card {
        padding: 1rem 0.75rem;
    }

    .cw-map {
        height: clamp(380px, 68vh, 640px);
        margin: 0 -0.25rem;
    }

    .cw-chip {
        padding: 0 0.65rem;
        gap: 0.35rem;
        font-size: 0.85rem;
    }

    .cw-chip .cw-long {
        display: none;
    }

    .cw-chip .cw-short {
        display: inline;
    }

    .cw-card {
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: 55%;
    }

    .cw-zoom {
        top: auto;
        bottom: 64px;
        transform: none;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .cw-map {
        height: calc(100vh - 90px);
        min-height: 260px;
    }

    .cw-card {
        max-height: calc(100% - 70px);
        bottom: 8px;
        left: 8px;
    }
}

/* A campaign without a world yet: the panel says why (and offers the button); the map's controls wait for a world. */
.cw-map.is-empty {
    height: clamp(220px, 34vh, 320px);
}

.cw-map.is-empty .cw-tools,
.cw-map.is-empty .cw-zoom,
.cw-map.is-empty .cw-scale,
.cw-map.is-empty .cw-compass {
    display: none;
}

.cw-status .cw-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

.cw-map[hidden] {
    display: none;
}

/* A passing problem (a map tile that could not be loaded): told at the top of the map, never in the way of the map. */
.cw-notice {
    position: absolute;
    left: 50%;
    top: 60px;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    background: var(--cw-glass);
    color: var(--cw-ink);
    border: 1px solid var(--cw-line);
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 4;
}

.cw-notice[hidden] {
    display: none;
}
