/* ============================================================
   LORE CODEX HUB - STYLES
   Monochromatic "Master Hub" with Dynamic Color Injection
   Inspired by Arik Ahmed Portfolio + Advanced Data-Extraction
   ============================================================ */

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

:root {
    /* Portfolio Palette */
    --bg-deepest: #050505;
    --bg-deep: #0a0a0a;
    --bg-surface: rgba(255, 255, 255, 0.012);

    --accent: #ffffff;
    --accent-rgb: 255, 255, 255;
    --zinc-gray: #52525b;
    --zinc-muted: #1F1F1F;

    --text-primary: #EDEDED;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --border: rgba(255, 255, 255, 0.07);

    --font-display: 'Oxanium', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-tech: 'Oxanium', sans-serif;

    /* Dynamic Color Slot */
    --active-node-color: var(--accent);
}

/* Base */
html { overflow: hidden; height: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background-color: var(--bg-deepest);
    color: var(--text-primary);
    overflow: hidden;
    height: 100%;
    position: relative;
    isolation: isolate;
}

/* Base Ambient (Portfolio spotlight style) */
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(circle at top center, rgba(var(--active-node-rgb, 255, 255, 255), 0.08), transparent 30%),
        linear-gradient(180deg, rgba(var(--active-node-rgb, 255, 255, 255), 0.015), transparent 40%),
        radial-gradient(circle at 20% 0%, rgba(var(--active-node-rgb, 255, 255, 255), 0.03), transparent 25%);
    transition: background 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Scanline Overlay (Visual Polish) */
body::after {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 2px, 3px 100%;
    opacity: 0.15;
}

/* ---- LOADING ---- */
#loading-screen {
    position: fixed; inset: 0; z-index: 10000;
    background: var(--bg-deepest);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
#loading-screen.hidden { opacity: 0; visibility: hidden; }

.loader-content {
    display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.loader-logo-img { width: 60px; height: 60px; filter: drop-shadow(0 0 15px rgba(255,255,255,0.2)); animation: loaderPulse 2.5s ease-in-out infinite; }
@keyframes loaderPulse { 0%, 100% { opacity: 0.3; transform: scale(0.96); } 50% { opacity: 0.7; transform: scale(1); } }

.loader-text {
    font-family: var(--font-display); font-size: 0.74rem; font-weight: 600;
    letter-spacing: 7px; color: var(--text-primary); opacity: 0.55; text-transform: uppercase;
}
.loader-bar { width: 160px; height: 1px; background: var(--zinc-muted); overflow: hidden; position: relative; margin-top: 4px; }
.loader-bar-fill {
    position: absolute; top: 0; left: 0; height: 100%; width: 50%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: loaderBar 2.5s infinite linear;
}
@keyframes loaderBar { from { transform: translateX(-100%); } to { transform: translateX(200%); } }

/* ---- BACKGROUND ---- */
#particle-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5; mix-blend-mode: screen; }

/* ---- NAV ---- */
#main-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 60px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--zinc-muted);
}
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo-img {
    width: 22px;
    height: 22px;
    display: block;
    flex: none;
    opacity: 0.95;
    filter: drop-shadow(0 0 12px var(--active-node-color, rgba(255, 255, 255, 0.15)));
    transition: filter 0.5s ease;
}
.nav-logo-text { font-family: var(--font-display); font-size: 0.98rem; font-weight: 700; letter-spacing: 5px; color: #fff; }

/* ---- COMPASS PAGE ---- */
#compass-page { position: relative; width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.compass-container {
    position: relative;
    width: min(calc(100vh - 120px), calc(100vw - 60px));
    height: min(calc(100vh - 120px), calc(100vw - 60px));
    aspect-ratio: 1;
    cursor: grab;
}
.compass-container.dragging {
    cursor: grabbing;
}
#compass-canvas { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0.7; }

.compass-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; }
.center-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--active-node-color, #fff);
    box-shadow: 0 0 15px var(--active-node-color, rgba(255, 255, 255, 0.35)), 
                0 0 35px rgba(var(--active-node-rgb, 255, 255, 255), 0.2);
    transition: background 0.5s ease, box-shadow 0.5s ease;
    animation: centerPulse 4s ease-in-out infinite;
}
.compass-center-detail { display: none; }
@keyframes centerPulse { 0%, 100% { transform: scale(1); opacity: 0.75; } 50% { transform: scale(1.18); opacity: 1; } }

/* ---- NODES ---- */
.compass-node {
    position: absolute; width: 72px; height: 72px; z-index: 10;
    transform: translate(-50%, -50%); text-decoration: none;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; align-items: center; justify-content: center;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}
.compass-node:hover { transform: translate(-50%, -50%) scale(1.12); z-index: 50; }
.compass-node.is-active {
    transform: translate(-50%, -50%) scale(1.12);
    z-index: 50;
}
.compass-node.is-dimmed {
    opacity: 0.18;
    transform: translate(-50%, -50%) scale(0.88);
    filter: blur(1.2px) saturate(0.55);
}

