/* ============================================================ */
/* ==================== FULL CSS START ======================== */
/* ============================================================ */

:root {
    /* Base colors - MUST match main-graph.js config.baseLayerColorsHex */
    --layer0-base: #b07aa1; /* Profile */
    --layer1-base: #4e79a7; /* Foundations */
    --layer2-base: #f28e2c; /* Skills */
    --layer3-base: #59a14f; /* Impact */
    --layer4-base: #9c65ab; /* Outcome */
    --fallback-color: #aabbc8; /* Fallback */

    /* Pre-calculated Variants (Based on base + brighter(0.7)) */
    /* Layer 0 (Usually only 1 parent) */
    --layer0-variant-0: var(--layer0-base); /* #b07aa1 */
    --layer0-variant-1: #c193b4; /* Lighter */
    --layer0-variant-2: #d0acc6; /* Lighter */
    --layer0-variant-3: #dec5d9; /* Lighter */
    --layer0-variant-4: #ebdeeB; /* Lighter */

    /* Layer 1 */
    --layer1-variant-0: var(--layer1-base); /* #4e79a7 */
    --layer1-variant-1: #6f97c0; /* Lighter */
    --layer1-variant-2: #8fb1d9; /* Lighter */
    --layer1-variant-3: #aecbf2; /* Lighter */
    --layer1-variant-4: #cee5ff; /* Lighter */

    /* Layer 2 */
    --layer2-variant-0: var(--layer2-base); /* #f28e2c */
    --layer2-variant-1: #f5a456; /* Lighter */
    --layer2-variant-2: #f7ba80; /* Lighter */
    --layer2-variant-3: #facfab; /* Lighter */
    --layer2-variant-4: #fde4d5; /* Lighter */

    /* Layer 3 */
    --layer3-variant-0: var(--layer3-base); /* #59a14f */
    --layer3-variant-1: #7cb871; /* Lighter */
    --layer3-variant-2: #9fcfa3; /* Lighter */
    --layer3-variant-3: #c1e6d5; /* Lighter */
    --layer3-variant-4: #e2fcef; /* Lighter */

    /* Layer 4 */
    --layer4-variant-0: var(--layer4-base); /* #9c65ab */
    --layer4-variant-1: #b182be; /* Lighter */
    --layer4-variant-2: #c6a0d1; /* Lighter */
    --layer4-variant-3: #dabdde; /* Lighter */
    --layer4-variant-4: #eddbeb; /* Lighter */


    /* Text colors - MUST match main-graph.js config.textColorsHex */
    --color-text-light: #f0f0f0;
    --color-text-dark: #333333; /* Renamed for clarity */
    --color-text: var(--color-text-dark); /* Default text color */

    /* Other UI Colors */
    --color-background: #dcdced;
    --color-popup-bg: #fff;
    --popup-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
    --transition-duration: 0.25s;
    --transition-ease: ease-in-out;
    --node-stroke: #fff;
    --node-highlight-stroke: #ff5722; /* Orange for focus/search/walkthrough */
    --node-details-stroke: #4a00e0; /* Purple for details-shown node */

    /* Relationship colors */
    --rel-has-foundation: #76b7b2; /* Teal */
    --rel-has-subcategory: #c0c0c0; /* Grey */
    --rel-develops: #e15759; /* Red */
    --rel-creates: #76b7b2; /* Teal */
    --rel-leads-to: #ff9d9a; /* Pink */

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================================================ */
/* ==================== Base Styles =========================== */
/* ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    color: var(--color-text);
    background-color: var(--color-background);
    margin: 0;
    overflow: hidden; /* Prevent body scroll */
    width: 100vw;
    height: 100vh;
    position: relative;
}
#graph-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}
#graph-container svg {
    display: block; /* Remove potential extra space below SVG */
}

/* Visually hidden elements (for accessibility and SEO) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

/* SEO content wrapper - hidden visually but available to search engines */
.seo-content {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
    top: 0;
    left: 0;
    z-index: -9999; /* Ensure it's below all other content */
    pointer-events: none; /* Prevents interaction with the hidden content */
    /* Fallback color applied to child elements below for higher specificity */
}

/* Fallback: Make text color match background for elements inside seo-content */
.seo-content *, 
.seo-content p, 
.seo-content h2, 
.seo-content a {
    color: var(--color-background) !important; /* Use !important to override potential conflicts */
    background-color: transparent !important; /* Ensure no background color interferes */
}


/* ============================================================ */
/* ==================== Node Styles =========================== */
/* ============================================================ */

/* Base Node Circle Style */
#graph-container .node circle {
    stroke: var(--node-stroke);
    stroke-width: 2px;
    cursor: pointer;
    /* Fill color set by layer/variant classes below */
    transition: fill var(--transition-duration) var(--transition-ease),
                stroke var(--transition-duration) var(--transition-ease),
                stroke-width var(--transition-duration) var(--transition-ease),
                transform 0.15s ease-out, /* Slightly smoother scale */
                filter 0.2s ease-out; /* Transition filter for brightness */
    outline: none; /* Remove default browser focus outline */
}

/* Base Node Text Style */
#graph-container .node text {
    font-size: 11px;
    font-weight: 500;
    /* fill color set by .text-dark / .text-light class rules */
    pointer-events: none; /* Text doesn't block clicks on circle */
    user-select: none; /* Prevent text selection */
    paint-order: stroke; /* Draw stroke behind fill for halo effect */
    stroke: rgba(255, 255, 255, 0.7); /* Default white halo */
    stroke-width: 3px;
    stroke-linecap: butt;
    stroke-linejoin: miter;
    text-anchor: middle;
    dominant-baseline: central;
    transition: opacity 0.2s ease-in-out; /* Smooth show/hide if needed */
}

