/**
 * Universe Map — Styles für die Blackbox-/Sternenkarten-Map.
 *
 * Enthält die drei Node-Zustände (locked, active, completed),
 * isometrische Box-Visuals, Verbindungslinien und Scan-Effekte.
 *
 * Nutzt ausschließlich CSS Custom Properties aus tokens.css.
 * Kein Tailwind — reines Vanilla CSS.
 *
 * @version 1.0
 * @see docs/conventions/PHASE1_ARCHITECTURE.md
 * @author Alexander Wolf
 */


/* =========================================================
   1. MAP DESIGN TOKENS (Namespace --map-*)
   Alle Magic-Values zentral, keine Hardcodes in Regeln.
   ========================================================= */

:root {
    /* Farben */
    --map-color-primary:        #5b13ec;
    --map-color-primary-glow:   rgba(91, 19, 236, 0.4);
    --map-color-success:        #0bda6f;
    --map-color-success-glow:   rgba(11, 218, 111, 0.3);
    --map-color-locked:         #2f2348;
    --map-color-surface:        #171122;
    --map-color-bg:             #0a0a0a;
    --map-color-text-muted:     #a492c9;

    /* Dimensionen */
    --map-node-size:            80px;
    --map-node-size-active:     96px;
    --map-line-width:           2px;
    --map-perspective:          800px;

    /* Timing */
    --map-transition-fast:      0.3s ease;
    --map-transition-normal:    0.5s ease;
    --map-pulse-duration:       3s;
    --map-scan-duration:        8s;
    --map-signal-duration:      2s;
}


/* =========================================================
   2. KEYFRAME ANIMATIONS
   ========================================================= */

@keyframes map-box-pulse {
    0%, 100% {
        box-shadow: 0 0 15px 2px var(--map-color-primary-glow);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px 8px rgba(91, 19, 236, 0.6);
        transform: scale(1.02);
    }
}

@keyframes map-signal-flow {
    0%   { background-position: 0% 0%; }
    100% { background-position: 0% 200%; }
}

@keyframes map-grid-scan {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

@keyframes map-flicker {
    0%, 19.999%, 22%, 62.999%, 64%, 64.999%, 70%, 100% { opacity: 0.15; }
    20%, 21.999%, 63%, 63.999%, 65%, 69.999%            { opacity: 0.3; }
}

@keyframes map-icon-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}


/* =========================================================
   3. MAP CONTAINER & BACKGROUND
   ========================================================= */

.map-canvas {
    position: relative;
    width: 100%;
    min-height: 100vh;
    background-color: var(--map-color-bg);
    overflow: auto;
}

.map-canvas__grid {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(47, 35, 72, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 35, 72, 0.2) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: map-flicker var(--map-scan-duration) infinite;
    opacity: 0.3;
}

.map-canvas__scan-line {
    position: absolute;
    width: 100%;
    height: 100px;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, rgba(91, 19, 236, 0.1), transparent);
    animation: map-grid-scan var(--map-scan-duration) linear infinite;
}

.map-canvas__radial {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, #1e162e, var(--map-color-bg) 70%);
    opacity: 0.8;
}


/* =========================================================
   4. ISOMETRIC BOX (shared geometry)
   ========================================================= */

.iso-box-container {
    perspective: var(--map-perspective);
    transform-style: preserve-3d;
}

.iso-box {
    position: relative;
    width: var(--map-node-size);
    height: var(--map-node-size);
    transform-style: preserve-3d;
    transform: rotateX(45deg) rotateZ(45deg);
    transition: all var(--map-transition-normal);
}

.iso-box__face {
    position: absolute;
    width: var(--map-node-size);
    height: var(--map-node-size);
    background: var(--map-color-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--map-transition-fast);
}

.iso-box__lid {
    transform: translateZ(10px);
}

.iso-box__side {
    transform: translateY(calc(var(--map-node-size) / 2)) rotateX(90deg);
    transform-origin: top;
}

