/* School Colors picker shared by settings.html and setup-wizard.html.
 *
 * A custom accessible combobox: the trigger button shows a three-swatch strip
 * (primary / surface / accent) plus the preset name, and the popover listbox
 * renders every curated preset. The hidden colourTheme input remains the form
 * value, so save and unsaved-changes-guard.js keep one simple source of truth. */

.app-theme .school-colors-field {
    margin-bottom: 0;
}

/* School Information labels (School Name and School Colors) share one class
 * so both surfaces render at exactly the same size, weight and spacing. */
.app-theme .school-info-label,
.app-theme .school-colors-label {
    display: block;
    margin: 0 0 9px;
    padding: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.app-theme .school-colors-combobox {
    position: relative;
}

/* Closed trigger: same 44px height, padding rhythm and crisp surface as the
   School Name input above it. */
.app-theme .school-colors-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 7px 11px;
    color: #25364a;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 8px;
    box-shadow: none;
    font: 600 14px "DM Sans", Arial, sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.app-theme .school-colors-trigger:hover,
.app-theme .school-colors-trigger:active {
    background: #fff;
    filter: none;
    transform: none;
    box-shadow: none;
}

.app-theme .school-colors-trigger[aria-expanded="true"] {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 2px var(--app-accent-soft);
}

.app-theme .school-colors-trigger:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.app-theme .school-colors-value {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-theme .school-colors-swatches {
    display: grid;
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid rgba(20, 35, 46, .35);
    border-radius: 5px;
}

.app-theme .school-colors-swatches > span {
    display: block;
    min-width: 0;
}

.app-theme .school-colors-trigger .school-colors-swatches {
    flex: 0 0 54px;
    width: 54px;
    height: 18px;
}

.app-theme .school-colors-summary-name {
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    line-height: 19px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-theme .school-colors-chevron {
    flex: none;
    color: #4a5b6c;
    font-size: 13px;
    line-height: 1;
    transition: transform .15s ease;
}

.app-theme .school-colors-trigger[aria-expanded="true"] .school-colors-chevron {
    transform: rotate(180deg);
}

/* Open popover: a compact, scrollable listbox. Each row keeps a 44px target
   and repeats the three swatches plus the human-readable preset name. */
.app-theme .school-colors-listbox {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    max-height: 302px;
    padding: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #25364a;
    background: #fff;
    border: 1px solid rgba(20, 35, 46, .22);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(4, 14, 24, .34);
}

.app-theme .school-colors-listbox[hidden] {
    display: none;
}

.app-theme .school-color-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color .12s ease;
}

.app-theme .school-color-option:hover,
.app-theme .school-color-option[data-active="true"] {
    background: rgba(11, 31, 51, .08);
}

.app-theme .school-color-option[aria-selected="true"] {
    background: rgba(11, 31, 51, .12);
}

.app-theme .school-color-option .school-colors-swatches {
    flex: 0 0 72px;
    width: 72px;
    height: 24px;
}

.app-theme .school-color-name {
    flex: 1 1 auto;
    min-width: 0;
    color: #22384d;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.app-theme .school-color-check {
    display: inline-grid;
    flex: none;
    width: 22px;
    height: 22px;
    place-items: center;
    color: #7a5d00;
    opacity: 0;
    transform: scale(.8);
    transition: opacity .15s ease, transform .15s ease;
}

.app-theme .school-color-option[aria-selected="true"] .school-color-check {
    opacity: 1;
    transform: none;
}

/* Collapsed School Information subtitle: School Name • mini three-swatch pill.
   The preset name is exposed to assistive tech on the pill (aria-label/title)
   instead of repeating it as visible text. */
.app-theme .school-info-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
}

.app-theme .school-info-summary-name {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-theme .school-info-summary-theme {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
}

.app-theme .school-info-summary-theme[hidden] {
    display: none;
}

.app-theme .school-info-summary-separator {
    color: var(--app-ink-soft);
    font-weight: 700;
}

.app-theme .school-info-summary-theme .school-colors-swatches {
    width: 46px;
    height: 15px;
    border-radius: 4px;
}

.app-theme .school-colors-note {
    margin: 10px 0 0;
    color: var(--sem-info-soft, #a9dcff);
    font-size: 13px;
    line-height: 1.45;
}

/* Collapsed subtitle: Name • [swatches] • Winter. The season label is omitted
   entirely when the automatic checkbox is off. */
.app-theme .school-info-summary-season {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    color: var(--app-ink-soft);
    font-weight: 600;
    white-space: nowrap;
}

.app-theme .school-info-summary-season[hidden] {
    display: none;
}

.app-theme .school-info-summary-season-separator {
    color: var(--app-ink-soft);
    font-weight: 700;
}

/* Hidden form value: real form state without adding visual weight. */
.app-theme input[type="hidden"][name="colorTheme"] {
    display: none;
}

/* Settings keeps the trigger non-interactive while the plan hydrates. */
.pickup-settings-page[data-settings-loading="true"] .school-colors-trigger {
    pointer-events: none;
}

.pickup-settings-page[data-settings-loading="true"] .school-colors-trigger .school-colors-swatches,
.pickup-settings-page[data-settings-loading="true"] .school-colors-trigger .school-colors-summary-name {
    visibility: hidden;
}

.pickup-settings-page .plan-school-info .plan-summary-value {
    max-width: 100%;
}

@media (max-width: 430px) {
    .app-theme .school-colors-trigger .school-colors-swatches {
        flex-basis: 46px;
        width: 46px;
        height: 17px;
    }

    .app-theme .school-color-option .school-colors-swatches {
        flex-basis: 60px;
        width: 60px;
        height: 22px;
    }
}
