/**
 * worldmap.css — WorldMap Plugin for MyBB 1.8
 *
 * Upload to: jscripts/worldmap.css
 *
 * Sections:
 *   1. Portal triptych
 *   2. Full map page
 *   3. Map pins / closed clusters
 *   4. Open cluster members
 *   5. ACP tool
 */


/* ── 1. Portal triptych ──────────────────────────────────────────────────── */

.wm-portal-wrap {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: flex-start;
    margin: 8px 0;
    flex-wrap: nowrap;
}

.wm-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    border: 2px solid #8b7355;
    border-radius: 4px;
    overflow: hidden;
    background: #1a1a1a;
    transition: border-color .2s;
}

.wm-thumb:hover {
    border-color: #c9a96e;
}

.wm-thumb-map {
    position: relative;
    display: block;
    width: 100%;
    line-height: 0;
}

.wm-thumb-map > img {
    width: 100%;
    height: auto;
    display: block;
}

.wm-thumb-label {
    font-size: 11px;
    color: #c9a96e;
    padding: 4px 6px 0;
    text-align: center;
    font-weight: 500;
}

.wm-thumb-count {
    font-size: 10px;
    color: #888;
    padding: 2px 6px 6px;
    text-align: center;
}

/* Portal pin markers are visual only.
   The whole thumbnail remains the single clickable link. */
.wm-thumb-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 4;
    line-height: normal;
}

.wm-thumb-pin-count {
    width: 15px;
    height: 15px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1.5px solid rgba(200,200,200,.92);
    background: rgba(0,0,0,.72);
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
}

.wm-thumb-pin-line {
    width: 1px;
    height: 7px;
    background: rgba(200,200,200,.92);
}

.wm-thumb-pin-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(200,200,200,.95);
}

/* Pure NPC clusters (group 21) */
.wm-thumb-pin-npc .wm-thumb-pin-count {
    border-color: #679899;
    background: rgba(40, 96, 99, .75);
    color: #679899;
}

.wm-thumb-pin-npc .wm-thumb-pin-line {
    background: #679899;
}

.wm-thumb-pin-npc .wm-thumb-pin-dot {
    background: #83a7a8;
}

@media (max-width: 900px) {
    .wm-portal-wrap {
        gap: 6px;
    }

    .wm-thumb-label {
        font-size: 10px;
    }

    .wm-thumb-pin-count {
        width: 12px;
        height: 12px;
        font-size: 7px;
    }

    .wm-thumb-pin-line {
        height: 6px;
    }
}


/* ── 2. Full map page ────────────────────────────────────────────────────── */

.wm-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
}

.wm-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 14px;
}

.wm-nav-btn {
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid #8b7355;
    color: #c9a96e;
    background: transparent;
    text-decoration: none;
    font-size: 13px;
    transition: background .15s;
}

.wm-nav-btn:hover {
    background: rgba(201, 169, 110, .15);
}

.wm-nav-active {
    background: #8b7355;
    color: #fff;
}

/*
 * The map container is the coordinate surface for pins.
 *
 * Landscape / desktop:
 *   - fit the complete map into the available viewport/container
 *   - never exceed the available width
 *
 * Portrait:
 *   - fill the available width
 *   - allow the map to become taller than the viewport
 *   - normal page scrolling moves map and pins together
 */
.wm-map-outer {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.wm-map-img {
    display: block;
    max-width: 100%;
   /* max-height: 85vh; */
    width: auto;
    height: auto;
    border: 2px solid #8b7355;
    border-radius: 4px;
    box-sizing: border-box;
    user-select: none;
}

@media (orientation: portrait) {
    .wm-map-outer {
        width: 100%;
        max-width: 100%;
    }

    .wm-map-img {
        width: 100%;
        max-width: 100%;
        max-height: none;
        height: auto;
    }
}


/* ── 3. Map pins / closed clusters ──────────────────────────────────────── */

/*
 * Every location is displayed as a numbered pin.
 * A single character therefore shows "1"; nearby characters show 2, 3, ...
 *
 * The entire cluster wrapper is anchored with its BOTTOM CENTER on the
 * calculated map coordinate, exactly like the ACP placement preview.
 */
.wm-cluster {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    overflow: visible;
    line-height: normal;
}

.wm-hub {
    width: 25px;
    height: 25px;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .68);
    border: 1.5px solid rgba(200, 200, 200, .9);
    display: flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    cursor: pointer;
    position: relative;
    z-index: 8;
    transition: background .15s, transform .15s, border-color .15s, color .15s;
}