.iso-box__front {
    transform: translateX(calc(var(--map-node-size) / 2)) rotateY(90deg);
    transform-origin: left;
}


/* =========================================================
   5. NODE STATE: LOCKED
   ========================================================= */

.node-locked {
    cursor: default;
}

.node-locked .iso-box {
    filter: grayscale(1);
}

.node-locked .iso-box__face {
    background: #120e1a;
    border-color: var(--map-color-locked);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.node-locked .iso-box__lid {
    transform: translateZ(0);
}

.node-locked .node__label {
    color: #6b7280;
    font-family: var(--font-mono, monospace);
    letter-spacing: 0.05em;
}

.node-locked .node__icon {
    color: #6b7280;
}

.node-locked .iso-box-container {
    opacity: 0.6;
    transition: opacity var(--map-transition-fast);
}

.node-locked:hover .iso-box-container {
    opacity: 1;
}


/* =========================================================
   6. NODE STATE: ACTIVE (unlocked, playable)
   ========================================================= */

.node-active {
    cursor: pointer;
}

.node-active .iso-box {
    animation: map-box-pulse var(--map-pulse-duration) infinite;
}

.node-active .iso-box__face {
    border-color: var(--map-color-primary);
    background: rgba(91, 19, 236, 0.1);
    box-shadow:
        0 0 15px var(--map-color-primary-glow),
        inset 0 0 10px rgba(91, 19, 236, 0.2);
}

.node-active .iso-box__lid {
    transform: translateZ(20px);
}

.node-active .iso-box__side {
    background: #1a122e;
}

.node-active .iso-box__front {
    background: #150e26;
}

.node-active .node__glow {
    position: absolute;
    inset: 0;
    transform: translateZ(10px);
    background: var(--map-color-primary);
    opacity: 0.2;
    filter: blur(8px);
    pointer-events: none;
}

.node-active .node__label {
    color: #ffffff;
    font-weight: 700;
}

.node-active .node__icon {
    color: var(--map-color-primary);
    animation: map-icon-pulse 2s ease-in-out infinite;
}

.node-active .iso-box-container {
    transition: transform var(--map-transition-fast);
}

.node-active:hover .iso-box-container {
    transform: scale(1.1);
}


/* =========================================================
   7. NODE STATE: COMPLETED
   ========================================================= */

.node-completed {
    cursor: pointer;
}

.node-completed .iso-box__face {
    border-color: var(--map-color-success);
    background: rgba(11, 218, 111, 0.05);
    box-shadow: 0 0 10px var(--map-color-success-glow);
}

.node-completed .iso-box__lid {
    transform: translateZ(35px) rotateX(-20deg);
    opacity: 0.8;
}

.node-completed .iso-box__side {
    background: #0f2c1f;
}

.node-completed .iso-box__front {
    background: #0b2218;
}

.node-completed .node__label {
    color: var(--map-color-success);
    font-weight: 700;
    text-shadow: 0 0 10px var(--map-color-success-glow);
}

.node-completed .node__icon {
    color: var(--map-color-success);
    filter: drop-shadow(0 0 10px rgba(11, 218, 111, 0.8));
}

.node-completed .iso-box-container {
    transition: transform var(--map-transition-fast);
}

.node-completed:hover .iso-box-container {
    transform: scale(1.05);
}


/* =========================================================
   8. CONNECTION LINES (Abhängigkeiten zwischen Nodes)
   ========================================================= */

.node-connection {
    position: absolute;
    z-index: -1;
    width: var(--map-line-width);
    background: var(--map-color-locked);
    overflow: hidden;
    pointer-events: none;
}

.node-connection--completed {
    background: #1e3a2f;
}

.node-connection--completed::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent, var(--map-color-success), transparent);
    background-size: 100% 200%;
    animation: map-signal-flow var(--map-signal-duration) linear infinite;
}


