/**
 * Podcast Map Visualization Styles
 * Inspired by askfuturefossils.com - Clean, elegant, full-window experience
 */

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: #f8f9fa;
    color: #1a1a1a;
    overflow: hidden;
}

/* Main container - full viewport */
#podcast-map-container {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header section - clean and minimal */
.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
    height: 72px;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.nav-link {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Project selector - elegant and clean */
.project-selector {
    position: relative;
}

.project-dropdown-btn {
    background: transparent;
    border: none;
    color: #1a1a1a;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.project-dropdown-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.project-name {
    letter-spacing: -0.2px;
}

.dropdown-arrow {
    font-size: 11px;
    opacity: 0.5;
    transition: transform 0.3s ease;
}

/* Episode filter - clean dropdown */
.episode-filter {
    position: relative;
    display: flex;
    align-items: center;
}

.episode-dropdown {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #1a1a1a;
    padding: 10px 40px 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    min-width: 300px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s ease;
    font-weight: 400;
}

.episode-dropdown:hover {
    background: #fafafa;
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.episode-dropdown:focus {
    outline: none;
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.episode-filter .dropdown-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.4;
}

/* Visualization container - full height below header */
.visualization-container {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: calc(100vh - 72px);
    overflow: hidden;
    background: #ffffff;
}

#map-svg-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.podcast-map-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Points styling - smooth and interactive */
.point {
    cursor: pointer;
    transition: r 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                fill 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.point:hover {
    filter: brightness(1.2) saturate(1.3);
}

/* Voronoi cells */
.voronoi-cells path {
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Cluster labels */
.cluster-label {
    font-family: system-ui, -apple-system, sans-serif;
    fill: #000000;
    text-shadow:
        0 0 8px rgba(255, 255, 255, 1),
        0 0 15px rgba(255, 255, 255, 0.8),
        0 0 25px rgba(255, 255, 255, 0.6),
        2px 2px 6px rgba(255, 255, 255, 0.9);
    user-select: none;
    transition: opacity 0.3s ease;
    paint-order: stroke fill;
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 4px;
}

/* Trajectory lines */
.trajectory-lines path {
    pointer-events: none;
    animation: drawLine 1s ease-out;
}

@keyframes drawLine {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Clusters legend - elegant positioning */
.clusters-legend {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 12px;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    max-width: 90%;
    z-index: 10;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-item:hover {
    color: #000000;
    transform: translateY(-3px);
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Audio player - elegant left-side overlay inspired by Future Fossils */
.audio-player-container {
    position: fixed;
    top: 72px;
    left: 0;
    width: 420px;
    height: calc(100vh - 72px);
    background: rgba(255, 255, 255, 0.98);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding: 32px 24px;
    backdrop-filter: blur(20px);
    z-index: 90;
    animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.player-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.close-player {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-player:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.8);
}

.episode-info {
    width: 100%;
    margin-bottom: 24px;
}

.episode-info h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.3;
    color: #1a1a1a;
}

.episode-info p {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    line-height: 1.6;
}

.audio-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#audio-element {
    width: 100%;
    height: 48px;
    border-radius: 8px;
}

.time-display {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.5);
    text-align: center;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(36, 44, 70, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 12px;
    pointer-events: none;
    z-index: 1000;
    backdrop-filter: blur(10px);
    max-width: 300px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-episode {
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 6px;
}

.tooltip-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
    margin-bottom: 6px;
}

.tooltip-cluster {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

/* Magic button */
.magic-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 90;
}

.magic-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.magic-btn img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

/* Chat modal */
.chat-modal {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    max-height: 600px;
    background: rgba(36, 44, 70, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    z-index: 95;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

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

.close-chat {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.chat-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
}

#chat-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-container button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-messages {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive design - smooth scaling */
@media (max-width: 1024px) {
    .audio-player-container {
        width: 360px;
        padding: 24px 20px;
    }

    .episode-info h3 {
        font-size: 18px;
    }
}

@media (max-width: 768px) {
    .map-header {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
        height: auto;
    }

    .project-dropdown-btn {
        font-size: 16px;
    }

    .episode-dropdown {
        min-width: 100%;
        font-size: 13px;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .clusters-legend {
        flex-direction: row;
        gap: 12px;
        font-size: 11px;
        padding: 12px 16px;
        max-width: 95%;
        bottom: 16px;
    }

    .audio-player-container {
        width: 100%;
        top: auto;
        bottom: 0;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .visualization-container {
        height: calc(100vh - auto);
    }

    .magic-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Hierarchical Controls */
.hierarchy-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.level-btn {
    padding: 8px 16px;
    background: rgba(100, 100, 100, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.level-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Breadcrumb */
.breadcrumb {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.breadcrumb-item {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
/* Zoom Mode Toggle */
.zoom-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
}

.mode-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.mode-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-toggle {
    background-color: #667eea;
}

input:checked + .slider-toggle:before {
    transform: translateX(26px);
}

.mode-label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
}

/* Cluster Slider */
.cluster-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 20px;
    margin-right: 15px;
}

.cluster-slider-container label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
}

#cluster-count {
    display: inline-block;
    min-width: 20px;
    text-align: right;
    font-weight: 600;
    color: #667eea;
}

#cluster-slider {
    width: 150px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    opacity: 0.9;
    transition: opacity .2s;
}

#cluster-slider:hover {
    opacity: 1;
}

#cluster-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

#cluster-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}
