/* Shared CourtSketch components (page cards, field labels, pill toggles, dropdown menus,
   modals, option toggles, chart placeholders).
   Linked by base.html after Tailwind and the base styles, before page CSS: a page that
   needs a variant overrides the rule in its own <style>. Don't paste these into templates.
   See docs/theming.md ("Shared components"). */

.page-card {
    background: var(--cs-board);
    border: 1px solid var(--cs-line-soft);
    border-radius: 0.75rem;
}

/* Context-table shading describes direction relative to the NBA baseline.
   Share colors are neutral about value; FG colors indicate accuracy. */
.cs-context-share-above { background-color: rgba(96, 165, 250, var(--cs-context-alpha, .08)); }
.cs-context-share-below { background-color: rgba(196, 181, 253, var(--cs-context-alpha, .08)); }
.cs-context-fg-above { background-color: rgba(52, 211, 153, var(--cs-context-alpha, .08)); }
.cs-context-fg-below { background-color: rgba(251, 113, 133, var(--cs-context-alpha, .08)); }

/* Wide contract evidence tables keep their columns on phones. Make the
   horizontal gesture visible instead of silently hiding later measures. */
.cs-table-swipe-hint {
    display: none;
    margin: 0.4rem 0 0.6rem;
    padding: 0.4rem 0.6rem;
    border-left: 2px solid var(--cs-orange);
    background: var(--cs-ink-2);
    color: var(--cs-chalk);
    font: 11px/1.4 var(--f-mono);
}
@media (max-width: 767px) {
    .cs-table-swipe-hint { display: block; }
}
/* The rule above beats Tailwind's rounded-* utilities; cards built as
   "rounded-xl sm:rounded-2xl" (shot index/combo, SRS explorer, ...) keep 1rem from sm up. */
@media (min-width: 640px) {
    .page-card.sm\:rounded-2xl {
        border-radius: 1rem;
    }
}

.field-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cs-faint);
    font-family: var(--f-mono);
    margin-bottom: 0.45rem;
}

/* Search fields and jQuery UI player menus used by the salary picker. */
.cs-search-field {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--cs-line);
    border-radius: 0.5rem;
    background: var(--cs-ink);
    color: var(--cs-chalk);
    font-family: var(--f-body);
}
.cs-search-field::placeholder { color: var(--cs-faint); }
.cs-search-field:hover { border-color: var(--cs-dim); }
.cs-search-field:focus-visible {
    outline: 2px solid var(--cs-orange);
    outline-offset: 2px;
}
.ui-autocomplete.cs-player-autocomplete {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--cs-line);
    border-radius: 0.5rem;
    background: var(--cs-board);
    color: var(--cs-chalk);
    font-family: var(--f-body);
    box-shadow: 0 12px 28px color-mix(in srgb, var(--cs-ink) 75%, transparent);
}
.ui-autocomplete.cs-player-autocomplete .ui-menu-item-wrapper {
    padding: 0.5rem 0.85rem;
    border: 0;
    color: var(--cs-dim);
}
.ui-autocomplete.cs-player-autocomplete .ui-menu-item-wrapper:hover,
.ui-autocomplete.cs-player-autocomplete .ui-menu-item-wrapper.ui-state-active {
    margin: 0;
    border: 0;
    background: var(--cs-board-2);
    color: var(--cs-chalk);
}
.cs-player-chip-list .player-tag {
    background: var(--cs-board-2);
    border-color: var(--cs-line);
    color: var(--cs-chalk);
}
.cs-player-chip-list .player-tag:hover { border-color: var(--cs-orange); }
.cs-player-chip-list .remove-player { color: var(--cs-chalk); }


.pill-toggle-track {
    display: inline-flex;
    background: var(--cs-ink);
    border: 1px solid var(--cs-line-soft);
    border-radius: 9999px;
    padding: 3px;
    gap: 2px;
}

.pill-toggle-track button {
    padding: 0.35rem 1.1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--f-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    color: var(--cs-dim);
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.pill-toggle-track button.active {
    background: var(--cs-orange);
    color: var(--cs-on-accent);
    box-shadow: none;
}

.graph-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 480px;
    border: 1.5px dashed var(--cs-line);
    border-radius: 0.75rem;
    background: var(--cs-ink);
    color: var(--cs-faint);
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
    font-family: var(--f-mono);
}
/* Charts render into the placeholder without clearing it: Plotly.newPlot keeps the empty-state
   icon/text next to the plot, and index.js's phone path swaps them for an <img class="img-fluid">.
   Once a chart is there, hide the empty state and drop its frame; the chart stays centered. */
