/**
 * Mobile / narrow-tablet section picker (selection bar + bottom sheet).
 * Used by Stats + Player Intelligence. Desktop sidebar remains unchanged ≥1134px.
 */

.section-picker-bar-host:empty {
    display: none;
}

.section-picker-bar {
    display: none;
    width: 100%;
    margin: 0 0 12px;
    padding: 12px 14px;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--match-card-bg, #1a1a1a);
    border: 1px solid var(--match-border, #2a2a2a);
    border-radius: 10px;
    color: var(--text-primary, #fff);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.section-picker-bar:focus-visible {
    outline: 2px solid var(--global-palette2, #629670);
    outline-offset: 2px;
}

.section-picker-bar__lead {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    color: var(--global-palette2, #629670);
}

.section-picker-bar__icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
}

.section-picker-bar__icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.section-picker-bar__crumbs {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}

.section-picker-bar__sep {
    color: #6b6b6b;
    font-weight: 400;
}

.section-picker-bar__dim {
    color: var(--text-secondary, #9a9a9a);
    font-weight: 500;
}

.section-picker-bar__current {
    color: var(--text-primary, #fff);
    font-weight: 600;
}

.section-picker-bar__chev {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    color: #6b6b6b;
    display: inline-flex;
}

.section-picker-bar__chev svg {
    width: 16px;
    height: 16px;
}

/* Overlay + sheet — fixed to viewport */
.section-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.section-picker-overlay.is-on {
    opacity: 1;
    pointer-events: auto;
}

.section-picker-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1201;
    max-height: min(72vh, 640px);
    display: flex;
    flex-direction: column;
    background: #141414;
    border-top: 1px solid var(--match-border, #2a2a2a);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}

.section-picker-sheet.is-on {
    transform: translateY(0);
}

.section-picker-sheet__handle {
    width: 36px;
    height: 4px;
    border-radius: 3px;
    background: #3a3a3a;
    margin: 10px auto 4px;
    flex: 0 0 auto;
}

.section-picker-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 12px;
    border-bottom: 1px solid #232323;
    flex: 0 0 auto;
}

.section-picker-sheet__head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.section-picker-sheet__close {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid var(--match-border, #2a2a2a);
    background: #202020;
    color: var(--text-muted, #9a9a9a);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.section-picker-sheet__close svg {
    width: 14px;
    height: 14px;
}

.section-picker-sheet__scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 8px 20px;
    overscroll-behavior: contain;
}

.section-picker-sg {
    margin-bottom: 2px;
}

.section-picker-sg__head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #cfcfcf;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.section-picker-sg__left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-picker-sg__icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: #6b6b6b;
    flex: 0 0 auto;
}

.section-picker-sg__icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.section-picker-sg.is-active > .section-picker-sg__head {
    background: #141f18;
}

.section-picker-sg.is-active > .section-picker-sg__head .section-picker-sg__icon {
    color: var(--global-palette2, #629670);
}

.section-picker-sg__chev {
    width: 14px;
    height: 14px;
    color: #6b6b6b;
    flex: 0 0 auto;
    display: inline-flex;
    transition: transform 0.15s ease;
}

.section-picker-sg__chev svg {
    width: 14px;
    height: 14px;
}

.section-picker-sg.is-open > .section-picker-sg__head .section-picker-sg__chev {
    transform: rotate(90deg);
}

.section-picker-sg__body {
    display: none;
    padding: 2px 0 6px 8px;
}

.section-picker-sg.is-open > .section-picker-sg__body {
    display: block;
}

.section-picker-branch {
    margin: 0 0 4px;
}

.section-picker-branch__label {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 4px;
    border: none;
    background: transparent;
    color: #6b6b6b;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
}

.section-picker-branch__label .section-picker-sg__chev {
    opacity: 0.7;
}

.section-picker-branch.is-open > .section-picker-branch__label .section-picker-sg__chev {
    transform: rotate(90deg);
}

.section-picker-branch__items {
    display: none;
    padding: 0 0 4px 14px;
}

.section-picker-branch.is-open > .section-picker-branch__items {
    display: block;
}

/* Branch with no label — always show items */
.section-picker-branch--flat > .section-picker-branch__items {
    display: block;
    padding-left: 22px;
}

.section-picker-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    margin: 1px 0;
    border: none;
    border-radius: 6px;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--text-muted, #9a9a9a);
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

.section-picker-item.is-current {
    color: #fff;
    font-weight: 600;
    border-left-color: var(--global-palette2, #629670);
    background: #141f18;
}

html.section-picker-open {
    overflow: hidden;
}

[data-theme="light"] .section-picker-bar {
    background: #fff;
    border-color: #e2e8f0;
    color: #1a202c;
}

[data-theme="light"] .section-picker-bar__dim {
    color: #64748b;
}

[data-theme="light"] .section-picker-sheet {
    background: #f8fafc;
    border-top-color: #e2e8f0;
}

[data-theme="light"] .section-picker-sheet__head h3 {
    color: #0f172a;
}

[data-theme="light"] .section-picker-sheet__close {
    background: #fff;
    border-color: #e2e8f0;
}

[data-theme="light"] .section-picker-sg__head {
    color: #334155;
}

[data-theme="light"] .section-picker-sg.is-active > .section-picker-sg__head {
    background: rgba(98, 150, 112, 0.12);
}

[data-theme="light"] .section-picker-item.is-current {
    background: rgba(98, 150, 112, 0.12);
    color: #0f172a;
}

[data-theme="light"] .section-picker-overlay {
    background: rgba(15, 23, 42, 0.45);
}

/* Show bar / hide desktop sidebars below shared tablet cutoff */
@media (max-width: 1133px) {
    .section-picker-bar {
        display: flex;
    }

    body.page-stats:not(.page-players) .sidebar {
        display: none !important;
    }

    body.page-players .pi-sidebar-col {
        display: none !important;
    }

    body.page-stats:not(.page-players) .container {
        flex-direction: column !important;
    }
}

@media (min-width: 1134px) {
    .section-picker-bar-host {
        display: none !important;
    }

    .section-picker-overlay,
    .section-picker-sheet {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .section-picker-overlay,
    .section-picker-sheet,
    .section-picker-sg__chev {
        transition: none;
    }
}
