/* =============================================================
   Skill Tree — In-Game Style (Zigzag Hubs + Column Clusters)
   ============================================================= */

/* =============================================================
   Skill Points Toolbar
   ============================================================= */

.st-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #1A1B1F;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

.st-toolbar__points {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #e0ddd5;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 10px;
    height: 40px;
    box-sizing: border-box;
    white-space: nowrap;
}

.st-toolbar__label {
    color: #9a978f;
}

.st-toolbar__spent {
    color: #c4a24e;
    font-weight: 700;
}

.st-toolbar__sep {
    color: #4a4840;
}

.st-toolbar__max {
    color: #9a978f;
}

.st-toolbar__remaining {
    color: #8a8780;
    font-weight: 500;
    margin-left: 4px;
}

.st-toolbar__search {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 10px;
    height: 40px;
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
}

.st-toolbar__search-icon {
    color: #5a5850;
    font-size: 14px;
    flex-shrink: 0;
}

.st-toolbar__search-input {
    background: transparent;
    border: none;
    outline: none;
    color: #e0ddd5;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    padding: 0;
    font-family: inherit;
}

.st-toolbar__search-input::placeholder {
    color: #5a5850;
}

.st-toolbar__btn {
    width: 40px;
    height: 40px;
    border: 1px solid #3a3a48;
    border-radius: 4px;
    background: #1a1a24;
    color: #e0ddd5;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    box-sizing: border-box;
    flex-shrink: 0;
}

.st-toolbar__btn:hover {
    border-color: #c4a24e;
    color: #c4a24e;
    background: rgba(196, 162, 78, 0.1);
}

.st-toolbar__btn svg {
    width: 16px;
    height: 16px;
}

/* Right-side button group */
.st-toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Mercenary toolbar: points left, slots center (absolute), buttons right */
.st-toolbar--merc {
    justify-content: flex-start;
}

/* --- Pan+Zoom viewport --- */
.skill-tree-visual-wrapper {
    overflow: hidden;
    background: #1A1B1F;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    border: 1px solid var(--border-color);
    position: relative;
    height: min(850px, calc(100vh - 200px));
    min-height: 400px;
    cursor: grab;
    touch-action: none;
}

/* Fullscreen mode (in-browser, not native) */
body.st-fullscreen-active {
    overflow: hidden;
}
body.st-fullscreen-active .site-header,
body.st-fullscreen-active .site-footer,
body.st-fullscreen-active nav[aria-label="Breadcrumb"] {
    display: none !important;
}
.st-container--fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #1A1B1F;
    display: flex;
    flex-direction: column;
}
.st-container--fullscreen .st-toolbar {
    border-radius: 0;
    border: none;
    flex-shrink: 0;
}
.st-container--fullscreen .skill-tree-visual-wrapper {
    flex: 1;
    max-height: none;
    height: auto;
    border-radius: 0;
    border: none;
}
.skill-tree-visual-wrapper--panning {
    cursor: grabbing;
}

