/* _th2-select.css - .th2-select (window.th2Select in th2-select.js; specs/th2-select/ux-plan.md).
   Tokens only, logical properties, light + dark from the same rules. No gold: gold is the one primary action. */
.th2-select {
    --th2s-hi: color-mix(in oklab, #fff 80%, transparent);
    --th2s-edge: var(--th2-border-strong);
    position: relative;
    display: block;
    inline-size: 100%;
}
[data-th2-theme="dark"] .th2-select, [data-th2-theme="dark"] .th2-select__list { --th2s-hi: rgba(255, 255, 255, .06); }
.th2-select[hidden] { display: none; }

/* Real select: still in the form and the value source, visually clipped (not display:none) */
.th2-select > select.th2-select__native {
    position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; opacity: 0;
    pointer-events: none;
}

/* ---- Trigger ---- */
.th2-select__trigger {
    display: flex; align-items: center; gap: 10px;
    inline-size: 100%; min-block-size: 52px;
    padding-block: 8px; padding-inline: 14px 12px;
    font: 600 var(--th2-text-lg) / 1.3 var(--th2-font);
    color: var(--th2-ink); text-align: start;
    background: var(--th2-surface);
    border: 1px solid var(--th2-border-control);
    border-radius: var(--th2-r);
    box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 2px 0 var(--th2s-edge), var(--th2-shadow-xs);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.th2-select--compact .th2-select__trigger { min-block-size: 44px; font-size: var(--th2-text-md); }
/* data-th2-select="key": a picker that sits in a row of th2-btn keys (first user: the reminder's snooze, .th2-remind__snooze).
   Same height, radius and type as an md key (44 on a touch screen, like the keys), so the row reads as one shelf. */
.th2-select--key .th2-select__trigger {
    min-block-size: var(--th2-key-h-md, 38px);
    padding-block: 4px;
    border-radius: var(--th2-key-r-md, 10px);
    font-size: var(--th2-text-base);
}
@media (pointer: coarse) { .th2-select--key .th2-select__trigger { min-block-size: var(--th2-key-h-lg, 44px); } }
@media (hover: hover) and (pointer: fine) {
    .th2-select__trigger:hover:not(:disabled) { border-color: var(--th2-border-strong); }
}
.th2-select__trigger:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 1px 0 var(--th2s-edge), var(--th2-shadow-xs); }
.th2-select__trigger:focus { outline: none; }
.th2-select__trigger:focus-visible,
.th2-select.is-open .th2-select__trigger {
    border-color: var(--th2-focus);
    box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 2px 0 var(--th2s-edge), 0 0 0 3px color-mix(in oklab, var(--th2-focus) 35%, transparent);
}
.th2-select__trigger.is-placeholder .th2-select__value { color: var(--th2-ink-2); }
.th2-select__value { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th2-select__icon { flex: 0 0 auto; display: inline-flex; color: var(--th2-ink-2); }
.th2-select__icon[hidden] { display: none; }
.th2-select__chevron {
    flex: 0 0 auto; inline-size: 12px; block-size: 8px; background: var(--th2-ink-2);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.th2-select.is-open .th2-select__chevron { transform: rotate(180deg); }

/* Invalid */
.th2-select__trigger.is-invalid {
    border-color: var(--th2-danger);
    box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 2px 0 color-mix(in oklab, var(--th2-danger) 45%, var(--th2-surface)), var(--th2-shadow-xs);
}
.th2-select__trigger.is-invalid:focus-visible,
.th2-select.is-open .th2-select__trigger.is-invalid {
    border-color: var(--th2-danger);
    box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 2px 0 color-mix(in oklab, var(--th2-danger) 45%, var(--th2-surface)), 0 0 0 3px color-mix(in oklab, var(--th2-danger) 35%, transparent);
}

/* Disabled: flat, "cannot be pressed" */
.th2-select__trigger:disabled {
    background: var(--th2-surface-2); color: var(--th2-muted); box-shadow: none; cursor: not-allowed;
}
.th2-select__trigger:disabled .th2-select__icon { color: var(--th2-muted); }
.th2-select__trigger:disabled .th2-select__chevron { background: var(--th2-muted); }

/* ---- List (top layer, popover="manual") ---- */
.th2-select__list {
    position: fixed; inset: auto; margin: 0;
    box-sizing: border-box;
    min-inline-size: 160px; max-inline-size: min(420px, calc(100vw - 16px));
    max-block-size: 360px; overflow-y: auto; overscroll-behavior: contain;
    padding: 6px;
    color: var(--th2-ink); background: var(--th2-surface);
    border: 1px solid var(--th2-border-strong); border-radius: var(--th2-r-lg);
    box-shadow: 0 1px 0 var(--th2s-hi) inset, 0 3px 0 var(--th2s-edge), var(--th2-shadow-lg);
    opacity: 0; transform: translateY(-4px);
}
.th2-select__list.is-flipped { transform: translateY(4px); }
.th2-select__list.is-open { opacity: 1; transform: none; }
.th2-select__list:focus-visible { outline: none; }
.th2-select__list[hidden] { display: none; }
.th2-select__list--fallback { z-index: 12000; }
.th2-select__sheet-head { display: none; }

.th2-select__option {
    position: relative; display: flex; align-items: center; gap: 10px;
    min-block-size: 48px; padding: 10px 14px; margin-block-end: 2px;
    border-radius: var(--th2-r-sm);
    font: 600 var(--th2-text-lg) / 1.3 var(--th2-font);
    cursor: pointer;
}
.th2-select__option:last-child { margin-block-end: 0; }
.th2-select__option.is-active { background: color-mix(in oklab, var(--th2-focus) 10%, var(--th2-surface)); }
.th2-select__option.is-active::before {
    content: ''; position: absolute; inset-block: 6px; inset-inline-start: 0; inline-size: 3px;
    border-radius: 2px; background: var(--th2-focus);
}
.th2-select__option.is-selected { font-weight: 700; }
.th2-select__option.is-disabled { color: var(--th2-muted); cursor: not-allowed; }
.th2-select__opt-icon { flex: 0 0 auto; inline-size: 20px; display: inline-flex; justify-content: center; color: var(--th2-ink-2); }
.th2-select__opt-icon:empty { display: none; }
.th2-select__opt-text { flex: 1 1 auto; min-inline-size: 0; display: flex; flex-direction: column; }
.th2-select__opt-hint { font-size: 15px; font-weight: 400; color: var(--th2-ink-2); line-height: 1.35; }
.th2-select__opt-hint:empty { display: none; }
.th2-select__check { flex: 0 0 auto; visibility: hidden; color: var(--th2-focus); }
.th2-select__option.is-selected .th2-select__check { visibility: visible; }
.th2-select__group { padding: 10px 14px 4px; font-size: 15px; font-weight: 700; color: var(--th2-ink-2); }

/* Tone dot: always sits next to the option text (WCAG 1.4.1) */
.th2-select__dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--th2-muted-2, var(--th2-muted)); }
.th2-select__dot--success { background: var(--th2-success); }
.th2-select__dot--warning { background: var(--th2-warning); }
.th2-select__dot--danger { background: var(--th2-danger); }
.th2-select__dot--info { background: var(--th2-info); }

@media (prefers-reduced-motion: no-preference) {
    .th2-select__list { transition: opacity 150ms var(--th2-ease-out), transform 150ms var(--th2-ease-out); }
    .th2-select__chevron { transition: transform 100ms var(--th2-ease-out); }
    .th2-select__trigger { transition: transform 100ms var(--th2-ease-out), box-shadow 100ms var(--th2-ease-out), border-color 100ms var(--th2-ease-out); }
}
@media (prefers-reduced-motion: reduce) {
    .th2-select__list, .th2-select__list.is-flipped { transform: none; }
}

/* ---- Phone: bottom sheet ---- */
.th2-select__list--sheet {
    inset-inline: 0; inset-block: auto 0;
    inline-size: auto; max-inline-size: none; min-inline-size: 0;
    max-block-size: 70vh;
    border-radius: var(--th2-r-lg) var(--th2-r-lg) 0 0; border-inline: 0; border-block-end: 0;
    padding-block-end: max(12px, env(safe-area-inset-bottom));
    transform: translateY(100%);
}
.th2-select__list--sheet.is-flipped { transform: translateY(100%); }
.th2-select__list--sheet.is-open { transform: none; }
.th2-select__list--sheet .th2-select__sheet-head {
    display: block; padding: 8px 14px 10px; font-size: var(--th2-text-lg); font-weight: 700; color: var(--th2-ink);
}
.th2-select__list--sheet .th2-select__option { min-block-size: 56px; }
.th2-select__list--sheet::backdrop { background: color-mix(in oklab, var(--th2-ink) 35%, transparent); }
@media (prefers-reduced-motion: no-preference) {
    .th2-select__list--sheet { transition: transform 200ms var(--th2-ease-out), opacity 200ms var(--th2-ease-out); }
}
@media (prefers-reduced-motion: reduce) {
    .th2-select__list--sheet, .th2-select__list--sheet.is-open { transform: none; }
}
