/* STEVE JOBS UPDATE: Titanium & Frost 2025 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;1,400&display=swap');

:root {
    /* The Titanium Palette */
    --bg-titanium: #161617;
    --bg-gradient: radial-gradient(circle at 50% 0%, #2c2c2e 0%, #161617 100%);
    
    /* The Glass Frost */
    --glass-surface: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.2);
    
    /* Typography */
    --text-primary: #F5F5F7; /* Apple White */
    --text-secondary: #86868B; /* Apple Grey */
    --accent-photon: #0A84FF; /* Electric Blue */
    
    --node-w: 260px; /* Wider for better readability */
}

body {
    background: var(--bg-titanium);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em; /* Tight, precision tracking */
}

/* UTILS */
.no-scrollbar::-webkit-scrollbar { display: none; }
.serif { font-family: 'Playfair Display', serif; }

/* REFINED NODE CARD: Machined Glass - OPTIMIZED (Air Edition) */
.node-card {
    background: rgba(28, 28, 30, 0.85); /* Titanium Dark, High Opacity for Performance */
    /* backdrop-filter removed for fluid scrolling */
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-highlight); /* Top light catch */
    border-radius: 18px; /* Smooth curvature */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: absolute;
    width: var(--node-w);
    cursor: pointer;
    z-index: 10;
    padding: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    will-change: transform; /* GPU Hint */
}

.node-card:hover {
    background: rgba(44, 44, 46, 0.95);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.3);
    z-index: 20;
}

.node-card.active {
    background: rgba(60, 60, 60, 0.4); /* Lighter, transparent */
    backdrop-filter: blur(20px) saturate(150%); /* The "Pop" - Frost returns only here */
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 0 0 1px var(--text-primary), 0 30px 60px rgba(0,0,0,0.5);
    z-index: 30;
    transform: scale(1.05);
    filter: none !important;
}

/* Focus Mode - Depth of Field effect */
body.focus-mode .node-card { opacity: 0.1; filter: blur(5px) grayscale(100%); pointer-events: none; transform: scale(0.95); }
body.focus-mode .node-card.active { opacity: 1; filter: none; pointer-events: auto; transform: scale(1.05); }
body.focus-mode .node-card.related { opacity: 0.8; filter: none; pointer-events: auto; transform: scale(1); }

/* Connections - Fibre Optic style */
svg.connections { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
path.connector { 
    fill: none; 
    stroke: rgba(255, 255, 255, 0.15); 
    stroke-width: 1px; 
    transition: all 0.5s ease; 
}
body.focus-mode path.connector { opacity: 0.02; }
body.focus-mode path.connector.highlight { 
    opacity: 1; 
    stroke-width: 1.5px; 
    stroke: var(--text-primary) !important; 
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.5)); 
}

/* MINIMAP: The "Crystal Bar" */
#minimap-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 64px;
    z-index: 45;
    background: rgba(30, 30, 30, 0.8); /* More opaque */
    backdrop-filter: blur(15px); /* Lighter blur */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 100px; /* Pill shape */
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#minimap-container:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateX(-50%) translateY(-2px);
}

canvas#minimap-canvas { width: 100%; height: 100%; cursor: crosshair; opacity: 0.8; mix-blend-mode: screen; }

.minimap-viewport-indicator {
    position: absolute; top: 4px; bottom: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 100px;
    pointer-events: none; 
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
    transition: width 0.1s, left 0.05s linear;
}

/* Sidebar: The Frosted Sheet */
.details-panel { 
    position: fixed; top: 16px; bottom: 16px; right: 16px; width: 420px; 
    background: linear-gradient(to bottom, #1a1a1a, #111111); /* Titanium Gradient */
    /* backdrop-filter removed */
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    transform: translateX(120%); 
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1); 
    z-index: 210; padding: 40px; overflow-y: auto;
    box-shadow: -20px 0 60px rgba(0,0,0,0.4); 
}
.details-panel.open { transform: translateX(0); }

