/* ============================================
   NAVIGATION.CSS - STARFIELD NAVIGATION
   "I Am Everywhere" - Fullscreen Planet Navigation

   Star trigger opens a fullscreen cosmos where
   each page is a floating planet. Modern,
   responsive, keyboard-friendly.
   ============================================ */

/* ===== NAV TRIGGER (floating star) ===== */
.nav-trigger {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 0px) + 10px);
    right: max(20px, env(safe-area-inset-right, 0px) + 10px);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 31, 58, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 2px solid var(--holo-pink-mid);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1400;
    box-shadow: 0 0 20px var(--holo-pink-glow), inset 0 0 15px rgba(255, 110, 199, 0.1);
    transition: transform 0.3s var(--ease-holo), box-shadow 0.3s var(--ease-holo), border-color 0.3s var(--ease-holo);
}

    .nav-trigger:hover,
    .nav-trigger:focus-visible {
        transform: scale(1.1) rotate(15deg);
        border-color: var(--halo-purple-bright);
        box-shadow: 0 0 35px var(--halo-purple-glow), 0 0 60px rgba(216, 180, 254, 0.3), inset 0 0 20px rgba(199, 125, 255, 0.15);
    }

.nav-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: trigger-star-spin 12s linear infinite;
}

    .nav-trigger-icon img {
        width: 30px;
        height: auto;
        filter: drop-shadow(0 0 8px var(--holo-pink-glow));
    }

@keyframes trigger-star-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Pulsing halo ring around the trigger */
.nav-trigger-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--halo-purple-glow);
    pointer-events: none;
    animation: trigger-ring-pulse 3s ease-in-out infinite;
}

@keyframes trigger-ring-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.18);
        opacity: 0;
    }
}

/* ===== FULLSCREEN STARFIELD OVERLAY ===== */
.nav-starfield {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(60px, 10vh, 100px) clamp(10px, 3vw, 30px) clamp(20px, 5vh, 50px);
    background: radial-gradient(ellipse at 50% 30%, var(--cosmos-light) 0%, var(--cosmos-mid) 45%, var(--cosmos-deep) 100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-holo), visibility 0.4s;
    overflow-y: auto;
    overscroll-behavior: contain;
}

    .nav-starfield.is-open {
        opacity: 1;
        visibility: visible;
    }

/* ===== STARFIELD BACKGROUND LAYERS ===== */
.starfield-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.star-layer {
    position: absolute;
    inset: -50%;
    background-repeat: repeat;
    background-size: 220px 220px;
}

.star-layer-1 {
    background-image: radial-gradient(1.5px 1.5px at 25px 35px, var(--holo-white), transparent), radial-gradient(1px 1px at 120px 90px, var(--holo-pink-soft), transparent), radial-gradient(1px 1px at 190px 150px, var(--holo-cyan), transparent), radial-gradient(1.5px 1.5px at 70px 180px, var(--halo-purple-bright), transparent);
    animation: star-twinkle 4s ease-in-out infinite, star-drift 90s linear infinite;
}

.star-layer-2 {
    background-image: radial-gradient(1px 1px at 55px 65px, var(--holo-pink-mid), transparent), radial-gradient(2px 2px at 155px 25px, var(--holo-white), transparent), radial-gradient(1px 1px at 95px 130px, var(--halo-purple-mid), transparent), radial-gradient(1px 1px at 200px 190px, var(--holo-cyan), transparent);
    background-size: 280px 280px;
    animation: star-twinkle 6s ease-in-out infinite 1s, star-drift 140s linear infinite reverse;
}

.star-layer-3 {
    background-image: radial-gradient(1px 1px at 40px 100px, var(--holo-white), transparent), radial-gradient(1px 1px at 170px 60px, var(--holo-pink-bright), transparent), radial-gradient(1.5px 1.5px at 110px 200px, var(--halo-purple-bright), transparent);
    background-size: 340px 340px;
    animation: star-twinkle 8s ease-in-out infinite 2s, star-drift 200s linear infinite;
}

@keyframes star-twinkle {
    0%, 100% {
        opacity: 0.9;
    }

    50% {
        opacity: 0.45;
    }
}

