/* ═══════════════════════════════════════════════
   SPG — MISSION MAP: TACTICAL STAR CHART
   Design Tokens: Ciano (#00FFCC), Magenta (#FF0066)
   ═══════════════════════════════════════════════ */

:root {
    --primary: #00FFCC;
    --primary-dim: rgba(0, 255, 204, 0.2);
    --primary-glow: 0 0 20px #00FFCC, 0 0 40px #00FFCC44;
    --secondary: #FF0066;
    --secondary-dim: rgba(255, 0, 102, 0.3);
    --accent: #FFD700;
    --accent-dim: rgba(255, 215, 0, 0.3);
    --bg: #030308;
    --surface: rgba(8, 8, 20, 0.85);
    --text: #e0e0e0;
    --text-dim: #666;
    --font-main: 'Orbitron', sans-serif;
    --font-alt: 'Outfit', sans-serif;
    --transition: 0.3s ease;

    /* Mission Type Colors */
    --color-surface: #00FFCC;
    --color-cave: #bf5af2;
    --color-space: #5e9eff;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: var(--bg); font-family: var(--font-main); color: var(--text);
}

/* ─── Starfield Canvas ─── */
#starfieldCanvas {
    position: fixed; inset: 0; z-index: 0;
    width: 100%; height: 100%;
}

/* ─── Tactical Grid ─── */
.tactical-grid {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background-image:
        linear-gradient(rgba(0, 255, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 204, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 30%, transparent 100%);
}

/* ─── Scanline ─── */
.scanline-overlay {
    position: fixed; inset: 0; z-index: 2; pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px);
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.map-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 2rem;
    background: linear-gradient(180deg, rgba(3,3,8,0.95) 0%, rgba(3,3,8,0.6) 80%, transparent 100%);
    border-bottom: 1px solid rgba(0, 255, 204, 0.08);
}

.header-left { display: flex; align-items: center; gap: 0.8rem; }

.nav-back {
    color: var(--primary); text-decoration: none;
    font-size: 0.55rem; letter-spacing: 0.15em;
    padding: 0.4rem 0.8rem; border: 1px solid var(--primary-dim);
    transition: var(--transition);
}
.nav-back:hover { background: var(--primary-dim); box-shadow: 0 0 10px var(--primary-dim); }

.header-separator { color: rgba(255,255,255,0.1); font-size: 0.8rem; }

.header-center { text-align: center; }

.map-title {
    font-size: 1.3rem; font-weight: 900; color: var(--primary);
    letter-spacing: 0.2em; text-shadow: var(--primary-glow);
}

.map-subtitle {
    font-size: 0.5rem; letter-spacing: 0.5em;
    color: var(--primary); opacity: 0.4; margin-top: 0.2rem;
}

.header-right { display: flex; align-items: center; gap: 1.5rem; }

.signal-indicator { display: flex; align-items: center; gap: 0.5rem; }

.signal-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--primary); box-shadow: 0 0 8px var(--primary);
    animation: signalPulse 2s ease-in-out infinite;
}

.signal-text { font-size: 0.5rem; color: var(--primary); letter-spacing: 0.15em; opacity: 0.7; }

.mission-count { display: flex; align-items: baseline; gap: 0.5rem; }
.count-label { font-size: 0.5rem; color: var(--text-dim); letter-spacing: 0.1em; }
.count-value { font-size: 1rem; font-weight: 900; color: var(--accent); text-shadow: 0 0 10px var(--accent-dim); }

/* ─── Glitch ─── */
.glitch { position: relative; }
.glitch::before, .glitch::after {
    content: attr(data-text); position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; opacity: 0.6;
}
.glitch::before {
    color: var(--secondary); animation: glitch1 4s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}
.glitch::after {
    color: var(--primary); animation: glitch2 4s infinite linear alternate-reverse;
    clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}

/* ═══════════════════════════════════════
   MAP VIEWPORT
   ═══════════════════════════════════════ */