/* External resource links inside the details panel */
.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 9999px;
    color: #ddd;
    text-decoration: none;
    font-size: 12px;
    transition: background 0.15s ease, transform 0.08s ease;
}
.resource-link:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }
.resource-link svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Integrated Video Player: The Floating Widget */
#music-player {
    position: fixed; bottom: 30px; left: 30px; width: 360px; height: 220px;
    min-width: 280px; min-height: 160px; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px);
    resize: both; overflow: auto; /* allow user to resize the widget */
    background: linear-gradient(145deg, #252525, #1a1a1a); /* Titanium Gradient */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    z-index: 200; display: flex; flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    transform: translateY(150%); transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
#music-player.active { transform: translateY(0); }

.player-header { 
    padding: 10px 14px; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
    display: flex; justify-content: space-between; align-items: center;
    flex: 0 0 auto;
}
/* Larger, easier-to-press close button */
.player-header button.player-close {
    padding: 8px; border-radius: 8px; display:inline-flex; align-items:center; justify-content:center;
    min-width: 40px; min-height: 40px; cursor: pointer; background: transparent; transition: background 0.12s ease, color 0.12s ease;
}
.player-header button.player-close svg { width: 18px; height: 18px; }
.player-header button.player-close:focus { outline: 2px solid rgba(255,255,255,0.12); outline-offset: 2px; }
.player-header button.player-close:hover { background: rgba(255,255,255,0.03); color: #fff; }

/* Make the video area flexible so it scales when the widget is resized */
#video-container { flex: 1 1 auto; display:flex; align-items:center; justify-content:center; overflow:hidden; }
#video-container iframe, #video-container video, #video-container embed { width:100%; height:100%; border:0; display:block; }

/* Search Overlay - Full Screen Frost */
#search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); /* Semi-transparent to allow backdrop blur */ z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding-top: 15vh; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; backdrop-filter: blur(12px) saturate(120%); -webkit-backdrop-filter: blur(12px) saturate(120%); }
#search-overlay.visible { opacity: 1; pointer-events: auto; }

/* Make the search box stand out while keeping the frosted background visible */
#search-box { 
    width: 600px; max-width: 90%; 
    background: rgba(28, 28, 30, 0.85); /* Slightly more translucent so backdrop blur is perceptible */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px; 
    box-shadow: 0 40px 100px rgba(0,0,0,0.8); 
    display: flex; flex-direction: column; overflow: hidden; 
    transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1); 
}
#search-overlay.visible #search-box { transform: scale(1); }

@media (prefers-reduced-motion: reduce) {
    #search-overlay, #search-box { transition: none !important; }
}

#search-input { 
    width: 100%; background: transparent; border: none; padding: 24px 32px; 
    font-size: 24px; color: var(--text-primary); font-weight: 300; 
    outline: none; border-bottom: 1px solid rgba(255,255,255,0.05); 
}
.search-result-item { padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.03); transition: background 0.1s; }
.search-result-item:hover { background: rgba(255,255,255,0.1); }

/* Typography & Details */
h1 { font-weight: 600; letter-spacing: -0.02em; text-shadow: 0 2px 10px rgba(0,0,0,0.3); }
h2 { font-weight: 500; letter-spacing: -0.01em; }

.badge { 
    font-size: 11px; padding: 4px 8px; border-radius: 6px; 
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; 
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.05);
}

#radio-badge {
    white-space: nowrap;
    flex-shrink: 0;
}

.track-item { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.05); transition: opacity 0.2s; }
.track-item:hover { opacity: 1; }
.track-item:hover .play-btn { background: #fff; color: #000; border-color: #fff; }
.play-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center; transition: all 0.2s; color: rgba(255,255,255,0.65); }
/* Ensure the inline SVG play triangle uses the button's color (so it's visible) */
.play-btn svg { width: 14px; height: 14px; display: block; }
.play-btn svg path { fill: currentColor; }
/* Search button placed to the left of the play icon in track items */
.search-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); display: inline-flex; align-items: center; justify-content: center; background: transparent; color: rgba(255,255,255,0.65); transition: all 0.15s; cursor: pointer; }
.track-item:hover .search-btn { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.95); border-color: rgba(255,255,255,0.25); }