@keyframes star-drift {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(60px, 40px);
    }
}

/* Occasional shooting stars */
.shooting-star {
    position: absolute;
    top: 15%;
    left: -10%;
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--holo-white), var(--holo-pink-bright));
    border-radius: 2px;
    transform: rotate(-20deg);
    opacity: 0;
    animation: shooting 9s linear infinite 2s;
}

.shooting-star-2 {
    top: 55%;
    width: 90px;
    animation: shooting 13s linear infinite 7s;
}

@keyframes shooting {
    0%, 92% {
        opacity: 0;
        transform: translateX(0) rotate(-20deg);
    }

    93% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateX(120vw) rotate(-20deg);
    }
}

/* ===== OVERLAY TITLE ===== */
.starfield-title {
    position: relative;
    margin: 0 0 clamp(20px, 4vh, 40px);
    font-family: 'Georgia', serif;
    font-size: clamp(18px, 3vw, 26px);
    font-style: italic;
    letter-spacing: 3px;
    color: var(--holo-pink-soft);
    text-shadow: 0 0 20px var(--holo-pink-glow), 0 0 40px rgba(199, 125, 255, 0.4);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.5s var(--ease-holo) 0.2s, transform 0.5s var(--ease-holo) 0.2s;
}

.nav-starfield.is-open .starfield-title {
    opacity: 1;
    transform: translateY(0);
}

/* ===== CLOSE BUTTON ===== */
.nav-close {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 0px) + 10px);
    right: max(20px, env(safe-area-inset-right, 0px) + 10px);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 31, 58, 0.7);
    border: 2px solid var(--holo-pink-mid);
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.3s var(--ease-holo), border-color 0.3s var(--ease-holo), box-shadow 0.3s var(--ease-holo);
    box-shadow: 0 0 15px var(--holo-pink-glow);
}

    .nav-close:hover,
    .nav-close:focus-visible {
        transform: rotate(90deg) scale(1.1);
        border-color: var(--holo-pink-bright);
        box-shadow: 0 0 30px var(--holo-pink-glow);
    }

.nav-close-icon {
    font-size: 32px;
    line-height: 1;
    color: var(--holo-pink-soft);
    text-shadow: 0 0 10px var(--holo-pink-glow);
}

/* ===== GALAXY STAR MAP =====
   Pages are stars in a connected constellation —
   scattered across the cosmos, joined by light. */
.planets-container {
    position: relative;
    width: min(1100px, 100%, calc((100dvh - 240px) * 1.5));
    aspect-ratio: 16 / 10;
    margin: 0 auto;
}

.constellation-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

    .constellation-lines line {
        stroke: rgba(216, 180, 254, 0.35);
        stroke-width: 1.5;
        stroke-linecap: round;
        filter: drop-shadow(0 0 4px rgba(199, 125, 255, 0.5));
    }

/* ===== STAR NODES ===== */
.planet {
    position: absolute;
    left: var(--x);
    top: var(--y);
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    text-align: center;
    z-index: 1;
    /* staggered reveal */
    opacity: 0;
    scale: 0.4;
    transition: opacity 0.5s var(--ease-holo) calc(var(--planet-index) * 70ms + 0.15s), scale 0.5s var(--ease-holo) calc(var(--planet-index) * 70ms + 0.15s);
}

.nav-starfield.is-open .planet {
    opacity: 1;
    scale: 1;
}

/* Star-map coordinates — a web radiating from Home */
.planet-home {
    --x: 50%;
    --y: 44%;
}

.planet-contact {
    --x: 50%;
    --y: 10%;
}

.planet-journey {
    --x: 30%;
    --y: 19%;
}

.planet-memories {
    --x: 70%;
    --y: 17%;
}

.planet-legacy {
    --x: 12%;
    --y: 40%;
}

.planet-footprints {
    --x: 88%;
    --y: 36%;
}

.planet-resources {
    --x: 13%;
    --y: 72%;
}

.planet-lullabies {
    --x: 88%;
    --y: 68%;
}

.planet-snapshots {
    --x: 33%;
    --y: 82%;
}

