/* Mystic MUD Auto-Mapper Overlay */

#map-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 300px;
    height: 300px;
    background: var(--bg-dark);
    opacity: 0.9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    z-index: 10;
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-width: 240px;
    min-height: 150px;
    max-width: 90%;
    max-height: 90%;
}

/* Resize grip — visual indicator in bottom-right corner */
#map-overlay::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    pointer-events: none;
    background:
        linear-gradient(135deg,
            transparent 30%,
            var(--border-color) 30%, var(--border-color) 35%,
            transparent 35%, transparent 55%,
            var(--border-color) 55%, var(--border-color) 60%,
            transparent 60%, transparent 80%,
            var(--border-color) 80%, var(--border-color) 85%,
            transparent 85%);
    opacity: 0.35;
    z-index: 11;
    border-radius: 0 0 3px 0;
}

#map-overlay:hover::after {
    opacity: 0.6;
}


/* Title bar — draggable, shows room name + close */
#map-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    gap: 4px;
}

.map-room-label {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.map-close-btn {
    flex-shrink: 0;
    font-size: 11px;
    padding: 1px 5px;
    opacity: 0.6;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.map-close-btn:hover {
    opacity: 1;
}

/* Control strip — buttons grouped with separators */
#map-controls {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    gap: 2px;
    flex-wrap: wrap;
}

.map-control-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.map-control-sep {
    width: 1px;
    height: 14px;
    background: var(--border-color);
    opacity: 0.3;
    margin: 0 2px;
    flex-shrink: 0;
}

.map-ctrl-btn {
    background: color-mix(in srgb, var(--border-color) 10%, transparent);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    padding: 2px 6px;
    font-family: inherit;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s ease;
    line-height: 1.2;
    white-space: nowrap;
}

.map-ctrl-btn:hover {
    background: color-mix(in srgb, var(--border-color) 25%, transparent);
}

.map-ctrl-btn:active {
    background: color-mix(in srgb, var(--border-color) 40%, transparent);
}

.map-ctrl-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
}

/* Zoom level indicator */
.map-zoom-level {
    font-size: 9px;
    color: var(--text-dim);
    min-width: 28px;
    text-align: center;
    cursor: pointer;
    padding: 1px 2px;
    border-radius: 2px;
    transition: color 0.15s ease;
}

.map-zoom-level:hover {
    color: var(--text-primary);
}

/* Gear menu (dropdown) */
.map-gear-wrap {
    position: relative;
}

.map-gear-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 3px 0;
    z-index: 25;
    min-width: 100px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.map-gear-menu.open {
    display: block;
}

.map-gear-item {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 4px 10px;
    font-family: inherit;
    font-size: 10px;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s ease;
    white-space: nowrap;
}

.map-gear-item:hover {
    background: color-mix(in srgb, var(--border-color) 15%, transparent);
}

.map-gear-item.map-gear-danger {
    color: #e65555;
}

.map-gear-item.map-gear-danger:hover {
    background: rgba(230, 85, 85, 0.15);
}

.map-gear-sep {
    height: 1px;
    background: var(--border-color);
    opacity: 0.2;
    margin: 3px 0;
}

/* Tab bar */
#map-tab-bar {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

/* Fixed nav buttons (+, arrows) */
.map-tab-nav {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-dim);
    padding: 2px 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.2;
}

.map-tab-nav:last-child {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.map-tab-nav:hover {
    background: color-mix(in srgb, var(--border-color) 15%, transparent);
    color: var(--text-primary);
}

/* Scrollable tab container */
.map-tab-scroll {
    display: flex;
    gap: 2px;
    overflow-x: hidden;
    flex: 1;
    padding: 2px 4px;
    min-width: 0;
    scroll-behavior: smooth;
}

.map-tab-btn {
    background: color-mix(in srgb, var(--border-color) 5%, transparent);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-dim);
    padding: 1px 8px;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.map-tab-btn:hover {
    background: color-mix(in srgb, var(--border-color) 15%, transparent);
    color: var(--text-primary);
}

.map-tab-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
    font-weight: bold;
}

.map-tab-close {
    margin-left: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s ease;
    cursor: pointer;
}

.map-tab-btn:hover .map-tab-close {
    opacity: 0.7;
}

.map-tab-close:hover {
    opacity: 1 !important;
    color: #ff4444;
}

/* Canvas fills remaining space without causing scrollbars */
#map-canvas {
    flex: 1;
    width: 100%;
    min-height: 0;
    max-height: 100%;
    display: block;
    cursor: grab;
    overflow: hidden;
}

#map-canvas:active {
    cursor: grabbing;
}

/* Hover tooltip */
.map-tooltip {
    display: none;
    position: absolute;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 3px 7px;
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Area change notification banner */
.map-area-banner {
    position: absolute;
    top: 50px;
    left: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-primary);
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: opacity 0.3s ease;
}

.map-area-banner span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Help panel */
.map-help-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    opacity: 0.95;
    z-index: 15;
    overflow-y: auto;
    padding: 12px;
}

.map-help-content {
    font-size: 11px;
    color: var(--text-primary);
    line-height: 1.5;
}

.map-help-content strong {
    display: block;
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.map-help-content strong:first-child {
    margin-top: 0;
}

.map-help-content p {
    margin: 4px 0;
    color: var(--text-dim);
}

.map-help-content ul {
    margin: 0;
    padding-left: 16px;
}

.map-help-content li {
    margin: 2px 0;
}

.map-help-content li b {
    color: var(--text-primary);
}

/* ======================================================================
   Mobile: < 600px wide
   Overlay becomes full-width, bottom-anchored, 40% height
   ====================================================================== */
@media (max-width: 600px) {
    #map-overlay::after {
        display: none;
    }

    #map-overlay {
        position: absolute;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0;
        width: 100% !important;
        height: 40% !important;
        max-width: 100%;
        max-height: 50%;
        border-radius: 4px 4px 0 0;
        resize: none;
    }
}

/* ======================================================================
   Landscape mobile: hide map entirely (too little screen space)
   ====================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    #map-overlay {
        display: none !important;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .map-ctrl-btn {
        padding: 5px 10px;
        font-size: 12px;
        min-width: 32px;
        min-height: 32px;
    }

    .map-ctrl-btn:hover {
        background: color-mix(in srgb, var(--border-color) 10%, transparent);
    }

    .map-ctrl-btn:active {
        background: color-mix(in srgb, var(--border-color) 35%, transparent);
    }

    #map-titlebar {
        padding: 5px 8px;
    }

    #map-controls {
        padding: 4px 6px;
        gap: 3px;
    }

    .map-room-label {
        font-size: 13px;
    }

    .map-gear-item {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 36px;
    }

    .map-zoom-level {
        font-size: 11px;
        min-width: 36px;
    }
}