/* Parent Node Specific Styles */
#graph-container .node-type-parent circle {
    stroke-width: 3px;
}
#graph-container .node-type-parent text {
    font-size: 13px;
    font-weight: bold;
}

/* Child Node Specific Styles */
#graph-container .node-type-child circle {
    stroke-width: 1.5px;
}
#graph-container .node-type-child text {
    font-size: 10px;
    stroke-width: 2px; /* Smaller halo for smaller text */
}

/* Node Fill Color Rules (Applied by JS based on preprocessData) */
/* Layer 0 */
.node.layer-0.color-variant-0 circle { fill: var(--layer0-variant-0, var(--fallback-color)); }
.node.layer-0.color-variant-1 circle { fill: var(--layer0-variant-1, var(--fallback-color)); }
.node.layer-0.color-variant-2 circle { fill: var(--layer0-variant-2, var(--fallback-color)); }
.node.layer-0.color-variant-3 circle { fill: var(--layer0-variant-3, var(--fallback-color)); }
.node.layer-0.color-variant-4 circle { fill: var(--layer0-variant-4, var(--fallback-color)); }
/* Layer 1 */
.node.layer-1.color-variant-0 circle { fill: var(--layer1-variant-0, var(--fallback-color)); }
.node.layer-1.color-variant-1 circle { fill: var(--layer1-variant-1, var(--fallback-color)); }
.node.layer-1.color-variant-2 circle { fill: var(--layer1-variant-2, var(--fallback-color)); }
.node.layer-1.color-variant-3 circle { fill: var(--layer1-variant-3, var(--fallback-color)); }
.node.layer-1.color-variant-4 circle { fill: var(--layer1-variant-4, var(--fallback-color)); }
/* Layer 2 */
.node.layer-2.color-variant-0 circle { fill: var(--layer2-variant-0, var(--fallback-color)); }
.node.layer-2.color-variant-1 circle { fill: var(--layer2-variant-1, var(--fallback-color)); }
.node.layer-2.color-variant-2 circle { fill: var(--layer2-variant-2, var(--fallback-color)); }
.node.layer-2.color-variant-3 circle { fill: var(--layer2-variant-3, var(--fallback-color)); }
.node.layer-2.color-variant-4 circle { fill: var(--layer2-variant-4, var(--fallback-color)); }
/* Layer 3 */
.node.layer-3.color-variant-0 circle { fill: var(--layer3-variant-0, var(--fallback-color)); }
.node.layer-3.color-variant-1 circle { fill: var(--layer3-variant-1, var(--fallback-color)); }
.node.layer-3.color-variant-2 circle { fill: var(--layer3-variant-2, var(--fallback-color)); }
.node.layer-3.color-variant-3 circle { fill: var(--layer3-variant-3, var(--fallback-color)); }
.node.layer-3.color-variant-4 circle { fill: var(--layer3-variant-4, var(--fallback-color)); }
/* Layer 4 */
.node.layer-4.color-variant-0 circle { fill: var(--layer4-variant-0, var(--fallback-color)); }
.node.layer-4.color-variant-1 circle { fill: var(--layer4-variant-1, var(--fallback-color)); }
.node.layer-4.color-variant-2 circle { fill: var(--layer4-variant-2, var(--fallback-color)); }
.node.layer-4.color-variant-3 circle { fill: var(--layer4-variant-3, var(--fallback-color)); }
.node.layer-4.color-variant-4 circle { fill: var(--layer4-variant-4, var(--fallback-color)); }

/* Text Color Classes (Applied by JS based on contrast check) */
.text-light { fill: var(--color-text-light); color: var(--color-text-light); /* Color for SVG text and HTML */ }
.text-dark { fill: var(--color-text-dark); color: var(--color-text-dark); /* Color for SVG text and HTML */ }

/* Text Halo Adjustments for Readability */
/* Light text gets a dark halo */
#graph-container .node text.text-light {
   stroke: rgba(0, 0, 0, 0.6);
   stroke-width: 3.5px;
}
#graph-container .node-type-child text.text-light {
   stroke-width: 2.5px;
}
/* Dark text gets a light halo (already default) */
/* #graph-container .node text.text-dark { stroke: rgba(255, 255, 255, 0.7); stroke-width: 3px; } */


/* ============================================================ */
/* ============ Node Text Visibility Rules ==================== */
/* ============================================================ */

/* Default Visibility: Show parent text, hide child text */
#graph-container .node-type-parent text {
    display: block; /* Or use opacity: 1; */
}
#graph-container .node-type-child text {
    display: none; /* Or use opacity: 0; pointer-events: none; */
}

/* Override Default: Show text based on interaction or persistent state */
/* Includes temporary hover/focus and persistent states */
#graph-container .node.is-interacted text, /* Temp: Hovered/Focused */
#graph-container .node:focus text, /* Temp: Keyboard Focused */
#graph-container .node.focus-highlight text, /* Temp: JS Focus */
#graph-container .node.search-match text, /* Persistent while search active */
#graph-container .node.walkthrough-target text, /* Persistent during walkthrough step */
#graph-container .node.details-shown-for text, /* Persistent: Details shown for this node */
#graph-container .node.is-neighbor text /* Persistent/Temp: Neighbor of interacted/detailed node */
{
    display: block !important; /* Force visibility */
    /* Or use opacity: 1 !important; pointer-events: auto !important; */
}