.planet-heartbeat {
    --x: 67%;
    --y: 80%;
}

.planet-support {
    --x: 50%;
    --y: 91%;
}

/* ===== STAR CORES ===== */
.planet-orb {
    --orb-a: var(--holo-pink-bright);
    --orb-b: var(--halo-purple-deep);
    position: relative;
    width: clamp(48px, 6.5vw, 68px);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5) 0%, transparent 30%), radial-gradient(circle at 50% 50%, var(--orb-a) 0%, var(--orb-b) 68%, transparent 100%);
    box-shadow: 0 0 18px color-mix(in srgb, var(--orb-a) 65%, transparent), 0 0 45px color-mix(in srgb, var(--orb-b) 35%, transparent);
    animation: star-node-twinkle 5s ease-in-out infinite;
    animation-delay: calc(var(--planet-index) * -0.8s);
    transition: box-shadow 0.3s var(--ease-holo), scale 0.3s var(--ease-holo);
}

/* Four-point star flare behind each core */
    .planet-orb::before {
        content: '';
        position: absolute;
        inset: -45%;
        background: linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.35) 50%, transparent 54%), linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.35) 50%, transparent 54%);
        opacity: 0.5;
        pointer-events: none;
        animation: flare-twinkle 4s ease-in-out infinite;
        animation-delay: calc(var(--planet-index) * -0.6s);
    }

    /* Orbital halo ring, revealed on hover/focus */
    .planet-orb::after {
        content: '';
        position: absolute;
        inset: -9px;
        border-radius: 50%;
        border: 2px solid var(--halo-purple-bright);
        opacity: 0;
        scale: 0.8;
        transition: opacity 0.3s var(--ease-holo), scale 0.3s var(--ease-holo);
        box-shadow: 0 0 15px var(--halo-purple-glow);
    }

@keyframes star-node-twinkle {
    0%, 100% {
        box-shadow: 0 0 18px color-mix(in srgb, var(--orb-a) 65%, transparent), 0 0 45px color-mix(in srgb, var(--orb-b) 35%, transparent);
    }

    50% {
        box-shadow: 0 0 28px color-mix(in srgb, var(--orb-a) 85%, transparent), 0 0 65px color-mix(in srgb, var(--orb-b) 50%, transparent);
    }
}

@keyframes flare-twinkle {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 0.2;
        transform: scale(0.85);
    }
}

.planet:hover .planet-orb,
.planet:focus-visible .planet-orb {
    scale: 1.15;
    box-shadow: 0 0 30px color-mix(in srgb, var(--orb-a) 90%, transparent), 0 0 70px var(--halo-purple-glow);
}

    .planet:hover .planet-orb::after,
    .planet:focus-visible .planet-orb::after {
        opacity: 1;
        scale: 1;
    }

.planet:focus-visible {
    outline: none;
}

.planet-icon-img {
    width: 62%;
    height: 62%;
    object-fit: contain;
    filter: drop-shadow(0 0 8px var(--holo-pink-glow));
    z-index: 2;
}

/* Home — the heart of the universe, brightest star */
.planet-home .planet-orb {
    width: clamp(60px, 8vw, 84px);
}

.planet-home .planet-icon-img {
    width: 58%;
    height: 58%;
}

/* Per-star color identities */
.planet-home .planet-orb {
    --orb-a: #ffd700;
    --orb-b: #b8860b;
}

.planet-journey .planet-orb {
    --orb-a: var(--holo-pink-bright);
    --orb-b: #a3427f;
}

.planet-legacy .planet-orb {
    --orb-a: var(--halo-purple-bright);
    --orb-b: #6d28d9;
}

.planet-memories .planet-orb {
    --orb-a: var(--holo-cyan);
    --orb-b: #0369a1;
}

.planet-footprints .planet-orb {
    --orb-a: var(--holo-pink-mid);
    --orb-b: #9d5c8f;
}

.planet-resources .planet-orb {
    --orb-a: #86efac;
    --orb-b: #15803d;
}

.planet-snapshots .planet-orb {
    --orb-a: #fcd34d;
    --orb-b: #b45309;
}