/* Headers */
header { position: fixed; top: 0; left: 0; width: 100%; padding: 40px; z-index: 40; pointer-events: none; }

/* Buttons */
.control-btn {
    pointer-events: auto;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 14px; font-weight: 500;
    padding: 10px 20px; border-radius: 100px;
    transition: all 0.2s;
}
.control-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); transform: translateY(-1px); }

/* Make dropdown caret icons larger and keep spacing so they don't appear as tiny dots */
.dropdown .control-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}

/* Regions: Subtle, Desaturated Titanium Tints */
.region-Germany { border-color: rgba(94, 92, 230, 0.4); } 
.region-Austria { border-color: rgba(255, 45, 85, 0.4); }
.region-Italy { border-color: rgba(48, 176, 199, 0.4); }
.region-France { border-color: rgba(191, 90, 242, 0.4); }
.region-Russia { border-color: rgba(255, 55, 95, 0.4); }

/* FAB - Floating Action Buttons (Mobile) */
.fab-container {
    position: fixed;
    bottom: 120px;
    right: 20px;
    z-index: 55;
    display: none;
    flex-direction: column;
    gap: 12px;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
}

.fab:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    :root {
        --node-w: 280px;
    }

    body {
        overflow-x: hidden;
    }

    /* Hide desktop header */
    header {
        padding: 20px;
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        background: #161617; /* Solid background */
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    header h1 {
        font-size: 24px;
    }

    header .pointer-events-auto {
        display: none;
    }

    /* Hide FAB on mobile - using bottom nav instead */
    .fab-container {
        display: none;
    }

    /* Vertical Timeline for Mobile */
    #canvas-container {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        /* Offset for the fixed header so the first card is not cropped */
        padding-top: 100px;
    }

    #world {
        width: 100% !important;
        height: auto !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        padding: 20px;
        gap: 24px;
    }

    .node-card {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100%;
        margin: 0;
        transform: none !important;
        height: auto !important;
        min-height: 160px;
    }

    .node-card:hover {
        transform: none !important;
    }

    .node-card.active {
        transform: none !important;
    }

    /* Hide connections on mobile for cleaner look */
    svg.connections {
        display: none;
    }

    /* Mobile-optimized sidebar */
    .details-panel {
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        border-radius: 0;
        padding: 24px;
        padding-top: 60px;
    }

    /* Mobile-optimized player */
    #music-player {
        bottom: 70px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 60vh;
        /* Disable resizing on mobile/PWA and revert desktop min/max sizes */
        resize: none;
        height: auto;
        min-width: unset;
        min-height: unset;
        max-width: 100%;
        overflow: hidden;
    }
    
    #music-player.active {
        bottom: 70px;
    }

    #music-player .player-header {
        padding: 20px;
    }

    /* Hide minimap on mobile */
    #minimap-container {
        display: none;
    }
    
    /* Mobile bottom navigation */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: rgba(22, 22, 23, 0.98);
        backdrop-filter: blur(40px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 45;
        padding: 0 20px;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-bottom-nav button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: rgba(255, 255, 255, 0.6);
        font-size: 10px;
        padding: 8px 12px;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .mobile-bottom-nav button:active {
        color: #0A84FF;
        transform: scale(0.95);
    }
    
    .mobile-bottom-nav button svg {
        width: 24px;
        height: 24px;
    }

    /* Mobile Legal Bar - appears below bottom nav */
    .mobile-legal-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 28px;
        background: rgba(22, 22, 23, 0.98);
        backdrop-filter: blur(40px);
        border-top: 1px solid rgba(255, 255, 255, 0.02);
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 10px;
        z-index: 44;
        font-size: 10px;
        font-weight: 400;
        letter-spacing: 0.02em;
    }

    .mobile-legal-bar a {
        color: rgba(255, 255, 255, 0.3);
        text-decoration: none;
        transition: color 0.3s ease;
    }

    .mobile-legal-bar:active a,
    .mobile-legal-bar a:active {
        color: rgba(255, 255, 255, 1);
    }

    .mobile-legal-bar span {
        color: rgba(255, 255, 255, 0.3);
        font-size: 9px;
        transition: color 0.3s ease;
    }

    .mobile-legal-bar:active span {
        color: rgba(255, 255, 255, 0.5);
    }

    /* Adjust bottom nav to sit above legal bar */
    .mobile-bottom-nav {
        bottom: 28px;
        border-top: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    }
    
    #canvas-container {
        padding-bottom: 98px; /* 70px nav + 28px legal bar */
    }

    /* Tour controls mobile */
    #tour-controls {
        bottom: 90px;
        right: 20px;
        left: 20px;
        width: auto;
    }