/* --- Virtual canvas (pan+zoom via transform) --- */
.skill-tree-visual {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

/* --- SVG layer (lines + veins) --- */
.skill-tree-visual svg {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    pointer-events: none;
}

/* Vein between hubs — gray bg + red progress overlay */
.st-vein {
    stroke-width: 4;
    stroke-linecap: round;
}
.st-vein--bg {
    stroke: #33333d;
}
.st-vein--progress {
    stroke: #a50905;
    transition: stroke-dasharray 0.3s ease;
}

/* Connection lines within clusters */
.st-line {
    stroke: #33333d;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s ease;
}
.st-line--active {
    stroke: #a50905;
}


/* =============================================================
   Nodes — Shared Base
   ============================================================= */

.st-node {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 1;
    cursor: pointer;
    /* NO flex column — node sizes to shape only so translate centers on the icon */
    transition: opacity 0.25s ease, filter 0.25s ease;
    -webkit-user-select: none;
    user-select: none;
}

.st-node:hover {
    z-index: 3;
}

.st-node--locked {
    cursor: not-allowed;
    pointer-events: auto;
}
.st-node--locked .st-node__shape {
    background: #1A1B1F;
    border-color: #2a2a30;
}
.st-node--locked .st-node__icon {
    opacity: 0.25;
}
.st-node--locked .st-node__rank {
    opacity: 0.25;
}
.st-node--locked:hover {
    filter: none;
}

/* --- Shape container (holds icon) --- */
.st-node__shape {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #3a3a45;
    background: linear-gradient(135deg, #1e1f25 0%, #15161b 100%);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    flex-shrink: 0;
}

.st-node__icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- Label (absolute: outside node box, so translate centers on shape) --- */
.st-node__label {
    display: none;
}

/* --- Rank badge (absolute: below label) --- */
.st-node__rank {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #6a6860;
    background: rgba(0,0,0,0.65);
    padding: 1px 5px;
    border-radius: 3px;
    pointer-events: none;
    line-height: 1.2;
}

/* =============================================================
   Hub Diamonds
   ============================================================= */

.st-hub {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
    /* NO flex column — hub sizes to diamond only so translate centers on it */
    pointer-events: none;
}

.st-hub__diamond {
    width: 56px;
    height: 56px;
    transform: rotate(45deg);
    border: 3px solid #3a3a45;
    background: linear-gradient(135deg, #1c1d23 0%, #111218 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.st-hub--unlocked .st-hub__diamond {
    border-color: #a50905;
    box-shadow: 0 0 18px rgba(165, 9, 5, 0.4);
}

.st-hub__inner {
    transform: rotate(-45deg);
    font-family: var(--font-heading);
    font-size: 13px;
    color: #5a5850;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 2px;
}
.st-hub--unlocked .st-hub__inner {
    color: #a50905;
}
.st-hub__pts-icon {
    font-size: 9px;
    opacity: 0.7;
}

.st-hub__label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: #5a5850;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
    white-space: nowrap;
}
.st-hub--unlocked .st-hub__label {
    color: #c4a24e;
}

/* (st-hub__req removed — points now shown inside diamond) */

/* =============================================================
   Node Types — Shapes & Sizes
   ============================================================= */

/* ACTIVE SKILL — Rounded square */
.st-node--active .st-node__shape {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border-width: 3px;
}

/* PASSIVE — Circle */
.st-node--passive .st-node__shape {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border-width: 2px;
}

/* UPGRADE — Diamond */
.st-node--upgrade .st-node__shape {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    transform: rotate(45deg);
    border-width: 2px;
}
.st-node--upgrade .st-node__icon {
    transform: rotate(-45deg) scale(1.42);
}
.st-node--upgrade .st-node__rank { font-size: 9px; }

/* KEY PASSIVE — Large rounded square */
.st-node--key_passive .st-node__shape {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border-width: 3px;
}

/* =============================================================
   Mercenary Tree — Larger node sizes
   Active skills: 100x100, Passives: 60x60
   ============================================================= */
.merc-tab .st-node--active .st-node__shape {
    width: 100px;
    height: 100px;
}
.merc-tab .st-node--passive .st-node__shape {
    width: 65px;
    height: 65px;
}
.merc-tab .st-node--upgrade .st-node__shape {
    width: 65px;
    height: 65px;
}
.merc-tab .st-node--key_passive .st-node__shape {
    width: 100px;
    height: 100px;
}

/* =============================================================
   Node States
   ============================================================= */

/* Unallocated (rank 0, not locked) — dimmed */
.st-node:not(.st-node--allocated):not(.st-node--selected):not(.st-node--locked) .st-node__icon {
    opacity: 0.4;
}
.st-node:not(.st-node--allocated):not(.st-node--selected):not(.st-node--locked) .st-node__shape {
    border-color: #2a2a30;
}

/* Allocated (rank > 0) */
.st-node--allocated .st-node__shape {
    border-color: #a50905;
    box-shadow: 0 0 12px rgba(165, 9, 5, 0.45);
}
.st-node--allocated .st-node__rank {
    color: #d4a04a;
}

/* Maxed out */
.st-node--maxed .st-node__shape {
    border-color: #d40b06;
    box-shadow: 0 0 18px rgba(212, 11, 6, 0.55);
    animation: st-glow-pulse 3s ease-in-out infinite;
}

/* Selected key passive */
.st-node--selected .st-node__shape {
    border-color: #d40b06;
    box-shadow: 0 0 22px rgba(212, 11, 6, 0.6);
}

@keyframes st-glow-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(165, 9, 5, 0.45); }
    50% { box-shadow: 0 0 22px rgba(212, 11, 6, 0.65); }
}

/* =============================================================
   Hover Effects
   ============================================================= */

.st-node:not(.st-node--locked):hover .st-node__shape {
    border-color: #c4a24e;
    box-shadow: 0 0 16px rgba(196, 162, 78, 0.4);
}

/* --- Search highlight --- */
.st-node--search-match .st-node__shape {
    outline: 2px solid #ffd700 !important;
    outline-offset: 1px;
    z-index: 15 !important;
    filter: brightness(1.3);
}
.st-node--search-match {
    z-index: 15 !important;
}

/* =============================================================
   Error / Empty state
   ============================================================= */

.skill-tree-empty {
    padding: 3rem;
    text-align: center;
    color: var(--text-dimmed);
    font-size: 1rem;
}

/* =============================================================
   Zoom Controls
   ============================================================= */

.st-zoom-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 12;
    font-size: 12px;
    color: #7a7870;
    background: rgba(15, 16, 20, 0.75);
    padding: 2px 8px;
    border-radius: 3px;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

/* Legacy zoom controls (hidden) */
.st-zoom-controls { display: none; }

/* =============================================================
   Leveling Path Toggle
   ============================================================= */

.st-toolbar__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 18px;
    height: 40px;
    box-sizing: border-box;
}

.st-toolbar__toggle-input {
    display: none;
}

