/* ══════════════════════════════════════════════════════════════════════
   skill-mastery.css  –  Skill Mastery sub-tab (sm-* prefix).

   Cards intentionally match the .mkt-detail-page design language:
   subtle gold-tint background, 1px gold border, 4px radius, section
   titles using the mkt-detail-order-title pattern.

   Mounted into #char-tab-mastery by SkillMasteryPanel.jsx.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Root ────────────────────────────────────────────────────────────── */
.sm-root {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding-top: var(--space-sm);
}

.sm-empty {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: var(--space-xl) 0;
}

/* ── Summary bar - reuses .mkt-detail-stats from market-panel.css ───── */
.sm-root .sm-summary.mkt-detail-stats {
    margin-bottom: 0;
}

.sm-root .sm-summary .mkt-item-icon.sm-summary__icon {
    width: 3.6rem;
    height: 3.6rem;
}

.sm-summary__title-row {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.sm-summary__action-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: var(--space-2xs);
}

.sm-reset-row {
    justify-content: flex-end;
}

.sm-reset-trigger {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-danger);
    cursor: pointer;
}

.sm-reset-trigger:hover:not(:disabled) {
    color: rgba(210, 90, 80, 1);
}

.sm-reset-trigger:disabled {
    opacity: 0.45;
    cursor: default;
}

.sm-summary__reset-cost {
    text-align: right;
}

.sm-gold-amount {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    vertical-align: middle;
}

.sm-gold-amount__icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Version 1 roadmap note (above skill trees) ─────────────────────── */
.sm-version-note {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--leading-normal);
    margin: 0;
}

/* ── Tree grid rows (footer in-flow after selected row) ──────────────── */
.sm-tree-stage {
    min-width: 0;
}

.sm-tree-grid-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.sm-tree-grid__row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-md);
    align-items: stretch;
}

.sm-tree-grid__footer-row {
    width: 100%;
    min-width: 0;
}

.sm-tree-grid__cell {
    height: 100%;
    min-width: 0;
}

.sm-tree-grid__cell > .sm-tree-card {
    height: 100%;
}

/* ══════════════════════════════════════════════════════════════════════
   Individual skill card - mirrors .mkt-detail-page
   ══════════════════════════════════════════════════════════════════════ */
.sm-tree-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 20px 24px 20px;
    background: rgba(197, 160, 89, 0.015);
    border: 1px solid rgba(197, 160, 89, 0.12);
    border-radius: 4px;
    transition: border-color 0.15s ease;
}

/* ── Card header ─────────────────────────────────────────────────────── */
.sm-card-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

/* Eyebrow - matches .mkt-detail-eyebrow */
.sm-card-eyebrow {
    font-size: var(--font-size-xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.55);
    font-family: var(--font-heading);
    margin: 0;
}

/* Icon + name row - matches .mkt-detail-header */
.sm-card-ident {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sm-card-icon {
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    object-fit: contain;
}

.sm-card-icon-fallback {
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
}

.sm-card-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Skill name - matches .mkt-detail-order-title */
.sm-card-name {
    font-family: var(--font-heading);
    font-size: var(--font-size-sm);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.65);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
    margin: 0;
}

.sm-card-invested {
    font-size: var(--font-size-xs);
    color: rgba(197, 160, 89, 0.55);
    letter-spacing: 0.04em;
    margin: 0;
}

/* Gradient rule - matches .mkt-detail-rule */
.sm-card-rule {
    flex-shrink: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(197, 160, 89, 0.3), transparent);
    margin: 0 0 14px;
}

.sm-tree-card__unavail {
    padding: var(--space-md) 0;
    color: var(--text-secondary);
    font-style: italic;
    font-size: var(--font-size-sm);
    margin: 0;
}

/* ── Two-lane body ────────────────────────────────────────────────────── */
.sm-tree-card__lanes {
    display: flex;
    flex-shrink: 0;
    align-items: stretch;
    gap: 0;
    width: 100%;
}

/* Vertical spine between lanes - matches .mkt-detail-spine aesthetic */
.sm-lanes-divider {
    width: 1px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(197, 160, 89, 0.25) 15%,
        rgba(197, 160, 89, 0.3) 50%,
        rgba(197, 160, 89, 0.25) 85%,
        transparent 100%
    );
    flex-shrink: 0;
    margin: 0 12px;
}

