/**
 * ZipNode Map – network diagram
 * Base styles apply everywhere (admin, other themes). Theme webapp overrides
 * when inside .framework-map-module / .webapp (benart).
 * Read-only visualisation; does not affect framework posts.
 */

/* Base: layout and defaults (admin, themes without webapp wrapper) */
.zipnode-map {
    display: block;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    position: relative;
    cursor: grab;
}

/* Aspect-ratio mode: height follows width; override theme min-height */
.zipnode-map.zipnode-map--aspect-ratio {
    height: auto;
    min-height: 0;
}

.zipnode-map-zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zipnode-map-zoom-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: #333;
}

.zipnode-map-zoom-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.zipnode-map-zoom-btn:active {
    background: #eee;
}

.zipnode-map-reposition-btn {
    font-size: 18px;
    line-height: 1;
}

.zipnode-map-fullscreen-btn {
    font-size: 18px;
    line-height: 1;
}

.zipnode-map svg {
    display: block;
    width: 100%;
    height: 100%;
}

.zipnode-map .zipnode-map-link {
    fill: none;
    stroke-opacity: 0.6;
    transition: stroke-opacity 0.15s ease, stroke 0.15s ease;
}

.zipnode-map .zipnode-map-link--dimmed {
    stroke-opacity: 0.15;
}

