/* =========================================================
   SHARED EXPANDED STUDY SCOPE CONTROLS

   IMPORTANT
   ---------
   These controls are EXPANDED-PANEL UI only.

   They may exist in the panel DOM while collapsed, but they
   must never be visible in the normal dashboard tile.
   ========================================================= */

/* =========================================================
   HOST VISIBILITY — EXPANDED ONLY
   ========================================================= */

.study-scope-host,
[data-performance-scope] {
    display: none;
}

.dashboard-panel.dashboard-panel--expanded
.study-scope-host,
.dashboard-panel.dashboard-panel--expanded
[data-performance-scope] {
    display: block;
}

.study-scope-host,
.dashboard-panel.dashboard-panel--expanded
[data-performance-scope] {
    width: 100%;
    margin: 0 0 .75rem;
}

/* =========================================================
   SHELL
   ========================================================= */

.study-scope {
    width: 100%;
    padding: .72rem .78rem;
    border: 1px solid var(--dashboard-border, #dfe5ec);
    border-radius: .55rem;
    background: var(--dashboard-surface-soft, #f7f9fb);
}

/* =========================================================
   CONTROL ROW
   ========================================================= */

.study-scope__controls {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: .55rem;
    width: 100%;
}

.study-scope__group {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .22rem;
}

.study-scope__group--geography {
    width: 13rem;
    max-width: 100%;
}

.study-scope__group--reset {
    width: auto;
}

/* =========================================================
   LABELS
   ========================================================= */

.study-scope__label {
    display: block;
    margin: 0;
    color: var(--dashboard-text-soft, #667085);
    font-size: .46rem;
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: .01em;
}

/* =========================================================
   SEGMENTED CONTROLS
   ========================================================= */

.study-scope__segmented {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 2px;
    border: 1px solid var(--dashboard-border, #dfe5ec);
    border-radius: .42rem;
    background: var(--dashboard-surface, #ffffff);
}

.study-scope__button {
    min-width: 68px;
    height: 28px;
    padding: 0 .55rem;
    border: 0;
    border-radius: .32rem;
    background: transparent;
    color: var(--dashboard-text, #344054);
    font: inherit;
    font-size: .48rem;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
}

.study-scope__button:hover {
    background: var(--dashboard-background, #edf1f5);
}

.study-scope__button.is-active {
    background: var(--dashboard-background, #e9eef4);
    color: var(--dashboard-text-strong, #101828);
}

/* =========================================================
   SELECTS
   ========================================================= */

.study-scope__select {
    height: 34px;
    min-width: 105px;
    max-width: 100%;
    padding: 0 1.65rem 0 .55rem;
    border: 1px solid var(--dashboard-border, #dfe5ec);
    border-radius: .42rem;
    background: var(--dashboard-surface, #ffffff);
    color: var(--dashboard-text, #344054);
    font: inherit;
    font-size: .48rem;
    font-weight: 700;
    cursor: pointer;
}

.study-scope__select:hover,
.study-scope__select:focus {
    border-color: var(--dashboard-border-strong, #c7d0dc);
}

.study-scope__select:focus {
    outline: 2px solid color-mix(in srgb, currentColor 12%, transparent);
    outline-offset: 1px;
}

.study-scope__select--geography {
    width: 100%;
    min-width: 13rem;
}

/* =========================================================
   READ-ONLY PERIOD
   ========================================================= */

.study-scope__readonly {
    display: flex;
    align-items: center;
    height: 34px;
    min-width: 96px;
    padding: 0 .55rem;
    border: 1px solid var(--dashboard-border, #dfe5ec);
    border-radius: .42rem;
    background: var(--dashboard-surface, #ffffff);
    color: var(--dashboard-text, #344054);
    font-size: .48rem;
    font-weight: 700;
}

/* =========================================================
   COMPARE
   ========================================================= */

.study-scope__compare {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
}

.study-scope__vs {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding-bottom: 1px;
    color: var(--dashboard-text-soft, #667085);
    font-size: .44rem;
    font-weight: 700;
}

/* =========================================================
   RESET
   ========================================================= */

.study-scope__reset {
    height: 34px;
    padding: 0 .65rem;
    border: 1px solid var(--dashboard-border, #dfe5ec);
    border-radius: .42rem;
    background: var(--dashboard-surface, #ffffff);
    color: var(--dashboard-text, #344054);
    font: inherit;
    font-size: .48rem;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
}

.study-scope__reset:hover:not(:disabled) {
    background: var(--dashboard-background, #edf1f5);
}

.study-scope__reset:disabled {
    color: var(--dashboard-text-soft, #98a2b3);
    opacity: .6;
    cursor: default;
}

/* =========================================================
   DARK MODE
   ========================================================= */

[data-theme="dark"] .study-scope {
    background: #111827;
    border-color: #293548;
}

[data-theme="dark"] .study-scope__segmented,
[data-theme="dark"] .study-scope__select,
[data-theme="dark"] .study-scope__readonly,
[data-theme="dark"] .study-scope__reset {
    background: #172033;
    border-color: #344054;
    color: #f4f7fb;
}

[data-theme="dark"] .study-scope__button {
    color: #d0d5dd;
}

[data-theme="dark"] .study-scope__button:hover,
[data-theme="dark"] .study-scope__button.is-active,
[data-theme="dark"] .study-scope__reset:hover:not(:disabled) {
    background: #253146;
    color: #ffffff;
}

[data-theme="dark"] .study-scope__label,
[data-theme="dark"] .study-scope__vs {
    color: #98a2b3;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1100px) {
    .study-scope__controls {
        gap: .5rem;
    }

    .study-scope__group--geography {
        width: 11rem;
    }

    .study-scope__select--geography {
        min-width: 11rem;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {
    .study-scope {
        padding: .65rem;
    }

    .study-scope__controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .55rem;
    }

    .study-scope__group,
    .study-scope__group--geography,
    .study-scope__group--reset {
        width: 100%;
    }

    .study-scope__segmented,
    .study-scope__select,
    .study-scope__select--geography,
    .study-scope__readonly,
    .study-scope__reset {
        width: 100%;
        min-width: 0;
    }

    .study-scope__segmented {
        display: flex;
    }

    .study-scope__button {
        flex: 1 1 0;
        min-width: 0;
        padding-left: .3rem;
        padding-right: .3rem;
    }

    .study-scope__compare {
        grid-column: 1 / -1;
        width: 100%;
    }

    .study-scope__compare .study-scope__group {
        flex: 1 1 0;
    }
}

/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 460px) {
    .study-scope__controls {
        grid-template-columns: 1fr;
    }

    .study-scope__compare {
        grid-column: auto;
    }
}