/* ── Lane column ─────────────────────────────────────────────────────── */
.sm-tree-lane {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
    flex: 1 1 0;
    min-width: 0;
}

/* Lane title row - label left, bonus right */
.sm-tree-lane__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-xs);
    width: 100%;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
    margin-bottom: 2px;
}

.sm-tree-lane__label {
    font-family: var(--font-heading);
    font-size: var(--font-size-sm);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.65);
    min-width: 0;
}

.sm-tree-lane__bonus {
    flex-shrink: 0;
    font-family: var(--font-heading);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}

.sm-tree-lane__bonus--exp {
    color: var(--gold);
}

.sm-tree-lane__bonus--yield {
    color: var(--text-success);
}

/* ── Node track ──────────────────────────────────────────────────────── */
.sm-node-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.sm-node-row {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-node-cell {
    display: flex;
    align-items: center;
}

/* Horizontal connector bar between nodes */
.sm-conn-h {
    display: block;
    width: 5px;
    height: 2px;
    background: rgba(197, 160, 89, 0.15);
    flex-shrink: 0;
}

/* ── Individual node button ──────────────────────────────────────────── */
.sm-tnode {
    position: relative;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    border: 1px solid rgba(197, 160, 89, 0.12);
    background: rgba(197, 160, 89, 0.03);
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease,
        background 0.12s ease;
}

/* Unlocked */
.sm-tnode--on {
    border-color: rgba(197, 160, 89, 0.5);
    background: rgba(197, 160, 89, 0.1);
    box-shadow:
        0 0 8px rgba(197, 160, 89, 0.2),
        inset 0 0 6px rgba(197, 160, 89, 0.08);
}

.sm-tree-lane--yield .sm-tnode--on {
    border-color: rgba(139, 196, 138, 0.5);
    background: rgba(139, 196, 138, 0.08);
    box-shadow:
        0 0 8px rgba(139, 196, 138, 0.2),
        inset 0 0 6px rgba(139, 196, 138, 0.06);
}

/* Next investable (only when points are available) */
.sm-tnode--next {
    border-color: rgba(197, 160, 89, 0.4);
    background: rgba(197, 160, 89, 0.06);
    cursor: pointer;
}

.sm-tree-lane--yield .sm-tnode--next {
    border-color: rgba(139, 196, 138, 0.4);
}

/* Locked / unavailable (including next tier when no points to spend) */
.sm-tnode--off {
    opacity: 0.25;
}

.sm-tnode:hover.sm-tnode--next {
    background: rgba(197, 160, 89, 0.12);
    transform: scale(1.08);
}

.sm-tree-lane--yield .sm-tnode:hover.sm-tnode--next {
    background: rgba(139, 196, 138, 0.1);
}

.sm-tnode__img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}

/* Tier label - bottom-right corner of every node */
.sm-tnode__tier {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-family: var(--font-heading);
    font-size: 7px;
    letter-spacing: 0.02em;
    line-height: 1;
    color: rgba(197, 160, 89, 0.5);
    pointer-events: none;
}

.sm-tnode--on .sm-tnode__tier {
    color: rgba(197, 160, 89, 0.85);
}

.sm-tnode--next .sm-tnode__tier {
    color: rgba(197, 160, 89, 0.65);
}

.sm-tnode__plus {
    position: absolute;
    top: 2px;
    right: 2px;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    color: var(--gold);
    pointer-events: none;
}

.sm-tree-lane--yield .sm-tnode__plus {
    color: var(--text-success);
}

/* Selected for unlock (confirmation bar open) */
.sm-tnode--selected {
    border-color: var(--gold);
    background: rgba(197, 160, 89, 0.14);
    transform: scale(1.06);
}

.sm-tree-lane--yield .sm-tnode--selected {
    border-color: var(--text-success);
    background: rgba(139, 196, 138, 0.12);
}

/* ── Lane footer ─────────────────────────────────────────────────────── */
.sm-tree-lane__foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xs);
    margin-top: auto;
    padding-top: var(--space-xs);
    width: 100%;
}

.sm-tree-lane__progress {
    font-size: var(--font-size-xs);
    color: rgba(197, 160, 89, 0.55);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-heading);
    letter-spacing: 0.08em;
}