.map-viewport {
    position: fixed; inset: 0; z-index: 10;
    padding-top: 70px; padding-bottom: 50px;
    overflow: hidden;
}

/* ─── SVG Route Lines ─── */
.route-lines {
    position: absolute; inset: 0; z-index: 1;
    width: 100%; height: 100%; pointer-events: none;
}

.route-line {
    stroke: var(--primary); stroke-width: 1.2;
    stroke-dasharray: 8 6; opacity: 0.25;
    filter: drop-shadow(0 0 3px var(--primary));
    animation: routeDash 20s linear infinite;
}

.route-line--active {
    stroke-width: 2; opacity: 0.6;
    stroke-dasharray: 12 4;
}

/* ─── Origin Node (HQ) ─── */
.origin-node {
    position: absolute; z-index: 20;
    left: 8%; top: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}

.origin-pulse {
    position: absolute; width: 80px; height: 80px;
    border-radius: 50%; border: 1px solid var(--primary);
    animation: originPulse 3s ease-out infinite;
    opacity: 0;
}

.origin-icon {
    font-size: 2.5rem; color: var(--primary);
    text-shadow: var(--primary-glow);
    filter: drop-shadow(0 0 15px var(--primary));
    animation: float 4s ease-in-out infinite;
}

.origin-label {
    font-size: 0.55rem; letter-spacing: 0.3em;
    color: var(--primary); opacity: 0.8;
    background: rgba(0, 255, 204, 0.08);
    padding: 0.25rem 0.6rem; border: 1px solid var(--primary-dim);
}

/* ═══════════════════════════════════════
   MISSION NODES
   ═══════════════════════════════════════ */
.mission-nodes {
    position: absolute; inset: 0; z-index: 15;
}

.mission-node {
    position: absolute;
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    cursor: pointer; transition: transform 0.3s ease;
    transform: translate(-50%, -50%);
}

.mission-node:hover { transform: translate(-50%, -50%) scale(1.15); }
.mission-node:hover .node-core { box-shadow: 0 0 30px var(--node-color, var(--primary)); }

.node-orbit {
    position: absolute; width: 60px; height: 60px;
    border-radius: 50%; border: 1px dashed var(--node-color, var(--primary));
    opacity: 0.2; animation: orbitSpin 15s linear infinite;
}

.node-core {
    width: 36px; height: 36px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--node-color, var(--primary)), rgba(0,0,0,0.8));
    border: 2px solid var(--node-color, var(--primary));
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.3), inset 0 0 15px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    position: relative; z-index: 2;
}

.node-core::after {
    content: ''; position: absolute;
    top: 20%; left: 25%; width: 30%; height: 20%;
    background: rgba(255,255,255,0.4); border-radius: 50%;
    transform: rotate(-30deg);
}

.node-label {
    font-size: 0.5rem; letter-spacing: 0.15em;
    color: var(--node-color, var(--primary));
    background: rgba(0,0,0,0.7); padding: 0.15rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap; max-width: 120px;
    overflow: hidden; text-overflow: ellipsis;
    transition: var(--transition);
}

.node-index {
    font-size: 0.4rem; color: var(--text-dim);
    letter-spacing: 0.2em;
}

/* Node States */
.mission-node--selected .node-core {
    border-width: 3px;
    box-shadow: 0 0 35px var(--node-color, var(--primary)), 0 0 60px rgba(0,255,204,0.15);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

.mission-node--selected .node-label {
    background: var(--node-color, var(--primary));
    color: #000; font-weight: 700;
}

/* Node Type Variations */
.mission-node--surface { --node-color: var(--color-surface); }
.mission-node--cave { --node-color: var(--color-cave); }
.mission-node--space { --node-color: var(--color-space); }

/* Mission Status Colors */
.mission-node--completed .node-core {
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary);
}
.mission-node--completed .node-label {
    border-color: var(--primary);
    opacity: 0.6;
}