/* Isolation Dimming */
.compass-container:has(.compass-node:hover) .compass-node:not(:hover) {
    opacity: 0.15;
    transform: translate(-50%, -50%) scale(0.88);
    filter: blur(2px);
}

.node-ring {
    width: 70px; height: 70px; display: flex; align-items: center; justify-content: center;
    position: relative;
}
/* Portfolio Glow Card Style */
.node-ring::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    border: 1px solid var(--zinc-muted); transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.compass-node:hover .node-ring::after { border-color: rgba(255,255,255,0.25); box-shadow: 0 0 15px rgba(255,255,255,0.05); }

.node-logo { width: 44px; height: 44px; object-fit: contain; opacity: 1; transition: all 0.4s ease; }
.node-logo {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}
.compass-node:hover .node-logo { transform: scale(1.12); filter: drop-shadow(0 0 12px var(--node-color)); }

.node-glow {
    position: absolute; inset: -24px; border-radius: 50%;
    background: radial-gradient(circle, var(--node-color) 0%, transparent 72%);
    opacity: 0.04; transition: opacity 0.6s ease; pointer-events: none;
}
.compass-node:hover .node-glow { opacity: 0.44; }

/* Labels positioning */
.node-label {
    position: absolute; display: flex; flex-direction: column; gap: 4px;
    white-space: nowrap; pointer-events: none; transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pos-right .node-label { left: 86px; text-align: left; }
.pos-left .node-label { right: 86px; text-align: right; }
.pos-top .node-label { bottom: 86px; text-align: center; }
.pos-bottom .node-label { top: 86px; text-align: center; }

.node-name {
    font-family: var(--font-display); font-size: 0.82rem; font-weight: 700;
    letter-spacing: 2.2px; text-transform: uppercase; color: var(--text-primary);
    opacity: 0.75; transition: all 0.4s ease;
}
.compass-node:hover .node-name { opacity: 1; color: #fff; text-shadow: 0 0 12px var(--node-color); letter-spacing: 2.5px; }

.node-universe {
    font-family: var(--font-tech); font-size: 0.44rem; font-weight: 600;
    letter-spacing: 3.5px; color: var(--text-muted); text-transform: uppercase;
    transition: color 0.4s ease;
}
.compass-node:hover .node-universe { color: var(--node-color); letter-spacing: 4px; }

/* ---- CREDITS ---- */
.credits {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    text-align: center; font-family: var(--font-body); z-index: 5;
}
.credits-line { font-size: 0.58rem; font-weight: 500; color: var(--zinc-gray); letter-spacing: 1.5px; text-transform: uppercase; }
.credit-link { color: #fff; text-decoration: none; transition: opacity 0.3s ease; opacity: 0.85; font-weight: 700; }
.credit-link:hover { opacity: 1; border-bottom: 1px solid currentColor; }
.credits-legal { font-size: 0.5rem; color: var(--text-muted); margin-top: 6px; opacity: 0.4; font-weight: 400; letter-spacing: 1px; }

/* ---- TOAST ---- */
.coming-soon-toast {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -44%);
    max-width: calc(100vw - 24px);
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(8, 8, 8, 0.98), rgba(18, 18, 18, 0.95));
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.coming-soon-toast.visible {
    opacity: 1;
    transform: translate(-50%, -50%);
}

/* ---- MOBILE PICKER ---- */
.mobile-site-launcher { display: none; }
.mobile-site-btn {
    --node-color: #ffffff;
    --node-rgb: 255, 255, 255;
    appearance: none;
    border: 1px solid var(--zinc-muted);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}
.mobile-site-btn img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}
.mobile-site-btn.is-pressed {
    border-color: rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.04);
    transform: scale(0.96);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 18px rgba(255, 255, 255, 0.08);
}
.mobile-site-btn.is-preview-active {
    border-color: rgba(var(--node-rgb), 0.62);
    background: rgba(var(--node-rgb), 0.08);
    box-shadow: 0 0 0 1px rgba(var(--node-rgb), 0.18), 0 0 20px rgba(var(--node-rgb), 0.18);
    transform: scale(0.98);
}
.mobile-site-btn.is-preview-dimmed {
    opacity: 0.32;
    filter: grayscale(1) brightness(0.72);
    transform: scale(0.92);
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
    html, body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }
    body::before {
        background:
            radial-gradient(circle at top center, rgba(var(--active-node-rgb, 255, 255, 255), 0.15), transparent 28%),
            radial-gradient(circle at 50% 38%, rgba(var(--active-node-rgb, 255, 255, 255), 0.06), transparent 44%),
            linear-gradient(180deg, rgba(var(--active-node-rgb, 255, 255, 255), 0.03), transparent 48%),
            radial-gradient(circle at 20% 0%, rgba(var(--active-node-rgb, 255, 255, 255), 0.05), transparent 22%);
    }
    body::after {
        opacity: 0.08;
    }
    #compass-page {
        height: auto;
        min-height: calc(100svh - 60px);
        padding: 12px 0 56px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    #particle-canvas { opacity: 0.66; }
    #compass-canvas { display: block; opacity: 0.78; }
    .nav-logo { gap: 8px; }
    .nav-logo-img { width: 19px; height: 19px; }
    .nav-logo-text { font-size: 0.8rem; letter-spacing: 3px; }
    .compass-container {
        width: calc(100vw - 2px);
        height: calc(100vw - 2px);
        touch-action: none;
        cursor: default;
        pointer-events: auto;
    }
    .compass-node {
        width: 54px;
        height: 54px;
        pointer-events: auto;
    }
    .node-ring { width: 54px; height: 54px; }
    .node-logo { width: 34px; height: 34px; }
    .center-dot { width: 8px; height: 8px; }
    .node-label { display: none !important; }
    .compass-center-detail {
        display: flex;
        position: absolute;
        left: 50%;
        top: 50%;
        width: max-content;
        max-width: min(78vw, 260px);
        padding: 12px 16px;
        border: 1px solid rgba(var(--node-rgb, 255, 255, 255), 0.18);
        border-radius: 14px;
        background: linear-gradient(135deg, rgba(5, 5, 5, 0.92), rgba(14, 14, 14, 0.86));
        box-shadow: 0 0 0 1px rgba(var(--node-rgb, 255, 255, 255), 0.06), 0 14px 30px rgba(0, 0, 0, 0.42), 0 0 24px rgba(var(--node-rgb, 255, 255, 255), 0.12);
        backdrop-filter: blur(10px);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-align: center;
        white-space: normal;
        opacity: 0;
        pointer-events: none;
        transform: translate(-50%, -50%) scale(0.96);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }
    .compass-center-detail .mobile-detail-name {
        font-family: var(--font-display);
        font-size: clamp(0.92rem, 3.6vw, 1.16rem);
        line-height: 1.1;
        font-weight: 700;
        letter-spacing: 2.4px;
        text-transform: uppercase;
        color: var(--text-primary);
        text-shadow: 0 0 12px rgba(var(--node-rgb, 255, 255, 255), 0.16);
    }
    .compass-center-detail .mobile-detail-universe {
        font-family: var(--font-tech);
        font-size: clamp(0.52rem, 2vw, 0.7rem);
        line-height: 1.1;
        font-weight: 600;
        letter-spacing: 3.2px;
        text-transform: uppercase;
        color: var(--node-color, var(--text-muted));
    }
    .compass-container.mobile-focus-active .compass-center-detail {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    .compass-container.mobile-focus-active #compass-canvas {
        opacity: 0.92;
    }
    .compass-container.mobile-focus-active .center-dot {
        opacity: 0.18;
    }
    .compass-container.mobile-focus-active .compass-node.is-active .node-ring::after {
        border-color: rgba(255, 255, 255, 0.3);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
    }
    .compass-container.mobile-focus-active .compass-node.is-active {
        transform: translate(-50%, -50%) scale(1.18);
    }
    .compass-container.mobile-focus-active .compass-node.is-active .node-logo {
        transform: scale(1.18);
        filter: drop-shadow(0 0 12px var(--node-color));
    }
    .compass-container.mobile-focus-active .compass-node.is-active .node-glow {
        opacity: 0.44;
    }
    .compass-container.mobile-focus-active .compass-node.is-active .node-name {
        opacity: 1;
        color: #fff;
        text-shadow: 0 0 12px var(--node-color);
        letter-spacing: 2.5px;
    }
    .compass-container.mobile-focus-active .compass-node.is-active .node-universe {
        color: var(--node-color);
        letter-spacing: 4px;
    }
    .compass-container.mobile-focus-active .compass-node.is-dimmed {
        opacity: 0.12;
        transform: translate(-50%, -50%) scale(0.84);
        filter: blur(1.4px) saturate(0.4);
    }
    .compass-container.mobile-focus-active .compass-node.is-active {
        opacity: 1;
    }
    .mobile-site-launcher {
        display: none;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
        width: min(84vw, 360px);
        justify-items: center;
        align-items: center;
    }
    .mobile-site-btn {
        width: 60px;
        height: 60px;
    }
    .credits {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        margin-top: 0;
    }
    .credits-line { font-size: 0.5rem; }
    .credits-legal { font-size: 0.42rem; }
}

@media (max-width: 480px) {
    #compass-page {
        padding-top: 8px;
        gap: 10px;
    }
    .compass-container {
        width: calc(100vw - 2px);
        height: calc(100vw - 2px);
    }
    .mobile-site-btn {
        width: 56px;
        height: 56px;
    }
    .mobile-site-btn img {
        width: 28px;
        height: 28px;
    }
    .credits {
        margin-top: 0;
    }
    .coming-soon-toast {
        padding: 10px 12px;
        font-size: 0.74rem;
        letter-spacing: 0.06em;
        max-width: calc(100vw - 16px);
    }
}