.graph-placeholder:has(> .plot-container, > img.img-fluid) {
    min-height: 0;
    padding: 0;
    border-color: transparent;
}
.graph-placeholder:has(> .plot-container) > :not(.plot-container) {
    display: none;
}

.cs-dropdown-menu {
    background: var(--cs-board);
    border: 1px solid var(--cs-line);
    border-radius: 0.5rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.cs-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    font-family: var(--f-mono);
    font-size: 0.75rem;
    color: var(--cs-dim);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cs-dropdown-item:hover {
    background: var(--cs-board-2);
    color: var(--cs-chalk);
}

.modal-overlay {
    background: rgba(8, 13, 20, 0.85);
    backdrop-filter: blur(8px);
}

.modal-card {
    background: var(--cs-board);
    border: 1px solid var(--cs-line);
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
}

.option-toggle input {
    display: none;
}

.option-toggle input:checked+.option-toggle-track {
    background: var(--cs-orange);
    border-color: var(--cs-orange-deep);
}

.option-toggle input:checked+.option-toggle-track::after {
    transform: translateX(16px);
}

/* Four-factor attribution tree, shared by Enhanced PBP and WOWY. */
.ff-tree-panel { margin-top: 0.9rem; border: 1px solid var(--cs-line-soft); border-radius: 0.55rem; background: var(--cs-ink); }
.ff-tree-panel > summary {
    display: flex; align-items: center; gap: 0.65rem; padding: 0.7rem 0.85rem;
    cursor: pointer; list-style: none; color: var(--cs-chalk); font-family: var(--f-mono);
}
.ff-tree-panel > summary::-webkit-details-marker { display: none; }
.ff-tree-panel > summary::before { content: '▸'; color: var(--cs-orange); font-size: 0.85rem; }
.ff-tree-panel[open] > summary::before { content: '▾'; }
.ff-tree-panel-title { font-size: 0.75rem; font-weight: 800; }
.ff-tree-panel-hint { margin-left: auto; color: var(--cs-faint); font-size: 0.62rem; text-align: right; }
.ff-tree-scroll { overflow-x: auto; padding: 0.8rem; border-top: 1px solid var(--cs-line-soft); }
.ff-tree { min-width: 560px; font-family: var(--f-mono); font-size: 0.7rem; color: var(--cs-chalk); }
.ff-tree-node {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    min-height: 2.45rem; padding: 0.55rem 0.7rem; border: 1px solid var(--cs-line-soft);
    border-radius: 0.42rem; background: var(--cs-board);
}
.ff-tree-label { flex: 1; }
.ff-tree-value { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.82rem; }
.ff-tree-positive { color: #34D399; }
.ff-tree-negative { color: #FB7185; }
.ff-tree-root { width: 48%; min-width: 250px; margin: 0 auto; border-color: var(--cs-orange); font-weight: 800; }
.ff-tree-fork { height: 2rem; position: relative; }
.ff-tree-fork::before { content: ''; position: absolute; left: 50%; top: 0; height: 50%; border-left: 1px solid var(--cs-line); }
.ff-tree-fork::after { content: ''; position: absolute; left: 25%; right: 25%; top: 50%; border-top: 1px solid var(--cs-line); }
.ff-tree-branches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.ff-tree-side { position: relative; min-width: 0; }
.ff-tree-side::before { content: ''; position: absolute; left: 50%; top: -1rem; height: 1rem; border-left: 1px solid var(--cs-line); }
.ff-tree-side-node { font-weight: 700; border-color: var(--cs-orange); }
.ff-tree-side[data-side="defense"] .ff-tree-side-node { border-color: #F472B6; }
.ff-tree-side.is-focus .ff-tree-side-node { background: var(--cs-board-2); box-shadow: 0 0 0 1px var(--cs-chalk) inset; }
.ff-tree-leaves { display: grid; gap: 0.45rem; margin: 0.85rem 0 0 1rem; padding-left: 0.85rem; border-left: 1px solid var(--cs-line); }
.ff-tree-leaf { position: relative; color: var(--cs-dim); }
.ff-tree-leaf::before { content: ''; position: absolute; left: -0.85rem; top: 50%; width: 0.85rem; border-top: 1px solid var(--cs-line); }
.ff-tree-note { margin: 0; padding: 0 0.85rem 0.8rem; color: var(--cs-faint); font-family: var(--f-mono); font-size: 0.65rem; line-height: 1.5; }
@media (max-width: 640px) {
    .ff-tree-panel-hint { display: none; }
    .ff-tree-scroll { padding: 0.5rem; }
    .ff-tree { min-width: 0; font-size: 0.63rem; }
    .ff-tree-node { gap: 0.25rem; min-height: 2.6rem; padding: 0.4rem 0.35rem; }
    .ff-tree-value { font-size: 0.73rem; }
    .ff-tree-root { width: 75%; min-width: 0; }
    .ff-tree-branches { gap: 0.35rem; }
    .ff-tree-leaves { margin-left: 0.25rem; padding-left: 0.25rem; }
    .ff-tree-leaf::before { left: -0.25rem; width: 0.25rem; }
}

/* Data notes: the shared bar (templates/_data_bar.html, static/js/data_notes.js) and /data-notes */
.cs-data-bar { max-width: 1400px; margin: 0.5rem auto 0; padding: 0 1rem; font-size: 0.8rem; line-height: 1.4; color: var(--cs-chalk); text-align: left; }
.cs-data-bar [hidden] { display: none !important; }
.cs-data-bar-full { padding: 0.4rem 0.7rem; border: 1px solid var(--cs-line-soft); border-left: 3px solid var(--cs-orange); border-radius: 6px; background: var(--cs-board); }
.cs-data-bar-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; }
.cs-data-bar-line > i { color: var(--cs-orange); }
.cs-data-bar-line > span { flex: 1 1 18rem; min-width: 0; }
.cs-data-bar-btn { padding: 0.1rem 0.5rem; border: 1px solid var(--cs-line); border-radius: 5px; background: transparent; color: var(--cs-chalk); font-size: 0.75rem; cursor: pointer; white-space: nowrap; }
.cs-data-bar-btn:hover, .cs-data-bar-btn:focus-visible, .cs-data-bar-chip:hover, .cs-data-bar-chip:focus-visible { border-color: var(--cs-orange); }
.cs-data-bar-notes { margin: 0.45rem 0 0.1rem; padding-left: 1.1rem; list-style: disc; }
.cs-data-bar-notes li { margin: 0.25rem 0; }
.cs-data-bar-notes a { color: var(--cs-orange); text-decoration: underline; }
.cs-data-bar-plain { list-style: none; margin-left: -1.1rem; color: var(--cs-dim); }
.cs-data-bar-line > span a { color: var(--cs-orange); text-decoration: underline; }
.cs-data-bar-chip { display: block; margin-left: auto; padding: 0.05rem 0.5rem; border: 1px solid var(--cs-line-soft); border-radius: 999px; background: var(--cs-board); color: var(--cs-dim); font-size: 0.7rem; cursor: pointer; }
.cs-data-bar-chip i { color: var(--cs-orange); }
.cs-dn-page { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; color: var(--cs-chalk); line-height: 1.6; }
.cs-dn-page h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.6rem; }
.cs-dn-lead { font-size: 1.02rem; }
.cs-dn-meta, .cs-dn-seasons { color: var(--cs-dim); font-size: 0.85rem; margin-top: 0.35rem; }
.cs-dn-toc { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin: 1rem 0 0.5rem; font-size: 0.88rem; }
.cs-dn-toc a { color: var(--cs-orange); text-decoration: underline; }
.cs-dn-note { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--cs-line-soft); scroll-margin-top: 5rem; }
.cs-dn-note h2 { font-size: 1.2rem; font-weight: 700; }
.cs-dn-note p { margin-top: 0.55rem; }
.cs-dn-short { font-weight: 600; }
.cs-dn-why { margin-top: 0.7rem; }
.cs-dn-why summary { cursor: pointer; color: var(--cs-dim); font-size: 0.88rem; }
.cs-dn-why summary:hover, .cs-dn-why summary:focus-visible { color: var(--cs-chalk); }

/* Graphs on /data-notes (static/js/data_notes_charts.js). Fixed series colors, validated on the site's dark boards; all text uses theme tokens. */
.cs-dn-fig { --dn-s1: #3987e5; --dn-s2: #d95926; --dn-s3: #199e70; margin: 1.1rem 0; padding: 0.9rem; background: var(--cs-board); border: 1px solid var(--cs-line-soft); border-radius: 8px; color: var(--cs-chalk); }
.cs-dn-fig figcaption strong { display: block; font-size: 0.98rem; font-weight: 700; line-height: 1.3; }
.cs-dn-fig figcaption span { display: block; margin-top: 0.15rem; color: var(--cs-dim); font-size: 0.8rem; line-height: 1.4; }
.dn-body { margin-top: 0.6rem; }
.dn-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.dn-panel { min-width: 0; }
.dn-panel-title { margin-bottom: 0.3rem; font-size: 0.8rem; font-weight: 600; line-height: 1.3; }
.dn-plot { position: relative; }
.dn-plot svg { display: block; max-width: 100%; touch-action: pan-y; }
.dn-t { fill: var(--cs-dim); font-size: 11px; }
.dn-v { fill: var(--cs-chalk); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--cs-board); stroke-width: 3px; }
.dn-v-soft { fill: var(--cs-chalk); font-size: 12px; }
.dn-grid { stroke: var(--cs-line-soft); stroke-width: 1; }
.dn-axis { stroke: var(--cs-faint); stroke-width: 1; }
.dn-ref { stroke: var(--cs-chalk); stroke-width: 1; opacity: 0.7; }
.dn-cross { stroke: var(--cs-faint); stroke-width: 1; }
.dn-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin-bottom: 0.45rem; color: var(--cs-dim); font-size: 0.78rem; }
.dn-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.dn-key-line { display: inline-block; flex: none; width: 14px; height: 2px; border-radius: 1px; }
.dn-key-rect { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.dn-tip { position: absolute; z-index: 5; min-width: 7rem; max-width: 15rem; padding: 0.4rem 0.55rem; background: var(--cs-ink); border: 1px solid var(--cs-line); border-radius: 6px; font-size: 0.75rem; line-height: 1.35; pointer-events: none; }
.dn-tip-title { color: var(--cs-dim); margin-bottom: 0.15rem; }
.dn-tip-row { display: flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.dn-tip-row span { color: var(--cs-dim); }
.dn-table { margin-top: 0.55rem; font-size: 0.8rem; }
.dn-table summary { cursor: pointer; color: var(--cs-dim); }
.dn-table-wrap { margin-top: 0.4rem; overflow-x: auto; }
.dn-table-tall { max-height: 18rem; overflow-y: auto; }
.cs-dn-page table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.cs-dn-page th, .cs-dn-page td { padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--cs-line-soft); text-align: right; white-space: nowrap; }
.cs-dn-page th:first-child, .cs-dn-page td:first-child { text-align: left; }
.cs-dn-page th { color: var(--cs-dim); font-weight: 600; }
.dn-actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.dn-action { padding: 0.2rem 0.55rem; border: 1px solid var(--cs-line); border-radius: 5px; background: transparent; color: var(--cs-dim); font-size: 0.72rem; cursor: pointer; }
.dn-action:hover, .dn-action:focus-visible { color: var(--cs-chalk); border-color: var(--cs-dim); }
.dn-credit { margin-top: 0.45rem; color: var(--cs-faint); font-size: 0.7rem; }
.cs-dn-table-box { margin: 1.1rem 0; padding: 0.9rem; background: var(--cs-board); border: 1px solid var(--cs-line-soft); border-radius: 8px; }
.cs-dn-table-box strong { display: block; font-size: 0.98rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.15rem; }
.cs-dn-table-box > span { display: block; color: var(--cs-dim); font-size: 0.8rem; line-height: 1.4; margin-bottom: 0.55rem; }
.cs-dn-games { margin-top: 0.6rem; padding-left: 0; list-style: none; }
.cs-dn-games li { margin-top: 0.6rem; padding-left: 0.7rem; border-left: 2px solid var(--cs-line); }
.cs-dn-games a { color: var(--cs-orange); text-decoration: underline; font-weight: 600; }
.cs-dn-games span { display: block; color: var(--cs-dim); font-size: 0.82rem; }
@media (max-width: 640px) { .dn-panels { grid-template-columns: minmax(0, 1fr); } }