/* Tour controls (desktop / general) */
#tour-controls {
    /* ensure it's above the details panel */
    z-index: 220;
    /* hidden by default; JS will add/remove classes */
    display: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease, right 0.3s ease, left 0.3s ease;
}

/* Ensure details panel is above cinematic overlay for interaction */
.details-panel {
    z-index: 210;
}
/* FOCUS MODE STYLES */
@keyframes breathe-border {
    0% { border-color: rgba(10, 132, 255, 0.3); box-shadow: 0 0 0 0 rgba(10, 132, 255, 0.1); }
    50% { border-color: rgba(10, 132, 255, 0.8); box-shadow: 0 0 20px 5px rgba(10, 132, 255, 0.2); }
    100% { border-color: rgba(10, 132, 255, 0.3); box-shadow: 0 0 0 0 rgba(10, 132, 255, 0.1); }
}

.focus-pulse {
    animation: breathe-border 3s infinite ease-in-out;
}

.focus-input-group {
    width: 100%;
    margin-bottom: 1.5rem;
    position: relative;
}

.focus-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.focus-input:focus {
    border-color: var(--accent-photon);
    background: rgba(0, 0, 0, 0.4);
}

.focus-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}#tour-controls.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
#tour-controls.hidden {
    display: none;
    opacity: 0;
}

    /* Search overlay mobile */
    #search-box {
        width: 95%;
        max-height: 80vh;
    }

    #search-input {
        padding: 20px 24px;
        font-size: 18px;
    }

    .search-result-item {
        padding: 16px 24px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --node-w: 220px;
    }

    header {
        padding: 30px;
    }

    .details-panel {
        width: 380px;
    }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .node-card:active {
        background: rgba(255, 255, 255, 0.15);
    }

    .control-btn:active,
    .fab:active {
        transform: scale(0.95);
    }
}

/* CINEMATIC MODE */
#cinematic-overlay {
    /* Removed backdrop-filter to allow clear view of nodes */
}

@media (prefers-reduced-motion: reduce) {
    #cinematic-overlay,
    #cinematic-title,
    #cinematic-blurb,
    #cinematic-source,
    #cinematic-next-btn span {
        transition: none !important;
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

/* Utility for Z-Index Management */
.z-elevated {
    z-index: 250 !important;
}
/* SIGNATURE FOOTER - The Museum Label */
.signature-footer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.3;
    transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: auto;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.signature-footer:hover {
    opacity: 1;
}

.signature-footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.signature-footer a:hover {
    color: var(--text-primary);
}

.signature-footer span {
    opacity: 0.5;
}

/* Mobile: Hide signature footer, show in mobile menu */
@media (max-width: 768px) {
    .signature-footer {
        display: none !important;
    }
}

/* Desktop: Hide mobile legal bar */
@media (min-width: 769px) {
    .mobile-legal-bar {
        display: none !important;
    }
}