.zipnode-map .zipnode-map-link--highlight {
    stroke-opacity: 1;
    stroke: var(--znmap-link-highlight, #4a90d9);
}

.zipnode-map .zipnode-map-arrow {
    stroke: none;
    pointer-events: none;
    fill-opacity: 0.6;
    transition: fill-opacity 0.15s ease, fill 0.15s ease;
}

.zipnode-map .zipnode-map-arrow--dimmed {
    fill-opacity: 0.15;
}

.zipnode-map .zipnode-map-arrow--highlight {
    fill-opacity: 1;
    fill: var(--znmap-link-highlight, #4a90d9);
}

.zipnode-map .zipnode-map-node {
    cursor: default;
    transition: opacity 0.15s ease;
    /* stroke and stroke-width set from settings in map.js */
}

.zipnode-map .zipnode-map-node--dimmed {
    opacity: 0.35;
}

.zipnode-map .zipnode-map-node--linked {
    cursor: pointer;
}

.zipnode-map .zipnode-map-node--current {
    cursor: default;
    transform-box: fill-box;
    transform-origin: center;
    animation: zipnode-map-node-pulse 2.4s ease-in-out infinite;
}

@keyframes zipnode-map-node-pulse {
    0%, 100% {
        fill: var(--znmap-current-fill);
        stroke-width: var(--znmap-current-stroke-width, 1.5px);
        transform: scale(1);
        filter: drop-shadow(0 0 0 transparent);
    }
    50% {
        fill: var(--znmap-current-bright);
        stroke-width: calc(var(--znmap-current-stroke-width, 1.5px) + 2px);
        transform: scale(1.35);
        filter: drop-shadow(0 0 6px var(--znmap-current-fill));
    }
}

.zipnode-map .zipnode-map-label {
    pointer-events: none;
    user-select: none;
}

.zipnode-map-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 280px;
    white-space: normal;
    opacity: 0;
    transition: none;
}

.zipnode-map-tooltip.is-visible {
    opacity: 1;
}

/* ==========================================================================
   Theme webapp overrides (benart: dark app chrome when inside .framework-map-module)
   ========================================================================== */

/* Theme webapp variables (fallbacks when not benart / in admin) */
.webapp.framework-map-module,
.zipnode-map-preview-wrap.webapp.framework-map-module {
    --znmap-app-bg: var(--app-bg, #0f172a);
    --znmap-app-bg-elevated: var(--app-bg-elevated, #1e293b);
    --znmap-app-text: var(--app-text, #f1f5f9);
    --znmap-app-text-muted: var(--app-text-muted, #94a3b8);
    --znmap-app-border: var(--app-border, #334155);
    --znmap-app-accent: var(--app-accent, #ff6b9d);
    --znmap-app-accent-hover: var(--app-accent-hover, #fda4c8);
}

/* Admin preview: mimic theme webapp card (border-radius, shadow, dark bg) */
.zipnode-map-preview-wrap.webapp.framework-map-module {
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    background: var(--znmap-app-bg);
}

/* Panel content: no max-height for map, allow full diagram */
.framework-map-module .framework-map-container.webapp-panel-content,
.webapp.framework-map-module .framework-map-container {
    max-height: none;
    padding: 0;
    overflow: visible;
}

/* Map canvas – app dark background and border (override inline plugin background) */
.framework-map-module .zipnode-map,
.webapp.framework-map-module .zipnode-map {
    display: block;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--znmap-app-border);
    border-radius: 8px;
    position: relative;
    cursor: grab;
    background: var(--znmap-app-bg) !important;
    min-height: 400px;
}

.framework-map-module .zipnode-map.zipnode-map--aspect-ratio,
.webapp.framework-map-module .zipnode-map.zipnode-map--aspect-ratio {
    min-height: 0;
    height: auto;
}

/* Zoom controls – top right, app-style buttons */
.framework-map-module .zipnode-map-zoom-controls,
.webapp.framework-map-module .zipnode-map-zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.framework-map-module .zipnode-map-zoom-btn,
.webapp.framework-map-module .zipnode-map-zoom-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--znmap-app-border);
    border-radius: 6px;
    background: var(--znmap-app-bg-elevated);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--znmap-app-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.framework-map-module .zipnode-map-zoom-btn:hover,
.webapp.framework-map-module .zipnode-map-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--znmap-app-border);
    color: var(--znmap-app-accent-hover);
}

.framework-map-module .zipnode-map-zoom-btn:active,
.webapp.framework-map-module .zipnode-map-zoom-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

.framework-map-module .zipnode-map-reposition-btn,
.webapp.framework-map-module .zipnode-map-reposition-btn {
    font-size: 18px;
    line-height: 1;
}

.framework-map-module .zipnode-map-fullscreen-btn,
.webapp.framework-map-module .zipnode-map-fullscreen-btn {
    font-size: 18px;
    line-height: 1;
}

/* SVG diagram */
.framework-map-module .zipnode-map svg,
.webapp.framework-map-module .zipnode-map svg {
    display: block;
    width: 100%;
    height: 100%;
}

.framework-map-module .zipnode-map .zipnode-map-link,
.webapp.framework-map-module .zipnode-map .zipnode-map-link {
    fill: none;
    stroke-opacity: 0.6;
}

.framework-map-module .zipnode-map .zipnode-map-link--dimmed,
.webapp.framework-map-module .zipnode-map .zipnode-map-link--dimmed {
    stroke-opacity: 0.15;
}

.framework-map-module .zipnode-map .zipnode-map-link--highlight,
.webapp.framework-map-module .zipnode-map .zipnode-map-link--highlight {
    stroke-opacity: 1;
    stroke: var(--znmap-app-accent, var(--znmap-link-highlight, #4a90d9));
}

.framework-map-module .zipnode-map .zipnode-map-arrow--highlight,
.webapp.framework-map-module .zipnode-map .zipnode-map-arrow--highlight {
    fill-opacity: 1;
    fill: var(--znmap-app-accent, var(--znmap-link-highlight, #4a90d9));
}

.framework-map-module .zipnode-map .zipnode-map-node,
.webapp.framework-map-module .zipnode-map .zipnode-map-node {
    cursor: default;
    /* stroke and stroke-width set from settings in map.js */
}

.framework-map-module .zipnode-map .zipnode-map-node--dimmed,
.webapp.framework-map-module .zipnode-map .zipnode-map-node--dimmed {
    opacity: 0.35;
}

.framework-map-module .zipnode-map .zipnode-map-node--linked,
.webapp.framework-map-module .zipnode-map .zipnode-map-node--linked {
    cursor: pointer;
}

.framework-map-module .zipnode-map .zipnode-map-node--current,
.webapp.framework-map-module .zipnode-map .zipnode-map-node--current {
    cursor: default;
}

.framework-map-module .zipnode-map .zipnode-map-label,
.webapp.framework-map-module .zipnode-map .zipnode-map-label {
    pointer-events: none;
    user-select: none;
    fill: var(--znmap-app-text);
}