/* =========================================================
   9. NODE LAYOUT (gemeinsames Spacing)
   ========================================================= */

.node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg, 1.5rem);
    z-index: 10;
}

.node__label {
    padding: var(--space-xs, 0.25rem) var(--space-md, 1rem);
    border-radius: var(--border-radius, 6px);
    font-size: var(--font-size-sm, 0.85rem);
    white-space: nowrap;
    background: rgba(23, 17, 34, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.node__badge {
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 20;
    background: var(--map-color-primary);
    color: #ffffff;
    box-shadow: 0 0 15px var(--map-color-primary);
}


/* =========================================================
   10. GLASS PANEL (Sidebar, Overlays)
   ========================================================= */

.glass-panel {
    background: rgba(30, 22, 46, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}


/* =========================================================
   11. GALAXY CLUSTER (visuelle Gruppierung)
   ========================================================= */

.galaxy {
    position: relative;
    padding: var(--space-2xl, 3rem);
}

.galaxy__title {
    font-size: var(--font-size-xl, 1.5rem);
    font-weight: 700;
    color: var(--map-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-xl, 2rem);
}

.galaxy__outline {
    position: absolute;
    inset: 0;
    border: 1px dashed rgba(91, 19, 236, 0.15);
    border-radius: 24px;
    pointer-events: none;
}


/* =========================================================
   12. STORAGE NOTICE BANNER
   ========================================================= */

.storage-notice {
    position: fixed;
    bottom: var(--space-lg, 1.5rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    max-width: 480px;
    width: calc(100% - 2 * var(--space-lg, 1.5rem));
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    border-radius: var(--border-radius-lg, 8px);
    font-size: var(--font-size-sm, 0.85rem);
    color: var(--map-color-text-muted);
    background: rgba(30, 22, 46, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.storage-notice--hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.storage-notice__btn {
    display: inline-block;
    margin-top: var(--space-sm, 0.5rem);
    padding: var(--space-xs, 0.25rem) var(--space-md, 1rem);
    border: none;
    border-radius: var(--border-radius, 6px);
    font-size: var(--font-size-sm, 0.85rem);
    font-weight: 600;
    color: #ffffff;
    background: var(--map-color-primary);
    cursor: pointer;
    transition: background var(--map-transition-fast);
}

.storage-notice__btn:hover {
    background: #4a0ec5;
}


/* =========================================================
   13. CHALLENGE MODAL / OVERLAY
   ========================================================= */

.challenge-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.challenge-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

.challenge-overlay__frame {
    width: 90vw;
    height: 80vh;
    max-width: 1200px;
    border: 1px solid var(--map-color-locked);
    border-radius: var(--border-radius-lg, 8px);
    background: var(--map-color-surface);
    box-shadow: 0 0 40px rgba(91, 19, 236, 0.2);
}

.challenge-overlay__close {
    position: absolute;
    top: var(--space-md, 1rem);
    right: var(--space-md, 1rem);
    width: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    font-size: var(--font-size-lg, 1.2rem);
    color: var(--map-color-text-muted);
    background: rgba(47, 35, 72, 0.6);
    cursor: pointer;
    transition: background var(--map-transition-fast);
}

.challenge-overlay__close:hover {
    background: rgba(91, 19, 236, 0.4);
    color: #ffffff;
}


/* =========================================================
   14. RESPONSIVE
   Breakpoints: 480px (sm), 768px (md), 1024px (lg)
   per ENGINEERING_CONVENTIONS §9
   ========================================================= */

@media (max-width: 768px) {
    :root {
        --map-node-size: 60px;
        --map-node-size-active: 72px;
    }

    .challenge-overlay__frame {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
    }

    .node__label {
        font-size: var(--font-size-xs, 0.75rem);
    }
}

@media (max-width: 480px) {
    :root {
        --map-node-size: 48px;
        --map-node-size-active: 56px;
    }
}