/* Text Halo Adjustments when Text is Explicitly Shown */
/* Ensure halos remain effective when text is forced visible */
#graph-container .node.is-interacted text.text-light,
#graph-container .node.is-neighbor text.text-light,
#graph-container .node:focus text.text-light,
#graph-container .node.focus-highlight text.text-light,
#graph-container .node.details-shown-for text.text-light,
#graph-container .node.search-match text.text-light,
#graph-container .node.walkthrough-target text.text-light {
    stroke: rgba(0, 0, 0, 0.7) !important; /* Darker halo for light text */
    stroke-width: 3.5px !important;
}
#graph-container .node.is-interacted text.text-dark,
#graph-container .node.is-neighbor text.text-dark,
#graph-container .node:focus text.text-dark,
#graph-container .node.focus-highlight text.text-dark,
#graph-container .node.details-shown-for text.text-dark,
#graph-container .node.search-match text.text-dark,
#graph-container .node.walkthrough-target text.text-dark {
    stroke: rgba(255, 255, 255, 0.8) !important; /* Lighter halo for dark text */
    stroke-width: 3px !important;
}


/* ============================================================ */
/* ============ Node Interaction State Styles ================= */
/* ============================================================ */

/* Temporary Hover/Focus State (.is-interacted, :focus) */
#graph-container .node.is-interacted circle, /* Includes mouse hover and temp focus */
#graph-container .node:focus circle {
    /* Avoid applying if details are shown (JS prevents adding .is-interacted) */
    /* Use :not selector if JS might still add class briefly */
    /* Example: #graph-container .node.is-interacted:not(.details-shown-for) circle */
    stroke: #333;
    filter: brightness(1.1);
    transform: scale(1.08);
}
#graph-container .node:focus circle {
    stroke: var(--node-highlight-stroke) !important; /* Use highlight color for focus */
    stroke-width: 4px !important;
    transform: scale(1.08); /* Consistent scale on focus */
    filter: brightness(1.1);
  
}

/* Dragging State */
#graph-container .node.dragging circle {
    stroke: var(--node-highlight-stroke) !important;
    stroke-width: 4px !important;
    cursor: grabbing;
    filter: brightness(1.15);
    transform: scale(1.05); /* Slightly less scale than hover/focus */
}

/* Persistent Details Shown State (.details-shown-for) */
#graph-container .node.details-shown-for circle {
    stroke: var(--node-details-stroke) !important; /* Distinct stroke color */
    stroke-width: 4px !important; /* Prominent stroke */
    transform: scale(1.08); /* Maintain scale */
    filter: brightness(1.05); /* Subtle brightness */
    /* Optional: Add a subtle glow */
    /* filter: brightness(1.05) drop-shadow(0 0 5px var(--node-details-stroke)); */
}

/* Neighbor State (.is-neighbor) */
/* Style for neighbors (when target is hovered OR has details shown) */
#graph-container .node.is-neighbor circle {
    filter: brightness(1.05);
    transform: scale(1.03);
    stroke-width: 2px;
    stroke-opacity: 0.8;
    transition: all 0.2s ease-in-out;
}
#graph-container .node.is-neighbor:focus circle,
#graph-container .node.is-neighbor.is-interacted circle {
    /* Focus/hover states take precedence - keep their styles */
    filter: brightness(1.1);
    transform: scale(1.08);
    stroke: #333;
}
#graph-container .node.is-neighbor.details-shown-for circle {
    /* Details-shown state takes precedence */
    stroke: var(--node-details-stroke) !important;
    stroke-width: 4px !important;
    transform: scale(1.08);
    filter: brightness(1.05);
}

/* Fading and Highlighting (Global - applied during hover OR details shown) */
#graph-container .node.faded {
    opacity: 0.15;
    transition: opacity 0.4s ease;
}
#graph-container .node:not(.faded) {
    opacity: 1; /* Ensure non-faded nodes are fully opaque */
}
#graph-container .node.is-interacted, /* Temp hover/focus */
#graph-container .node:focus{
    outline: none; /* Ensure the group element also has no outline */
}
#graph-container .node.focus-highlight, /* Temp JS focus */
#graph-container .node.details-shown-for, /* Persistent */
#graph-container .node.search-match,
#graph-container .node.walkthrough-target,
#graph-container .node.dragging {
    opacity: 1 !important; /* Override fading */
}

/* Search & JS Focus Highlights (Temporary states) */
#graph-container .node.search-match circle {
    stroke: var(--node-highlight-stroke);
    stroke-width: 4px !important;
}
#graph-container .node.search-non-match {
    opacity: 0.2; /* More faded than standard fade */
}
#graph-container .node.focus-highlight circle {
    stroke: var(--node-highlight-stroke) !important;
    stroke-width: 5px !important;
    filter: drop-shadow(0 0 8px rgba(255, 87, 34, 0.6));
    animation: pulse-focus-highlight 1.5s infinite ease-in-out;
}
@keyframes pulse-focus-highlight {
  0% { stroke-width: 5px; filter: drop-shadow(0 0 4px rgba(255, 87, 34, 0.5)); }
  50% { stroke-width: 7px; filter: drop-shadow(0 0 10px rgba(255, 87, 34, 0.7)); }
  100% { stroke-width: 5px; filter: drop-shadow(0 0 4px rgba(255, 87, 34, 0.5)); }
}


/* ============================================================ */
/* ===================== Link Styles ========================== */
/* ============================================================ */

/* Base Link Style */
#graph-container .link {
    stroke-opacity: 0.4;
    stroke-width: 1.5px;
    transition: stroke-opacity var(--transition-duration) var(--transition-ease),
                stroke-width var(--transition-duration) var(--transition-ease);
}

