/* ============================================
   THE ECONOMIST'S SKILL TREE - V2
   Tree + Underground Roots Visualization
   ============================================ */

:root {
    /* Sky & Ground */
    --sky-top: #1a1a2e;
    --sky-bottom: #2d2d44;
    --ground-surface: #3d2817;
    --ground-dark: #1a0f08;
    --underground-top: #2a1a0f;
    --underground-bottom: #0f0a05;

    /* Colors */
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Root/Skill colors */
    --color-prereq: #6366f1;
    --color-required: #22c55e;
    --color-bonus: #3b82f6;
    --color-soft: #ec4899;

    /* Glows */
    --glow-prereq: rgba(99, 102, 241, 0.5);
    --glow-required: rgba(34, 197, 94, 0.5);
    --glow-bonus: rgba(59, 130, 246, 0.4);

    /* Tree colors */
    --tree-trunk: #8B4513;
    --tree-canopy: #228B22;
    --tree-selected: #FFD700;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background:
        linear-gradient(180deg,
            rgba(26, 26, 46, 0.7) 0%,
            rgba(45, 45, 68, 0.85) 25%,
            var(--ground-surface) 30%,
            var(--underground-bottom) 100%),
        url('../../assets/BetterClouds.gif');
    background-size: cover, cover;
    background-position: center, center;
    background-attachment: fixed, fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* Context Note (Top Left) */
.context-note {
    position: absolute;
    top: 15px;
    left: 15px;
    max-width: 280px;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
    z-index: 5;
}

.context-note em {
    font-style: italic;
    color: var(--text-secondary);
}

/* JEL Footnote (Top Right) */
.jel-footnote {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 4px;
    z-index: 5;
}

/* Header */
.header {
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
    position: relative;
    z-index: 10;
}

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--text-primary);
}

.title {
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #22c55e 0%, #eab308 50%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-xs);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0 var(--spacing-lg) var(--spacing-md);
    flex-wrap: wrap;
}

.search-box {
    position: relative;
}

#skill-search {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    width: 200px;
    transition: all var(--transition-normal);
}

#skill-search:focus {
    outline: none;
    border-color: var(--color-required);
    background: rgba(255, 255, 255, 0.12);
    width: 250px;
}

#skill-search::placeholder {
    color: var(--text-muted);
}

.control-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.control-btn.active {
    background: rgba(234, 179, 8, 0.2);
    border-color: var(--tree-selected);
    color: var(--tree-selected);
}

/* Comparison Info Bar */
.comparison-info {
    display: none;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: rgba(234, 179, 8, 0.1);
    border-top: 1px solid rgba(234, 179, 8, 0.2);
    border-bottom: 1px solid rgba(234, 179, 8, 0.2);
}

.comparison-info.active {
    display: flex;
}

.compare-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.compare-badges {
    display: flex;
    gap: var(--spacing-sm);
}

.compare-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.compare-badge.career-1 {
    border-color: #f472b6;
    color: #f472b6;
}

.compare-badge.career-2 {
    border-color: #38bdf8;
    color: #38bdf8;
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 8px;
}

.clear-btn:hover {
    color: var(--text-primary);
}

/* Forest Section (Above Ground) */
.forest-section {
    padding: var(--spacing-md) var(--spacing-lg);
    min-height: 180px;
}

.forest {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--spacing-xl);
    flex-wrap: wrap;
}

/* Individual Tree */
.tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-normal);
    position: relative;
}

.tree:hover {
    transform: scale(1.05);
}

.tree.selected {
    transform: scale(1.1);
}

.tree-canopy {
    font-size: 4rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: all var(--transition-normal);
}

.tree.selected .tree-canopy {
    filter: drop-shadow(0 0 20px var(--tree-selected));
    animation: sway 2s ease-in-out infinite;
}

@keyframes sway {

    0%,
    100% {
        transform: rotate(-2deg);
    }

    50% {
        transform: rotate(2deg);
    }
}

.tree-trunk {
    width: 20px;
    height: 40px;
    background: linear-gradient(90deg, #5D3A1A 0%, #8B5A2B 50%, #5D3A1A 100%);
    border-radius: 3px 3px 0 0;
    position: relative;
}

.tree.selected .tree-trunk::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: var(--tree-selected);
    opacity: 0.5;
    animation: pulse-down 1s ease-in-out infinite;
}

@keyframes pulse-down {

    0%,
    100% {
        opacity: 0.3;
        height: 100%;
    }

    50% {
        opacity: 0.8;
        height: 120%;
    }
}