.st-toolbar__toggle-switch {
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: #2a2a35;
    border: 1px solid #3a3a45;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.st-toolbar__toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6a6860;
    transition: transform 0.2s ease, background 0.2s ease;
}

.st-toolbar__toggle-input:checked + .st-toolbar__toggle-switch {
    background: rgba(165, 9, 5, 0.3);
    border-color: #a50905;
}

.st-toolbar__toggle-input:checked + .st-toolbar__toggle-switch::after {
    transform: translateX(16px);
    background: #a50905;
}

.st-toolbar__toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #7a7870;
    white-space: nowrap;
}

.st-toolbar__toggle-input:checked ~ .st-toolbar__toggle-label {
    color: #a50905;
}

/* =============================================================
   Leveling Path Panel
   ============================================================= */

.st-path-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    background: rgba(15, 16, 20, 0.96);
    border-right: 1px solid #2a2a35;
    z-index: 6;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    pointer-events: auto;
}

.st-path-panel--open {
    transform: translateX(0);
}

.st-path-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #2a2a35;
    font-size: 14px;
    font-weight: 700;
    color: #a50905;
}

.st-path-panel__count {
    font-size: 12px;
    font-weight: 500;
    color: #6a6860;
}

.st-path-panel__list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: #3a3a45 transparent;
}

.st-path-panel__empty {
    padding: 24px 14px;
    color: #5a5850;
    font-size: 13px;
    text-align: center;
    font-style: italic;
}

.st-path-panel__step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    font-size: 13px;
    color: #c0bdb5;
    background: rgba(25, 26, 32, 0.8);
    border: 1px solid #252830;
    border-radius: 4px;
    transition: border-color 0.15s ease;
    cursor: pointer;
}

.st-path-panel__step:hover {
    border-color: rgba(196, 162, 78, 0.3);
}

.st-node--highlight {
    z-index: 20 !important;
    transform: translate(-50%, -50%) scale(1.25);
    transition: transform 0.3s ease;
}
.st-node--highlight .st-node__shape {
    box-shadow: 0 0 28px 14px rgba(196, 162, 78, 0.7);
    transition: box-shadow 0.3s ease;
}
.st-node--highlight .st-node__icon {
    opacity: 1 !important;
}

.st-path-panel__num {
    min-width: 18px;
    text-align: center;
    font-weight: 700;
    color: #5a5850;
    font-size: 15px;
    flex-shrink: 0;
}

.st-path-panel__icon {
    width: 25px;
    height: 25px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #3a3a45;
}

.st-path-panel__icon-placeholder {
    width: 25px;
    height: 25px;
    border-radius: 4px;
    background: #1e1f25;
    border: 1px solid #2a2a30;
    flex-shrink: 0;
}

.st-path-panel__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.st-path-panel__check {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #3a3a45;
    background: rgba(25, 26, 32, 0.8);
    color: #c4a24e;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: border-color 0.15s, background 0.15s;
}
.st-path-panel__check:hover {
    border-color: #c4a24e;
    background: rgba(196, 162, 78, 0.1);
}
.st-path-panel__step--checked .st-path-panel__check {
    background: rgba(196, 162, 78, 0.2);
    border-color: #c4a24e;
}
.st-path-panel__step--checked {
    opacity: 0.4;
}
.st-path-panel__step--checked .st-path-panel__num {
    text-decoration: line-through;
}

.st-path-panel__rank {
    font-size: 11px;
    font-weight: 600;
    color: #6a6860;
    white-space: nowrap;
    flex-shrink: 0;
}

/* =============================================================
   Responsive
   ============================================================= */

@media (max-width: 768px) {
    .st-node__label {
        font-size: 9px;
    }
    .st-hub__label {
        font-size: 11px;
    }
    .st-node--upgrade .st-node__label {
        display: none;
    }

    /* Toolbar wrapping */
    .st-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px;
    }

    .st-toolbar__search {
        order: 10;
        flex: 1 1 100%;
    }

    .st-toolbar__toggle {
        padding: 0 10px;
    }

    .st-toolbar__toggle-label {
        display: none;
    }

    /* Path panel as bottom-sheet */
    .st-path-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        border-right: none;
        border-top: 1px solid #2a2a35;
        transform: translateY(100%);
        z-index: 100;
    }

    .st-path-panel--open {
        transform: translateY(0);
    }

    /* Touch hint */
    .st-touch-hint {
        position: absolute;
        bottom: 40px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(15, 16, 20, 0.85);
        color: #9a978f;
        padding: 6px 16px;
        border-radius: 20px;
        font-size: 12px;
        z-index: 10;
        pointer-events: none;
        white-space: nowrap;
        animation: d4-fade-in 0.5s ease 0.5s both;
    }
}

@media (max-width: 480px) {
    .st-toolbar__points {
        font-size: 12px;
        padding: 0 6px;
        height: 36px;
    }

    .st-toolbar__btn {
        width: 36px;
        height: 36px;
    }

    .skill-tree-visual-wrapper {
        min-height: 350px;
    }
}