/* Relationship Type Specific Link Styles */
#graph-container .link[data-type="HAS_FOUNDATION"] { stroke: var(--rel-has-foundation); stroke-width: 2.5px; stroke-opacity: 0.6; }
#graph-container .link[data-type="HAS_SUBCATEGORY"] { stroke: var(--rel-has-subcategory); stroke-opacity: 0.35; }
#graph-container .link[data-type="DEVELOPS"] { stroke: var(--rel-develops); stroke-dasharray: 8, 4; stroke-width: 2px; stroke-opacity: 0.5; }
#graph-container .link[data-type="CREATES"] { stroke: var(--rel-creates); stroke-dasharray: 3, 3; stroke-width: 2px; stroke-opacity: 0.5; }
#graph-container .link[data-type="LEADS_TO"] { stroke: var(--rel-leads-to); stroke-dasharray: 6, 3, 2, 3; stroke-width: 2px; stroke-opacity: 0.5; }

/* Link Highlighting/Fading (during hover OR details shown) */
#graph-container .link.highlighted {
    stroke-opacity: 0.9 !important;
    stroke-width: 3px !important;
}
#graph-container .link.faded {
    stroke-opacity: 0.05 !important; /* Make very faint */
    transition: stroke-opacity 0.4s ease;
}


/* ============================================================ */
/* ================== UI Element Styles ======================= */
/* ============================================================ */

/* Popups (Node Details & Legend) */
#popup, #legend-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: none; /* Use display none/flex for show/hide */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0; /* Start transparent */
    transition: opacity var(--transition-duration) var(--transition-ease);
}
#popup.visible, #legend-popup.visible {
    display: flex; /* Show using flex */
    opacity: 1; /* Fade in */
}
#popup .content, #legend-popup .content {
    background: var(--color-popup-bg);
    padding: 25px 30px;
    border-radius: 10px;
    max-width: 550px;
    width: 90%;
    max-height: 85vh; /* Limit height */
    overflow-y: auto; /* Allow content scrolling */
    position: relative;
    box-shadow: var(--popup-shadow);
    transform: scale(0.95) translateY(10px); /* Start scaled down */
    transition: transform var(--transition-duration) var(--transition-ease),
                opacity var(--transition-duration) var(--transition-ease);
    opacity: 0; /* Start transparent for transition */
}
#popup.visible .content, #legend-popup.visible .content {
    transform: scale(1) translateY(0); /* Animate to full size */
    opacity: 1; /* Animate to full opacity */
}

/* Popup Title Styling (Use color classes applied by JS) */
#popup .content h2, #legend-popup .content h2 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    padding-bottom: 12px;
    font-size: 1.4em;
    /* Color applied by .title-layer-X.color-variant-Y.text-color */
}
#legend-popup .content h2 {
    color: var(--layer2-base); /* Keep Legend title base color (Orange) */
}

/* Popup Close Button */
#popup .close-button, #legend-popup .close-button {
    position: absolute;
    top: 10px; right: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    background: none; /* Style as button */
    border: none;
    cursor: pointer;
    width: 35px; height: 35px;
    line-height: 35px;
    text-align: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    padding: 0;
}
#popup .close-button:hover, #legend-popup .close-button:hover,
#popup .close-button:focus, #legend-popup .close-button:focus {
    color: #666;
    background-color: rgba(0, 0, 0, 0.08);
    outline: 2px solid var(--layer1-base); /* Consistent focus indicator */
    outline-offset: 1px;
}