.planet-heartbeat .planet-orb {
    --orb-a: #fda4af;
    --orb-b: #be123c;
}

.planet-lullabies .planet-orb {
    --orb-a: #a5b4fc;
    --orb-b: #4338ca;
}

.planet-contact .planet-orb {
    --orb-a: var(--holo-cyan);
    --orb-b: #155e75;
}

.planet-support .planet-orb {
    --orb-a: var(--halo-purple-bright);
    --orb-b: var(--holo-pink-bright);
}

/* ===== STAR LABELS ===== */
.planet-label {
    font-family: 'Georgia', serif;
    font-size: clamp(12px, 1.5vw, 15px);
    font-weight: 600;
    letter-spacing: 1px;
    white-space: nowrap;
    color: var(--holo-pink-soft);
    text-shadow: 0 0 10px var(--holo-pink-glow), 0 2px 6px rgba(10, 14, 39, 0.9);
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.planet:hover .planet-label,
.planet:focus-visible .planet-label {
    color: var(--holo-white);
    text-shadow: 0 0 15px var(--halo-purple-glow), 0 0 30px var(--holo-pink-glow);
}

.planet-tagline {
    position: absolute;
    top: 100%;
    font-size: 11px;
    white-space: nowrap;
    color: var(--starlight);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    text-shadow: 0 2px 6px rgba(10, 14, 39, 0.9);
    pointer-events: none;
}

.planet:hover .planet-tagline,
.planet:focus-visible .planet-tagline {
    opacity: 0.85;
    transform: translateY(0);
}

/* ===== RESPONSIVE — winding star path on small screens ===== */
@media (max-width: 700px) {
    .planets-container {
        width: 100%;
        aspect-ratio: 10 / 16;
        max-width: 420px;
    }

    .planet-orb {
        width: clamp(46px, 13vw, 60px);
    }

    .planet-home .planet-orb {
        width: clamp(56px, 16vw, 72px);
    }

    .planet-tagline {
        display: none;
    }

    /* Winding path: Home leads the descent */
    .planet-home {
        --x: 50%;
        --y: 6%;
    }

    .planet-journey {
        --x: 24%;
        --y: 15%;
    }

    .planet-legacy {
        --x: 74%;
        --y: 22%;
    }

    .planet-memories {
        --x: 26%;
        --y: 31%;
    }

    .planet-footprints {
        --x: 75%;
        --y: 39%;
    }

    .planet-resources {
        --x: 25%;
        --y: 47%;
    }

    .planet-snapshots {
        --x: 73%;
        --y: 55%;
    }

    .planet-heartbeat {
        --x: 26%;
        --y: 63%;
    }

    .planet-lullabies {
        --x: 74%;
        --y: 71%;
    }

    .planet-contact {
        --x: 28%;
        --y: 79%;
    }

    .planet-support {
        --x: 50%;
        --y: 90%;
    }

    .nav-trigger {
        width: 54px;
        height: 54px;
    }

        .nav-trigger-icon img {
            width: 26px;
        }

    .nav-close {
        width: 48px;
        height: 48px;
    }
}

/* Short landscape phones: let the map breathe and scroll */
@media (max-height: 500px) {
    .nav-starfield {
        justify-content: flex-start;
    }

    .starfield-title {
        margin-bottom: 12px;
    }

    .planets-container {
        width: min(1100px, 100%);
        flex-shrink: 0;
    }
}

/* ===== FALLBACKS ===== */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .planet-orb,
    .planet:hover .planet-orb,
    .planet:focus-visible .planet-orb {
        box-shadow: 0 0 20px var(--holo-pink-glow), 0 0 45px var(--halo-purple-glow);
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .nav-trigger-icon,
    .nav-trigger-ring,
    .star-layer,
    .shooting-star,
    .planet-orb,
    .planet-orb::before {
        animation: none !important;
    }

    .planet,
    .starfield-title {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }

    .nav-starfield {
        transition: none;
    }

    .constellation-lines line {
        transition: none !important;
    }
}

/* ===== PRINT ===== */
@media print {
    .nav-trigger,
    .nav-starfield {
        display: none !important;
    }
}