.tree-label {
    margin-top: var(--spacing-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    max-width: 100px;
    transition: color var(--transition-fast);
}

.tree.selected .tree-label {
    color: var(--tree-selected);
}

.tree-icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

/* Ground Line */
.ground-line {
    position: relative;
    height: 40px;
    background: linear-gradient(180deg,
            var(--ground-surface) 0%,
            #4a2c1a 50%,
            var(--underground-top) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ground-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-linear-gradient(90deg,
            #2d1a0d 0px,
            #4a2c1a 10px,
            #3d2817 20px);
}

.ground-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 12px;
    border-radius: 12px;
    position: relative;
    z-index: 1;
}

/* Underground Section */
.underground-section {
    flex: 1;
    min-height: 400px;
    position: relative;
    background: linear-gradient(180deg, var(--underground-top) 0%, var(--underground-bottom) 100%);
}

.underground {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

#roots-svg {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Root Nodes - Always Visible with Layer Colors */
.root-node {
    cursor: pointer;
    transition: all var(--transition-normal);
}

.root-node circle {
    stroke-width: 2px;
    transition: all var(--transition-normal);
}

.root-node text {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    fill: var(--text-primary);
    pointer-events: none;
    text-anchor: middle;
    transition: opacity var(--transition-normal);
}

.root-node:hover circle {
    stroke-width: 3px;
    filter: drop-shadow(0 0 10px currentColor);
}

/* Default layer colors (always visible) */
.root-node.layer-core circle {
    fill: #4a4a6a;
    stroke: #6366f1;
    fill-opacity: 0.15;
}

.root-node.layer-toolbelt circle {
    fill: #2a4a3a;
    stroke: #22c55e;
    fill-opacity: 0.15;
}

.root-node.layer-specialization circle {
    fill: #4a3a2a;
    stroke: #f59e0b;
    fill-opacity: 0.15;
}

/* Dimmed state (when a career is selected but skill not relevant) */
.root-node.dimmed circle {
    opacity: 0.25;
}

.root-node.dimmed text {
    opacity: 0.3;
}

/* Highlighted states (when skill is part of selected career) */
.root-node.highlighted circle {
    stroke-width: 3px;
}

.root-node.prereq circle {
    fill: var(--color-prereq);
    stroke: var(--color-prereq);
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 8px var(--glow-prereq));
}

.root-node.required circle {
    fill: var(--color-required);
    stroke: var(--color-required);
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 8px var(--glow-required));
}

.root-node.bonus circle {
    fill: var(--color-bonus);
    stroke: var(--color-bonus);
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 8px var(--glow-bonus));
}

.root-node.soft circle {
    fill: var(--color-soft);
    stroke: var(--color-soft);
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.4));
}

/* Search match state */
.root-node.search-match circle {
    stroke-width: 4px;
    stroke: #fbbf24;
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.6));
}

.root-node.search-match text {
    fill: #fbbf24;
    font-weight: 600;
}

/* Compare mode - overlap (both careers) */
.root-node.overlap circle {
    fill: #fbbf24;
    stroke: #fbbf24;
    fill-opacity: 0.4;
    stroke-width: 4px;
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.6));
}

/* Compare mode - career 1 only */
.root-node.career-1-only circle {
    fill: #f472b6;
    stroke: #f472b6;
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 8px rgba(244, 114, 182, 0.5));
}

/* Compare mode - career 2 only */
.root-node.career-2-only circle {
    fill: #38bdf8;
    stroke: #38bdf8;
    fill-opacity: 0.3;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}

/* Root Lines */
.root-line {
    stroke: #4a3525;
    stroke-width: 3px;
    stroke-linecap: round;
    fill: none;
    opacity: 0;
    transition: all var(--transition-slow);
}

.root-line.visible {
    opacity: 1;
    animation: grow-root 0.6s ease-out;
}

@keyframes grow-root {
    from {
        stroke-dasharray: 1000;
        stroke-dashoffset: 1000;
    }

    to {
        stroke-dasharray: 1000;
        stroke-dashoffset: 0;
    }
}

.root-line.prereq {
    stroke: var(--color-prereq);
    filter: drop-shadow(0 0 4px var(--glow-prereq));
}

.root-line.required {
    stroke: var(--color-required);
    filter: drop-shadow(0 0 4px var(--glow-required));
}

.root-line.bonus {
    stroke: var(--color-bonus);
    filter: drop-shadow(0 0 4px var(--glow-bonus));
}

/* Info Panel */
.info-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--spacing-lg);
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all var(--transition-normal);
}

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

@media (max-width: 1200px) {
    .info-panel {
        position: fixed;
        right: 10px;
        top: auto;
        bottom: 20px;
        transform: none;
        width: calc(100% - 20px);
        max-width: 400px;
    }
}

.panel-content {
    animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.panel-employers {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: var(--spacing-md);
}

.panel-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
}

.panel-salary {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.salary-tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

.salary-tag.us {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.salary-tag.eu {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.panel-section {
    margin-bottom: var(--spacing-md);
}

.panel-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.skill-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.skill-tag.prerequisite {
    background: rgba(99, 102, 241, 0.2);
    color: var(--color-prereq);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.skill-tag.required {
    background: rgba(34, 197, 94, 0.2);
    color: var(--color-required);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.skill-tag.bonus {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-bonus);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.skill-tag.soft {
    background: rgba(236, 72, 153, 0.2);
    color: var(--color-soft);
    border: 1px solid rgba(236, 72, 153, 0.3);
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(0, 0, 0, 0.3);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-prereq {
    background: var(--color-prereq);
    box-shadow: 0 0 6px var(--glow-prereq);
}

.legend-required {
    background: var(--color-required);
    box-shadow: 0 0 6px var(--glow-required);
}

.legend-bonus {
    background: var(--color-bonus);
}

.legend-soft {
    background: var(--color-soft);
}

.legend-overlap {
    background: #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.legend-compare {
    display: none;
}

.legend-compare.active {
    display: flex;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.8rem;
    max-width: 250px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.tooltip-layer {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tooltip-description {
    color: var(--text-secondary);
    line-height: 1.4;
}