/* ── Affects (full-width below lanes) ────────────────────────────────── */
.sm-affects {
    flex-shrink: 0;
    width: 100%;
    margin-top: auto;
    padding-top: var(--space-md);
}

.sm-affects__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-sm);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.65);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
    margin: 0 0 var(--space-sm);
}

.sm-affects__icons {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: var(--space-xs);
    justify-items: center;
}

.sm-affects__item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.sm-affects__item .item-icon {
    width: 2rem;
    height: 2rem;
}

.sm-affects__item .item-icon__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sm-tree-grid__footer-row .srl-upgrade-footer.srl-upgrade-footer--active.sm-select-footer {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: var(--surface-base, #0a0e14);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.sm-select-footer__col {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: 16px 20px;
    min-width: 0;
}

.sm-select-footer__col + .sm-select-footer__col {
    border-left: 1px solid rgba(197, 160, 89, 0.12);
}

.sm-select-footer__eyebrow {
    font-family: var(--font-heading);
    font-size: var(--font-size-xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.55);
    margin: 0 0 var(--space-xs);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
}

.sm-select-footer__node {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.sm-select-footer__icon {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(197, 160, 89, 0.35);
    border-radius: 3px;
    background: rgba(197, 160, 89, 0.06);
    box-shadow: inset 0 0 10px rgba(197, 160, 89, 0.08);
}

.sm-select-footer__icon-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sm-select-footer__icon-fallback {
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
}

.sm-select-footer__icon-tier {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    font-size: 9px;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.55);
    padding: 1px 4px;
    border-radius: 2px;
}

.sm-select-footer__copy {
    min-width: 0;
}

.sm-select-footer__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-md);
    letter-spacing: 0.08em;
    text-transform: none;
    color: var(--gold);
    margin: 0 0 6px;
}

.sm-select-footer__desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    margin: 0;
}

.sm-select-footer__bonus {
    color: var(--gold);
    font-weight: 600;
}

.sm-select-footer__bonus--yield {
    color: var(--text-success);
}

.sm-select-footer__label {
    font-family: var(--font-heading);
    font-size: var(--font-size-xs);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.65);
    margin: 0 0 var(--space-xs);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
}

.sm-select-footer__block--cost {
    margin-top: auto;
}

.sm-select-footer__affects {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: var(--space-xs);
    justify-items: center;
}

.sm-select-footer__affect {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.sm-select-footer__affect .item-icon {
    width: 1.75rem;
    height: 1.75rem;
}

.sm-select-footer__affect .item-icon__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sm-select-footer__cost {
    font-family: var(--font-heading);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.04em;
}

.sm-select-footer__col--actions {
    align-items: stretch;
    justify-content: center;
    gap: var(--space-sm);
    min-width: 11rem;
}

.sm-select-footer__cancel {
    width: 100%;
    padding: 10px 16px;
    font-size: var(--font-size-xs);
}

/* ── Reset modal note ────────────────────────────────────────────────── */
.sm-reset-note {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--leading-normal);
    margin: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sm-tree-grid__row {
        grid-template-columns: 1fr;
    }

    .sm-tree-grid__footer-row .srl-upgrade-footer.srl-upgrade-footer--active.sm-select-footer {
        grid-template-columns: 1fr;
    }

    .sm-select-footer__col + .sm-select-footer__col {
        border-left: none;
        border-top: 1px solid rgba(197, 160, 89, 0.12);
    }

    .sm-conn-h {
        width: 3px;
    }

    .sm-lanes-divider {
        margin: 0 8px;
    }

    .sm-node-row {
        width: 100%;
    }

    .sm-node-cell {
        flex: 1 1 0%;
    }

    .sm-tnode {
        width: 100%;
        aspect-ratio: 1;
        height: auto;
    }

    .sm-tnode__img {
        width: 55%;
        height: 55%;
    }

    .sm-tnode__tier {
        font-size: 10px;
        bottom: 3px;
        right: 4px;
    }

    .sm-tnode__plus {
        font-size: 14px;
        top: 3px;
        right: 4px;
    }

    .sm-root .sm-summary .mkt-item-icon.sm-summary__icon {
        display: none;
    }
}