.mission-node--locked {
    cursor: not-allowed;
    filter: grayscale(1) brightness(0.4);
}
.mission-node--locked .node-core {
    background: #333;
    border-color: #555;
    box-shadow: none;
}
.mission-node--locked .node-orbit { display: none; }

.mission-node--next .node-core {
    animation: selectedPulse 2s infinite;
}
.mission-node--next .node-label {
    box-shadow: 0 0 10px var(--primary-dim);
    border-color: var(--primary);
}

/* ═══════════════════════════════════════
   DETAIL PANEL (Sidebar)
   ═══════════════════════════════════════ */
.mission-detail-panel {
    position: fixed; top: 60px; right: -400px; bottom: 50px;
    width: 360px; z-index: 200;
    background: rgba(5, 5, 15, 0.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--primary-dim);
    border-top: 1px solid rgba(0,255,204,0.08);
    padding: 1.5rem;
    display: flex; flex-direction: column;
    transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}

.mission-detail-panel.open { right: 0; }

.detail-header {
    display: flex; justify-content: space-between; align-items: center;
}

.detail-title {
    font-size: 0.85rem; letter-spacing: 0.15em; color: var(--primary);
    border-left: 3px solid var(--primary); padding-left: 0.8rem;
}

.btn-close-detail {
    background: none; border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-dim); font-size: 0.8rem;
    width: 30px; height: 30px; cursor: pointer;
    transition: var(--transition); font-family: var(--font-main);
}
.btn-close-detail:hover { border-color: var(--secondary); color: var(--secondary); }

.detail-divider {
    height: 1px; margin: 1rem 0;
    background: linear-gradient(90deg, var(--primary-dim), transparent);
}

.detail-body { flex: 1; overflow-y: auto; }
.detail-hint { font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.1em; line-height: 1.8; }

/* Detail Content */
.detail-field {
    margin-bottom: 1.2rem;
}

.detail-field-label {
    font-size: 0.45rem; letter-spacing: 0.25em;
    color: var(--text-dim); margin-bottom: 0.3rem;
}

.detail-field-value {
    font-size: 0.75rem; color: #fff;
    letter-spacing: 0.05em;
}

.detail-color-row {
    display: flex; gap: 0.5rem; margin-top: 0.3rem;
}

.detail-color-swatch {
    width: 24px; height: 24px; border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
}

.detail-tag {
    display: inline-block; padding: 0.2rem 0.5rem;
    font-size: 0.5rem; letter-spacing: 0.15em;
    border-radius: 3px; font-weight: 700;
}

.detail-tag--surface { background: rgba(0,255,204,0.15); color: var(--color-surface); border: 1px solid rgba(0,255,204,0.3); }
.detail-tag--cave { background: rgba(191,90,242,0.15); color: var(--color-cave); border: 1px solid rgba(191,90,242,0.3); }
.detail-tag--space { background: rgba(94,158,255,0.15); color: var(--color-space); border: 1px solid rgba(94,158,255,0.3); }

/* Preview Mini Canvas */
.detail-preview {
    width: 100%; aspect-ratio: 16/9;
    background: #000; border: 1px solid rgba(255,255,255,0.08);
    border-radius: 4px; margin-top: 0.5rem; overflow: hidden;
    position: relative;
}

.detail-preview-gradient {
    width: 100%; height: 100%;
}

/* Detail Actions */
.detail-actions {
    display: flex; flex-direction: column; gap: 0.6rem;
    padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.05);
}

.btn-action {
    display: block; text-align: center;
    padding: 0.7rem; font-family: var(--font-main);
    font-size: 0.6rem; letter-spacing: 0.15em;
    cursor: pointer; transition: var(--transition);
    text-decoration: none; font-weight: 700;
    border: none;
}

.btn-edit {
    background: transparent; border: 1px solid var(--primary-dim);
    color: var(--primary);
}
.btn-edit:hover { background: var(--primary-dim); }