/* --- HTML Title Color Rules (For Popups/CV - Applied by JS) --- */
/* Define rules for h2, h3, h4, strong using the layer/variant/text classes */
/* Example: */
h2.title-layer-1.color-variant-0.text-dark,
h3.title-layer-1.color-variant-0.text-dark,
h4.title-layer-1.color-variant-0.text-dark,
strong.title-layer-1.color-variant-0.text-dark { color: var(--layer1-variant-0, var(--fallback-color)); }
h2.title-layer-1.color-variant-0.text-light,
h3.title-layer-1.color-variant-0.text-light,
h4.title-layer-1.color-variant-0.text-light,
strong.title-layer-1.color-variant-0.text-light { color: var(--layer1-variant-0, var(--fallback-color)); }
/* Repeat for all layers and variants, respecting text-dark/text-light if needed for contrast inside popups, though usually the colored text IS the contrast element */
/* Layer 0 */
h2.title-layer-0.color-variant-0, h3.title-layer-0.color-variant-0, h4.title-layer-0.color-variant-0, strong.title-layer-0.color-variant-0 { color: var(--layer0-variant-0, var(--fallback-color)); }
/* Layer 1 */
h2.title-layer-1.color-variant-0, h3.title-layer-1.color-variant-0, h4.title-layer-1.color-variant-0, strong.title-layer-1.color-variant-0 { color: var(--layer1-variant-0, var(--fallback-color)); }
h2.title-layer-1.color-variant-1, h3.title-layer-1.color-variant-1, h4.title-layer-1.color-variant-1, strong.title-layer-1.color-variant-1 { color: var(--layer1-variant-1, var(--fallback-color)); }
h2.title-layer-1.color-variant-2, h3.title-layer-1.color-variant-2, h4.title-layer-1.color-variant-2, strong.title-layer-1.color-variant-2 { color: var(--layer1-variant-2, var(--fallback-color)); }
h2.title-layer-1.color-variant-3, h3.title-layer-1.color-variant-3, h4.title-layer-1.color-variant-3, strong.title-layer-1.color-variant-3 { color: var(--layer1-variant-3, var(--fallback-color)); }
h2.title-layer-1.color-variant-4, h3.title-layer-1.color-variant-4, h4.title-layer-1.color-variant-4, strong.title-layer-1.color-variant-4 { color: var(--layer1-variant-4, var(--fallback-color)); }
/* Layer 2 */
h2.title-layer-2.color-variant-0, h3.title-layer-2.color-variant-0, h4.title-layer-2.color-variant-0, strong.title-layer-2.color-variant-0 { color: var(--layer2-variant-0, var(--fallback-color)); }
h2.title-layer-2.color-variant-1, h3.title-layer-2.color-variant-1, h4.title-layer-2.color-variant-1, strong.title-layer-2.color-variant-1 { color: var(--layer2-variant-1, var(--fallback-color)); }
h2.title-layer-2.color-variant-2, h3.title-layer-2.color-variant-2, h4.title-layer-2.color-variant-2, strong.title-layer-2.color-variant-2 { color: var(--layer2-variant-2, var(--fallback-color)); }
h2.title-layer-2.color-variant-3, h3.title-layer-2.color-variant-3, h4.title-layer-2.color-variant-3, strong.title-layer-2.color-variant-3 { color: var(--layer2-variant-3, var(--fallback-color)); }
h2.title-layer-2.color-variant-4, h3.title-layer-2.color-variant-4, h4.title-layer-2.color-variant-4, strong.title-layer-2.color-variant-4 { color: var(--layer2-variant-4, var(--fallback-color)); }
/* Layer 3 */
h2.title-layer-3.color-variant-0, h3.title-layer-3.color-variant-0, h4.title-layer-3.color-variant-0, strong.title-layer-3.color-variant-0 { color: var(--layer3-variant-0, var(--fallback-color)); }
h2.title-layer-3.color-variant-1, h3.title-layer-3.color-variant-1, h4.title-layer-3.color-variant-1, strong.title-layer-3.color-variant-1 { color: var(--layer3-variant-1, var(--fallback-color)); }
h2.title-layer-3.color-variant-2, h3.title-layer-3.color-variant-2, h4.title-layer-3.color-variant-2, strong.title-layer-3.color-variant-2 { color: var(--layer3-variant-2, var(--fallback-color)); }
h2.title-layer-3.color-variant-3, h3.title-layer-3.color-variant-3, h4.title-layer-3.color-variant-3, strong.title-layer-3.color-variant-3 { color: var(--layer3-variant-3, var(--fallback-color)); }
h2.title-layer-3.color-variant-4, h3.title-layer-3.color-variant-4, h4.title-layer-3.color-variant-4, strong.title-layer-3.color-variant-4 { color: var(--layer3-variant-4, var(--fallback-color)); }
/* Layer 4 */
h2.title-layer-4.color-variant-0, h3.title-layer-4.color-variant-0, h4.title-layer-4.color-variant-0, strong.title-layer-4.color-variant-0 { color: var(--layer4-variant-0, var(--fallback-color)); }
h2.title-layer-4.color-variant-1, h3.title-layer-4.color-variant-1, h4.title-layer-4.color-variant-1, strong.title-layer-4.color-variant-1 { color: var(--layer4-variant-1, var(--fallback-color)); }
h2.title-layer-4.color-variant-2, h3.title-layer-4.color-variant-2, h4.title-layer-4.color-variant-2, strong.title-layer-4.color-variant-2 { color: var(--layer4-variant-2, var(--fallback-color)); }
h2.title-layer-4.color-variant-3, h3.title-layer-4.color-variant-3, h4.title-layer-4.color-variant-3, strong.title-layer-4.color-variant-3 { color: var(--layer4-variant-3, var(--fallback-color)); }
h2.title-layer-4.color-variant-4, h3.title-layer-4.color-variant-4, h4.title-layer-4.color-variant-4, strong.title-layer-4.color-variant-4 { color: var(--layer4-variant-4, var(--fallback-color)); }

#popup .content .cv-error { color: var(--rel-develops); font-weight: bold; padding: 15px; border: 1px solid var(--rel-develops); border-radius: 4px; background-color: rgba(225, 87, 89, 0.1); }
#popup .content .cv-profile-header { margin-bottom: 25px; }
#popup .content .cv-profile-body { display: flex; align-items: flex-start; gap: 15px; margin-top: 10px; flex-wrap: wrap; } /* Allow wrap */
#popup .content .cv-profile-summary { flex: 1; min-width: 250px; line-height: 1.5; } /* Allow summary to wrap */
#popup .content img.profile-photo {
    width: 100px; height: 100px;
    border-radius: 50%;
    border: 3px solid; /* Base border style */
    object-fit: cover;
    flex-shrink: 0;
    /* Border color applied by specific class rule below */
}
img.profile-photo.border-layer-0-variant-0 { border-color: var(--layer0-variant-0, var(--fallback-color)); }
/* Add more variants if layer 0 could have them */

#popup .content .cv-section { margin-bottom: 25px; }
/* Section Title Style (Uses color classes applied by JS) */
#popup .content h3.cv-section-title {
    margin-top: 0; margin-bottom: 10px;
    border-bottom: 1px solid #eee; padding-bottom: 5px;
    font-size: 1.2em;
    /* Color applied by .title-layer-X.color-variant-Y */
}
/* List Styles */
#popup .content .cv-list { padding-left: 20px; margin-top: 10px; margin-bottom: 15px; list-style: disc; }
#popup .content .cv-list-no-bullets { list-style-type: none; padding-left: 0; margin-top: 0; }
/* Item Styles */
#popup .content .cv-item { margin-bottom: 15px; }
/* Item Title Style (Uses color classes applied by JS) */
#popup .content .cv-item strong.item-title {
    display: block; margin-bottom: 3px; font-weight: 600;
    /* Color applied by .title-layer-X.color-variant-Y */
}
#popup .content .cv-item-details { margin-left: 20px; margin-top: 5px; font-size: 0.95em; line-height: 1.4; color: #555; }
#popup .content .cv-item-details div { margin-bottom: 5px; } /* For non-list details */
#popup .content .cv-item-details ul { list-style: circle; padding-left: 18px; margin-top: 5px; margin-bottom: 8px; }
#popup .content .cv-item-details ul li { margin-bottom: 5px; }
/* Skills Section Specific Styles */
#popup .content .skills-container { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 15px; margin-bottom: 15px; }
#popup .content .cv-skill-category { flex: 1; min-width: 200px; }
/* Skill Category Title Style (Uses color classes applied by JS) */
#popup .content .cv-skill-category h4 {
    margin-bottom: 8px; font-size: 1.05em;
    /* Color applied by .title-layer-X.color-variant-Y */
}
#popup .content .cv-skill-list { margin-top: 5px; padding-left: 20px; list-style: disc; margin-bottom: 0; }
#popup .content .cv-skill-item { margin-bottom: 5px; font-size: 0.95em; }
/* --- End Classic CV Styles --- */


