/* ==========================================================================
   Line of Sponsor – shared hierarchy tree (public page + admin dashboard)
   Colours are CSS custom properties so each side can follow its own theme.
   Defaults follow the website theme (style.css :root variables).
   ========================================================================== */

.st-scope {
    --st-gap: 28px;
    --st-line: #d9cdc6;
    --st-line-width: 2px;
    --st-node-bg: #fff;
    --st-node-border: #e8dfda;
    --st-node-text: var(--dark, #212121);
    --st-node-muted: #857873;
    --st-node-radius: 8px;
    --st-node-shadow: 0 4px 10px rgba(0, 0, 0, .06);
    --st-accent: var(--theme, #b06b54);
    --st-accent-contrast: #fff;
    --st-accent-soft: rgba(176, 107, 84, .1);
    --st-ring: rgba(176, 107, 84, .3);
    --st-root-bg: var(--theme-dark, #351d12);
    --st-root-text: #fff;
    --st-root-muted: rgba(255, 255, 255, .7);
    --st-badge-bg: var(--theme, #b06b54);
    --st-badge-text: #fff;
    --st-badge-alt-bg: var(--theme-dark, #351d12);
    --st-badge-alt-text: #fff;
    --st-canvas-bg: #fdfbfa;
    --st-dot: #eee4df;
    --st-overlay-bg: rgba(253, 251, 250, .97);
    --st-hint-bg: rgba(33, 33, 33, .84);
    --st-font-head: var(--headfont, inherit);
    --st-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---------------------------------------------------------------- viewport */

.st-viewport {
    position: relative;
    overflow: hidden;
    height: 70vh;
    min-height: 440px;
    max-height: 860px;
    background-color: var(--st-canvas-bg);
    background-image: radial-gradient(var(--st-dot) 1px, transparent 1px);
    background-size: 20px 20px;
    border: 1px solid var(--st-node-border);
    border-radius: var(--st-node-radius);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: contain;
}

.st-viewport.is-dragging {
    cursor: grabbing;
}

.st-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    transform-origin: 0 0;
}

.st-canvas.is-animating {
    transition: transform .32s ease;
}

/* ------------------------------------------------------------- tree layout */

.st-tree,
.st-children {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 0;
    padding: 0;
    list-style: none;
}

.st-tree {
    width: max-content;
    padding: 32px 40px 60px;
}

.st-children {
    position: relative;
    padding-top: var(--st-gap);
}

/* line from a member down to the bar above its members */
.st-children::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    height: var(--st-gap);
    border-left: var(--st-line-width) solid var(--st-line);
}

.st-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--st-gap) 7px 0;
}

.st-tree > .st-item {
    padding-top: 0;
}

/* horizontal bar + line into each member */
.st-children > .st-item::before,
.st-children > .st-item::after {
    content: "";
    position: absolute;
    top: 0;
    width: 50%;
    height: var(--st-gap);
    border-top: var(--st-line-width) solid var(--st-line);
}

.st-children > .st-item::before {
    right: 50%;
}

.st-children > .st-item::after {
    left: 50%;
    border-left: var(--st-line-width) solid var(--st-line);
}

.st-children > .st-item:first-child::before,
.st-children > .st-item:last-child::after {
    border: 0 none;
}

.st-children > .st-item:last-child::before {
    right: calc(50% - var(--st-line-width));
    border-right: var(--st-line-width) solid var(--st-line);
    border-radius: 0 10px 0 0;
}

.st-children > .st-item:first-child::after {
    border-radius: 10px 0 0 0;
}

.st-children > .st-item:only-child {
    padding-top: 0;
}

.st-children > .st-item:only-child::before,
.st-children > .st-item:only-child::after {
    display: none;
}

/* ------------------------------------------------------------- member card */

.st-node-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.st-node {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
    max-width: 210px;
    padding: 10px 14px 12px;
    background: var(--st-node-bg);
    color: var(--st-node-text);
    border: 1px solid var(--st-node-border);
    border-radius: var(--st-node-radius);
    box-shadow: var(--st-node-shadow);
    text-align: left;
    white-space: normal;
    cursor: pointer;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.st-node:hover {
    border-color: var(--st-accent);
}

.st-node:focus-visible {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-ring), var(--st-node-shadow);
}

.st-node.is-selected {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px var(--st-ring), 0 8px 18px rgba(0, 0, 0, .08);
}

.st-node.is-root {
    background: var(--st-root-bg);
    color: var(--st-root-text);
    border-color: var(--st-root-bg);
}

.st-node.is-root .st-uid {
    color: var(--st-root-muted);
}

.st-node.is-root.is-selected,
.st-node.is-root:focus-visible {
    box-shadow: 0 0 0 3px var(--st-ring), 0 8px 18px rgba(0, 0, 0, .12);
}

.st-node-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.st-name {
    font-family: var(--st-font-head);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.st-badge {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 50px;
    background: var(--st-badge-bg);
    color: var(--st-badge-text);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.st-badge.is-alt {
    background: var(--st-badge-alt-bg);
    color: var(--st-badge-alt-text);
}

.st-uid {
    font-family: var(--st-font-mono);
    font-size: 11px;
    letter-spacing: .02em;
    color: var(--st-node-muted);
}

/* expand / collapse */
.st-toggle {
    position: absolute;
    left: 50%;
    bottom: 0;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 22px;
    min-width: 22px;
    padding: 0 9px;
    border: 1px solid var(--st-node-border);
    border-radius: 50px;
    background: var(--st-node-bg);
    color: var(--st-node-text);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
    transform: translate(-50%, 50%);
    cursor: pointer;
}

.st-toggle[aria-expanded="true"] {
    width: 22px;
    padding: 0;
}

.st-toggle:hover {
    background: var(--st-accent);
    border-color: var(--st-accent);
    color: var(--st-accent-contrast);
}

.st-icon {
    display: block;
    flex: 0 0 auto;
}

/* --------------------------------------------- overlays (loading / empty / error) */

.st-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    background: var(--st-overlay-bg);
    color: var(--st-node-text);
    text-align: center;
    cursor: default;
    user-select: text;
    -webkit-user-select: text;
}

.st-overlay[hidden] {
    display: none;
}

.st-overlay-title {
    margin: 0;
    font-family: var(--st-font-head);
    font-size: 18px;
    font-weight: 600;
}

.st-overlay-text {
    margin: 0;
    max-width: 420px;
    color: var(--st-node-muted);
}

.st-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.st-skeleton-row {
    display: flex;
    gap: 14px;
}

.st-skeleton-card {
    width: 140px;
    height: 50px;
    border-radius: var(--st-node-radius);
    background: linear-gradient(90deg, var(--st-dot) 25%, var(--st-node-bg) 50%, var(--st-dot) 75%);
    background-size: 200% 100%;
    animation: st-shimmer 1.2s linear infinite;
}

@keyframes st-shimmer {
    to {
        background-position: -200% 0;
    }
}

/* -------------------------------------------------------- hint and notice */

.st-hint,
.st-notice {
    position: absolute;
    left: 50%;
    z-index: 4;
    max-width: calc(100% - 24px);
    padding: 6px 14px;
    border-radius: 50px;
    background: var(--st-hint-bg);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity .3s ease;
}

.st-hint {
    bottom: 12px;
}

.st-viewport.is-used .st-hint {
    opacity: 0;
}

.st-notice {
    top: 50%;
    padding: 10px 18px;
    font-size: 14px;
    opacity: 0;
    transform: translate(-50%, -50%);
}

.st-viewport.show-notice .st-notice {
    opacity: 1;
}

/* ------------------------------------------------- search box / picker */

.st-search {
    position: relative;
}

.st-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 320px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--st-node-bg);
    border: 1px solid var(--st-node-border);
    border-radius: var(--st-node-radius);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .12);
    text-align: left;
}

.st-results[hidden] {
    display: none;
}

.st-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.st-result:hover,
.st-result.is-active {
    background: var(--st-accent-soft);
}

.st-result[aria-selected="true"] .st-result-name {
    color: var(--st-accent);
}

.st-result.is-disabled {
    cursor: not-allowed;
    opacity: .55;
}

.st-result.is-disabled:hover {
    background: transparent;
}

.st-result-name {
    color: var(--st-node-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.st-result-meta,
.st-result-note,
.st-results-empty,
.st-results-more {
    color: var(--st-node-muted);
    font-size: 12px;
    line-height: 1.4;
}

.st-result-note {
    font-style: italic;
}

.st-results-empty,
.st-results-more {
    padding: 8px 10px;
}

.st-result mark {
    padding: 0;
    background: transparent;
    color: var(--st-accent);
    font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
    .st-skeleton-card {
        animation: none;
    }

    .st-node,
    .st-hint,
    .st-notice {
        transition: none;
    }
}

@media (max-width: 767.98px) {
    .st-viewport {
        height: 62vh;
        min-height: 400px;
    }

    .st-tree {
        padding: 24px 24px 48px;
    }
}