.btn-launch {
    background: var(--primary); color: #000;
}
.btn-launch:hover { background: #00e6b8; box-shadow: 0 0 20px var(--primary-dim); }

/* ═══════════════════════════════════════
   LOADER & EMPTY
   ═══════════════════════════════════════ */
.map-loader {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
    z-index: 50;
}

.loader-ring {
    width: 60px; height: 60px; border-radius: 50%;
    border: 2px solid transparent; border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px var(--primary-dim);
}

.loader-text { font-size: 0.7rem; letter-spacing: 0.3em; color: var(--primary); }

.map-empty {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 1rem;
    z-index: 50;
}

.empty-icon { font-size: 3rem; opacity: 0.4; animation: float 5s ease-in-out infinite; }
.empty-text { font-size: 0.65rem; color: var(--text-dim); letter-spacing: 0.2em; text-align: center; }

.btn-create {
    color: var(--primary); text-decoration: none;
    font-size: 0.6rem; letter-spacing: 0.15em;
    padding: 0.6rem 1.2rem; border: 1px solid var(--primary);
    transition: var(--transition);
}
.btn-create:hover { background: var(--primary-dim); box-shadow: 0 0 15px var(--primary-dim); }

/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */
.map-footer {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 2rem;
    background: linear-gradient(0deg, rgba(3,3,8,0.95), transparent);
    border-top: 1px solid rgba(0,255,204,0.05);
    font-size: 0.5rem;
}

.footer-coords { display: flex; gap: 0.4rem; align-items: baseline; }
.coord-label { color: var(--text-dim); letter-spacing: 0.1em; }
.coord-value { color: var(--primary); letter-spacing: 0.15em; font-weight: 700; }

.footer-legend { display: flex; gap: 1.5rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; color: var(--text-dim); letter-spacing: 0.1em; }

.legend-dot {
    width: 8px; height: 8px; border-radius: 50%;
}
.legend-dot--surface { background: var(--color-surface); box-shadow: 0 0 6px var(--color-surface); }
.legend-dot--cave { background: var(--color-cave); box-shadow: 0 0 6px var(--color-cave); }
.legend-dot--space { background: var(--color-space); box-shadow: 0 0 6px var(--color-space); }

.footer-version { color: var(--text-dim); letter-spacing: 0.15em; opacity: 0.5; }

/* ─── Toast ─── */
.notification-container {
    position: fixed; top: 5rem; right: 2rem; z-index: 10000;
    display: flex; flex-direction: column; gap: 10px;
}

.toast {
    background: rgba(5, 5, 20, 0.95); backdrop-filter: blur(10px);
    border: 1px solid var(--primary-dim); border-left: 4px solid var(--primary);
    padding: 0.8rem 1.2rem; color: var(--text); font-family: var(--font-main);
    font-size: 0.6rem; letter-spacing: 0.1em;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 20px var(--primary-dim);
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes signalPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--primary); }
    50% { opacity: 0.4; box-shadow: 0 0 3px var(--primary); }
}

@keyframes originPulse {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes orbitSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 25px var(--node-color); }
    50% { box-shadow: 0 0 45px var(--node-color), 0 0 80px rgba(0,255,204,0.1); }
}

@keyframes routeDash {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -200; }
}

@keyframes nodeAppear {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

@keyframes glitch1 {
    0% { transform: translate(0); } 20% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, -1px); } 60% { transform: translate(-1px, 1px); }
    80% { transform: translate(1px, -1px); } 100% { transform: translate(0); }
}

@keyframes glitch2 {
    0% { transform: translate(0); } 20% { transform: translate(1px, -1px); }
    40% { transform: translate(-2px, 1px); } 60% { transform: translate(1px, 1px); }
    80% { transform: translate(-1px, -1px); } 100% { transform: translate(0); }
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .map-header { flex-direction: column; gap: 0.5rem; padding: 0.5rem 1rem; }
    .header-left, .header-right { gap: 0.5rem; }
    .mission-detail-panel { width: 300px; }
    .footer-legend { display: none; }
}

@media (max-width: 600px) {
    .mission-detail-panel { width: 100%; right: -100%; }
    .map-title { font-size: 0.9rem; }
}