/* Legend Popup Specific Styles */
#legend-popup .legend-content { padding-top: 10px; }
#legend-popup h3 { font-size: 1.1em; margin-top: 15px; margin-bottom: 10px; color: var(--color-text); }
#legend-popup .legend-item { display: flex; align-items: center; margin-bottom: 8px; font-size: 0.95em; }
#legend-popup .legend-color {
    width: 18px; height: 18px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Background color set by layer/variant class rules below */
}
#legend-popup .legend-color.line { /* Style for link type indicators */
    width: 25px; height: 4px; border-radius: 2px; border: none;
}

/* Legend Color Swatches (Applied by JS - ensure matches node fill rules) */
.legend-color.layer-0.color-variant-0 { background-color: var(--layer0-variant-0, var(--fallback-color)); }
.legend-color.layer-1.color-variant-0 { background-color: var(--layer1-variant-0, var(--fallback-color)); }
.legend-color.layer-2.color-variant-0 { background-color: var(--layer2-variant-0, var(--fallback-color)); }
.legend-color.layer-3.color-variant-0 { background-color: var(--layer3-variant-0, var(--fallback-color)); }
.legend-color.layer-4.color-variant-0 { background-color: var(--layer4-variant-0, var(--fallback-color)); }
/* Add rules for other variants if needed in legend */

/* Legend Relationship Line Colors */
.legend-color.line.rel-has-foundation { background-color: var(--rel-has-foundation); }
.legend-color.line.rel-has-subcategory { background-color: var(--rel-has-subcategory); }
.legend-color.line.rel-develops { background-color: var(--rel-develops); /* Simulate dash with border */ height: 2px; border: 1px dashed var(--rel-develops); background-color: transparent; }
.legend-color.line.rel-creates { background-color: var(--rel-creates); /* Simulate dot with border */ height: 2px; border: 1px dotted var(--rel-creates); background-color: transparent; }
.legend-color.line.rel-leads-to { /* Simulate dash-dot-dot using gradient */
    background: repeating-linear-gradient( 90deg, var(--rel-leads-to), var(--rel-leads-to) 6px, transparent 6px, transparent 9px, var(--rel-leads-to) 9px, var(--rel-leads-to) 11px, transparent 11px, transparent 14px );
    background-size: 14px 100%; height: 2px; border: none;
}


/* Profile Picture Button (Menu Trigger) */
#profile-legend-button {
    position: absolute;
    top: 15px; right: 15px;
    z-index: 101; /* Above menu panel when closed */
    width: 45px; height: 45px;
    border-radius: 50%;
    border: 2px solid; /* Base border */
    border-color: var(--layer0-variant-0, var(--fallback-color)); /* Match profile node color */
    padding: 0;
    cursor: pointer;
    overflow: hidden; /* Clip image */
    background-color: var(--color-background); /* Fallback background */
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#profile-legend-button img { display: block; width: 100%; height: 100%; object-fit: cover; }
#profile-legend-button:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
#profile-legend-button:active { transform: scale(1); box-shadow: 0 2px 5px rgba(0,0,0,0.15); }
#profile-legend-button:focus {
    outline: 3px solid var(--node-highlight-stroke); /* Use consistent highlight color */
    outline-offset: 2px;
}


/* Menu Panel */
#menu-panel {
    position: absolute;
    top: calc(15px + 45px + 8px); /* Position below profile button */
    right: 15px;
    background: var(--color-popup-bg);
    border-radius: 8px;
    box-shadow: var(--popup-shadow);
    padding: 15px;
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0; /* Start hidden */
    transform: translateY(-10px) scale(0.95); /* Start slightly up and scaled down */
    transition: opacity var(--transition-duration) var(--transition-ease), transform var(--transition-duration) var(--transition-ease);
    pointer-events: none; /* Prevent interaction when hidden */
    border: 1px solid rgba(0,0,0,0.1);
    z-index: 100; /* Below profile button */
}
#menu-panel.menu-open {
    opacity: 1; /* Fade in */
    transform: translateY(0) scale(1); /* Animate to final position */
    pointer-events: auto; /* Allow interaction when open */
}

/* Menu Items */
#menu-panel .search-box {
    width: 100%;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 20px; /* Rounded search box */
    padding: 5px 12px;
    transition: border-color 0.2s ease;
}
#menu-panel .search-box:focus-within {
    border-color: var(--layer1-base); /* Highlight on focus */
}
#menu-panel .search-box input {
    flex-grow: 1;
    font-size: 14px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--color-text);
    font-family: var(--font-family);
}
#menu-panel .search-icon { opacity: 0.6; margin-right: 8px; line-height: 1; }
/* Search Feedback (Style the added class) */
#menu-panel .search-feedback {
    width: 100%; text-align: center; margin: 5px 0 0 0;
    font-size: 0.8em; color: var(--rel-develops); /* Use error color */
    display: none; /* Shown by JS */
}
/* Control Buttons */
#menu-panel .control-button {
    width: 100%;
    justify-content: flex-start; /* Align text left */
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    display: inline-flex; /* Align icon and text */
    align-items: center;
    gap: 8px;
    color: #555;
    text-align: left; /* Ensure text aligns left */
}
#menu-panel .control-button:hover {
    background-color: var(--layer1-base); /* Use theme color on hover */
    color: white;
    border-color: var(--layer1-base);
}
#menu-panel .control-button:focus {
     outline: 2px solid var(--layer1-base); /* Consistent focus outline */
     outline-offset: 1px;
     border-color: var(--layer1-base);
}