.wm-hub:hover {
    background: rgba(0, 0, 0, .82);
    transform: scale(1.06);
}

/* A cluster is blue only if every member belongs to NPC group 21. */
.wm-hub-npc {
    background: rgba(40, 96, 99, .75);
    border-color: #679899;
    color: #679899;
}

.wm-hub-npc:hover {
    background: rgba(47, 112, 116, .92);
}

.wm-cneedle-line {
    display: block;
    width: 2px;
    height: 16px;
    background: #aaa;
}

.wm-cneedle-dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    margin-top: -1px;
}

.wm-cluster-npc .wm-cneedle-line {background: #679899;}
.wm-cluster-npc .wm-cneedle-dot {background: #83a7a8;}


/* ── 4. Open cluster members ─────────────────────────────────────────────── */

.wm-cluster-members {
    position: absolute;

    /* Center of the numbered hub.
       Member offsets supplied by JS are relative to this point. */
    left: 50%;
    top: 18px;

    width: 0;
    height: 0;
    overflow: visible;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity .15s;
    z-index: 20;
}

.wm-cluster-open .wm-cluster-members {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.wm-orb {
    position: absolute;
    transform: translate(-50%, -50%);
    overflow: visible;
    cursor: pointer;
    z-index: 4;
    text-decoration: none;
}

.wm-orb img {
    width: 100%;
    height: 100%;
    display: block;
    box-sizing: border-box;
    object-fit: cover;
    object-position: center top;
    border-radius: 50%;
    border: 1.5px solid #aaa;
    transition: filter .15s, transform .15s, border-color .15s;
}

/* NPCs stay identifiable even inside mixed clusters. */
.wm-orb-npc img {
    border-color: #286063;
}

.wm-orb:hover {
    z-index: 9999;
}

.wm-orb:hover img {
    filter: brightness(1.15);
    transform: scale(1.06);
}

.wm-orb-name {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    display: block;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,.78);
    color: #fff;
    font-size: 10px;
    line-height: 1.2;
    text-decoration: none;
    pointer-events: none;
}


/* ── 5. ACP tool ─────────────────────────────────────────────────────────── */

.wm-acp-wrap {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.wm-map-frame {
    position: relative;
    flex: 1;
    min-width: 280px;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    cursor: crosshair;
    background: #1a1a1a;
}

.wm-map-frame img {
    width: 100%;
    display: block;
    user-select: none;
}

/* Preview pin (while placing) */
.wm-pin-preview {
    position: absolute;
    transform: translate(-50%, -100%);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wm-preview-bubble {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2.5px solid #fff;
    background: #7F77DD;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    font-weight: 500;
}

.wm-preview-needle {
    width: 2px;
    height: 14px;
    background: #fff;
}

.wm-preview-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    margin-top: -1px;
}

.wm-pin-preview-npc .wm-preview-bubble {
    background: rgba(40, 96, 99, .75);
    border-color: #679899;
    color: #679899;
}

.wm-pin-preview-npc .wm-preview-needle { background: #679899; }
.wm-pin-preview-npc .wm-preview-dot {background: #83a7a8;}

/* Existing pins shown on ACP map */
.wm-existing-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.wm-existing-pin img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
}

.wm-existing-pin-npc img {
    border-color: #679899;
}

.wm-existing-needle {
    width: 2px;
    height: 12px;
    background: #fff;
}

.wm-existing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #fff;
    margin-top: -1px;
}

.wm-existing-pin-npc .wm-existing-needle {background: #679899;}
.wm-existing-pin-npc .wm-existing-dot {background: #83a7a8;}

.wm-pin-tip {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .8);
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    display: none;
}

.wm-existing-pin:hover .wm-pin-tip {
    display: block;
}

/* Form panel */
.wm-form-panel {
    width: 260px;
    flex-shrink: 0;
}

.wm-coord-box {
    font-family: monospace;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    margin-bottom: 12px;
}

.wm-select {
    width: 100%;
}

.wm-form-submit {
    text-align: right;
    padding-top: 8px;
}

/* Pins overview table */
.wm-pin-table {
    width: 100%;
}

.wm-no-pins {
    text-align: center;
    color: #999;
}

.wm-delete-form {
    display: inline;
}