/* Tooltip */
.tooltip {
    position: absolute; /* Positioned by JS */
    background: rgba(255, 255, 255, 0.95); /* Slightly transparent */
    backdrop-filter: blur(2px); /* Optional background blur */
    color: var(--color-text-dark);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none; /* Prevent tooltip from blocking interactions */
    opacity: 0; /* Start hidden */
    transition: opacity var(--tooltip-fade-in-duration, 0.15s) var(--transition-ease); /* Use config values if possible, else default */
    z-index: 1050; /* Above graph elements */
    max-width: 220px;
    text-align: center;
    box-shadow: var(--popup-shadow);
    border: 1px solid rgba(128, 128, 128, 0.2);
    display: none; /* Initially hidden */
}
.tooltip strong { color: #333; } /* Darker strong text */
/* Tooltip Indicator Swatch */
.tooltip-layer-indicator {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.1);
    /* Background color set by layer/variant classes applied by JS */
}
.tooltip-type { font-size: 0.9em; opacity: 0.7; display: block; margin-top: 2px; }

.tooltip-layer-indicator.layer-0.color-variant-0 { background-color: var(--layer0-variant-0, var(--fallback-color)); }
.tooltip-layer-indicator.layer-1.color-variant-0 { background-color: var(--layer1-variant-0, var(--fallback-color)); }
.tooltip-layer-indicator.layer-1.color-variant-1 { background-color: var(--layer1-variant-1, var(--fallback-color)); }
.tooltip-layer-indicator.layer-2.color-variant-0 { background-color: var(--layer2-variant-0, var(--fallback-color)); }
.tooltip-layer-indicator.layer-2.color-variant-1 { background-color: var(--layer2-variant-1, var(--fallback-color)); }
.tooltip-layer-indicator.layer-3.color-variant-0 { background-color: var(--layer3-variant-0, var(--fallback-color)); }
.tooltip-layer-indicator.layer-3.color-variant-1 { background-color: var(--layer3-variant-1, var(--fallback-color)); }
.tooltip-layer-indicator.layer-4.color-variant-0 { background-color: var(--layer4-variant-0, var(--fallback-color)); }
/* Add more variants if tooltip might show them */


/* ============================================================ */
/* ============ Accessibility & Walkthrough =================== */
/* ============================================================ */

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* Print Styles */
@media print {
    /* Hide interactive UI elements */
    #profile-legend-button, #menu-panel, .tooltip, #popup, #legend-popup, .walkthrough-overlay { display: none !important; }
    body { overflow: visible; height: auto; background-color: #fff; }
    #graph-container { position: static; width: 100%; height: auto; }
    /* Simplify graph appearance for print */
    #graph-container .node circle { stroke: #ccc; fill: #eee !important; /* Override dynamic fill */ }
    #graph-container .node text { display: block !important; fill: #000 !important; stroke: none !important; font-size: 9px !important; } /* Ensure text visible, black, no halo */
    #graph-container .node-type-parent circle { stroke: #aaa; fill: #ddd !important; }
    #graph-container .node-type-parent text { font-weight: bold; font-size: 10px !important; }
    #graph-container .link { stroke: #bbb !important; stroke-opacity: 0.7 !important; }
    #graph-container .link[data-type="HAS_SUBCATEGORY"] { stroke: #ddd !important; }
    /* Dashed/dotted links might not print well, simplify */
    #graph-container .link[data-type="DEVELOPS"],
    #graph-container .link[data-type="CREATES"],
    #graph-container .link[data-type="LEADS_TO"] { stroke: #ccc !important; stroke-dasharray: none !important; }
    /* Ensure popup content (like CV if opened for print) is fully visible */
    #popup .content, #legend-popup .content { box-shadow: none; max-height: none; overflow: visible; }
}

/* Walkthrough Styles */
.walkthrough-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 2000; opacity: 0; display: none; transition: opacity 0.3s ease-in-out; }
.walkthrough-tooltip { position: absolute; background: var(--color-popup-bg); color: var(--color-text); padding: 15px 20px; border-radius: 8px; box-shadow: 0 5px 20px rgba(0,0,0,0.25); z-index: 2001; max-width: 300px; opacity: 0; transition: opacity 0.3s ease-in-out 0.1s; border: 1px solid rgba(0,0,0,0.1); }
.walkthrough-tooltip h3 { margin: 0 0 10px 0; font-size: 1.15em; color: var(--layer1-base); }
.walkthrough-tooltip p { margin: 0 0 15px 0; font-size: 0.95em; line-height: 1.5; }
.walkthrough-tooltip em { font-style: italic; color: var(--layer2-base); } /* Emphasized text */
.walkthrough-tooltip strong { font-weight: 600; color: var(--layer0-base); } /* Strong text */
.walkthrough-buttons { display: flex; justify-content: space-between; border-top: 1px solid #eee; padding-top: 10px; margin-top: 15px; gap: 10px; }
.walkthrough-button { background: var(--layer1-base); color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-size: 0.9em; font-weight: 500; transition: background-color 0.2s; }
.walkthrough-button:hover { background: var(--layer2-base); }
.walkthrough-button:focus { outline: 2px solid var(--layer1-base); outline-offset: 1px; }
.walkthrough-button.walkthrough-skip { background: #aaa; }
.walkthrough-button.walkthrough-skip:hover { background: #888; }
.walkthrough-cursor { position: fixed; /* Use fixed for viewport positioning */ font-size: 24px; animation: point-animation 0.7s infinite ease-in-out; pointer-events: none; z-index: 2500; text-shadow: 0 0 5px rgba(255,255,255,0.7); transform-origin: center bottom; }
@keyframes point-animation { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Walkthrough Node Highlight */
#graph-container .node.walkthrough-target circle {
    stroke: var(--node-highlight-stroke) !important; /* Use consistent highlight color */
    stroke-width: 5px !important; /* Make highlight prominent */
    animation: pulse-walkthrough-highlight 1.5s infinite ease-in-out;
    filter: drop-shadow(0 0 6px var(--node-highlight-stroke));
    opacity: 1 !important; /* Ensure fully visible */
}
@keyframes pulse-walkthrough-highlight {
  0% { stroke-width: 5px; filter: drop-shadow(0 0 4px var(--node-highlight-stroke)); }
  50% { stroke-width: 7px; filter: drop-shadow(0 0 10px var(--node-highlight-stroke)); }
  100% { stroke-width: 5px; filter: drop-shadow(0 0 4px var(--node-highlight-stroke)); }
}
#graph-container .node.walkthrough-target text {
    /* Optional: Slightly bolder/larger text for target node */
    /* font-weight: bold !important; */
    font-size: 13px !important; /* Ensure size override */
}
.walkthrough-element-highlight {
    outline: 3px solid var(--node-highlight-stroke) !important;
    outline-offset: 3px !important;
    border-radius: 4px; /* Optional rounded outline */
    box-shadow: 0 0 15px rgba(255, 87, 34, 0.5) !important; /* Glow effect */
    position: relative; /* Needed for z-index potentially */
    z-index: 2002 !important; /* Ensure highlighted element is above overlay background */
    transition: outline 0.2s ease, box-shadow 0.2s ease;
}


/* ============================================================ */
/* ==================== Responsive Styles ===================== */
/* ============================================================ */

/* Tablet */
@media (max-width: 768px) {
    /* Adjust UI element positions/sizes */
    #profile-legend-button { top: 10px; right: 10px; width: 40px; height: 40px; }
    #menu-panel { top: calc(10px + 40px + 8px); right: 10px; width: 220px; padding: 12px; gap: 10px; }

    /* Slightly smaller base text size in graph */
    #graph-container .node text { font-size: 9px; stroke-width: 2.5px; }
    #graph-container .node-type-parent text { font-size: 10px; stroke-width: 3px; }
    #graph-container .node-type-child text { font-size: 8px; stroke-width: 2px; } /* Only applies if shown */

    /* Adjust halo for explicitly shown text on tablet */
    #graph-container .node.is-interacted text.text-light,
    #graph-container .node.is-neighbor text.text-light,
    #graph-container .node:focus text.text-light,
    #graph-container .node.details-shown-for text.text-light,
    #graph-container .node.search-match text.text-light,
    #graph-container .node.walkthrough-target text.text-light { stroke-width: 3px !important; }

    #graph-container .node.is-interacted text.text-dark,
    #graph-container .node.is-neighbor text.text-dark,
    #graph-container .node:focus text.text-dark,
    #graph-container .node.details-shown-for text.text-dark,
    #graph-container .node.search-match text.text-dark,
    #graph-container .node.walkthrough-target text.text-dark { stroke-width: 2.5px !important; }

    /* Adjust popup padding and sizing */
    #popup .content, #legend-popup .content { max-height: 90vh; padding: 20px; }
    #popup .content h2, #legend-popup .content h2 { font-size: 1.2em; }
    #popup .content img.profile-photo { width: 80px; height: 80px;}
    #popup .content .cv-section-title { font-size: 1.1em; }
    .walkthrough-tooltip { max-width: 280px; }
}

/* Mobile */
@media (max-width: 480px) {
    /* Wider menu panel on small screens */
    #menu-panel { width: calc(100vw - 30px); right: 15px; }
    #menu-panel .control-button { font-size: 13px; padding: 6px 10px; gap: 5px; }
    #menu-panel .search-box input { font-size: 13px; }
    #menu-panel .search-feedback { display: none !important; } /* Hide feedback text */

    /* Adjust popups for small screens */
    #popup .content, #legend-popup .content { padding: 15px; width: 95%; }
    #popup .close-button, #legend-popup .close-button { top: 5px; right: 5px; font-size: 24px; width: 30px; height: 30px; line-height: 30px; }
    /* Center profile photo in popup on mobile */
    #popup .content img.profile-photo { width: 60px; height: 60px; margin: 0 auto 10px auto; float: none; display: block; }
    #popup .content .cv-profile-body { flex-direction: column; align-items: center; text-align: center; }
    #popup .content .cv-item-details { margin-left: 10px; }
    #popup .content .skills-container { gap: 10px; }
    #popup .content .cv-skill-category { min-width: 100%; } /* Stack skill categories */

    /* Legend adjustments */
    #legend-popup .legend-item span { font-size: 0.9em; }
    #legend-popup .legend-color { width: 14px; height: 14px; margin-right: 8px; }

    /* Walkthrough tooltip */
    .walkthrough-tooltip { max-width: calc(100vw - 40px); }

    /* Text size already small, ensure visibility rules work */
    /* The core text visibility logic relies on display: block/none, which works fine on mobile */
}


/* ============================================================ */
/* ===================== FULL CSS END ========================= */
/* ============================================================ */