/* select.css: the themed drop-down that public/sf/select.js builds for <select data-sf-select> (checkout's State first).
   Served as /_sf/<hash>/select.css on system and checkout pages (views/layout.js). select.js enhances only when this file
   is on the page (--sf-select-ready), so a page without it keeps the native select.
   Colours, corners and fonts come from the page's --sf-* variables: the checkout frame (white, the brand colour or the
   theme's accent) and the system pages (the live theme's own colours, dark themes included). The accent is used for the
   focus ring, the highlighted row's tint and the tick, never a flood. */

:root { --sf-select-ready: 1; }

.sf-select {
  --sfs-bg: var(--co-field, var(--sf-bg, #fff));
  --sfs-text: var(--sf-text, #1d1f2b);
  --sfs-line: var(--sf-line, color-mix(in srgb, var(--sfs-text) 15%, transparent));
  --sfs-accent: var(--sf-accent, #6a5cc4);
  --sfs-r: var(--sf-r, 8px);
  --sfs-muted: color-mix(in srgb, var(--sfs-text) 58%, var(--sfs-bg));
  position: relative;
}

/* The real select stays in the form (posts, autofill, validation) but out of sight, under the button. */
.sf-select > select.sf-select-native {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; pointer-events: none; z-index: -1;
}

/* The button: looks like the page's other fields (checkout: 46 px, 15 px text) */
.sf-select > .sf-select-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  min-height: 46px; margin: 0; padding: 0 12px 0 13px;
  border: 1px solid var(--sfs-line); border-radius: var(--sfs-r); background: var(--sfs-bg); color: var(--sfs-text);
  font: inherit; font-size: 15px; font-weight: 400; line-height: 1.3; text-align: left; cursor: pointer;
  transition: border-color .12s, box-shadow .12s; filter: none;
}
.sf-select > .sf-select-btn:hover { background: var(--sfs-bg); border-color: color-mix(in srgb, var(--sfs-text) 32%, var(--sfs-bg)); }
.sf-select > .sf-select-btn:focus { outline: none; }
.sf-select > .sf-select-btn:focus-visible,
.sf-select.is-open > .sf-select-btn {
  outline: none; border-color: var(--sfs-accent);
  box-shadow: 0 0 0 1px var(--sfs-accent), 0 0 0 4px color-mix(in srgb, var(--sfs-accent) 18%, transparent);
}
.sf-select > .sf-select-btn[aria-invalid="true"] { border-color: var(--sf-danger, #c62f22); box-shadow: 0 0 0 1px var(--sf-danger, #c62f22); }
.sf-select > .sf-select-btn:disabled { opacity: .55; cursor: not-allowed; }
.sf-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-select.is-empty .sf-select-value { color: var(--sfs-muted); }
.sf-select-caret { flex: none; width: 16px; height: 16px; color: var(--sfs-muted); transition: transform .15s; }
.sf-select.is-open .sf-select-caret { transform: rotate(180deg); color: var(--sfs-text); }

/* The list, below the button */
.sf-select-pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  display: flex; flex-direction: column;
  background: var(--sfs-bg); color: var(--sfs-text);
  border: 1px solid var(--sfs-line); border-radius: calc(var(--sfs-r) + 2px);
  box-shadow: 0 12px 32px rgba(15, 16, 26, .16), 0 2px 6px rgba(15, 16, 26, .08);
  overflow: hidden;
}
.sf-select-pop[hidden] { display: none; }

.sf-select-pop > input.sf-select-filter[type="text"] {
  display: block; width: auto; height: 38px; margin: 8px 8px 4px; padding: 0 11px;
  border: 1px solid var(--sfs-line); border-radius: max(4px, calc(var(--sfs-r) - 2px)); background: transparent; color: inherit;
  font: inherit; font-size: 14px; box-shadow: none;
}
.sf-select-pop > input.sf-select-filter[type="text"]::placeholder { color: var(--sfs-muted); opacity: 1; }
.sf-select-pop > input.sf-select-filter[type="text"]:focus { outline: none; border-color: var(--sfs-accent); box-shadow: 0 0 0 1px var(--sfs-accent); }

.sf-select-list {
  margin: 0; padding: 4px; list-style: none; overflow-y: auto; overscroll-behavior: contain;
  max-height: min(296px, 46vh);
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--sfs-text) 22%, transparent) transparent;
}
.sf-select-list::-webkit-scrollbar { width: 8px; }
.sf-select-list::-webkit-scrollbar-track { background: transparent; }
.sf-select-list::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--sfs-text) 22%, transparent); border-radius: 8px; border: 2px solid var(--sfs-bg); }
.sf-select-list::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--sfs-text) 36%, transparent); }

.sf-select-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 36px; padding: 7px 10px; border-radius: max(4px, calc(var(--sfs-r) - 3px));
  font-size: 14px; line-height: 1.3; cursor: pointer; user-select: none;
}
.sf-select-option.is-placeholder { color: var(--sfs-muted); }
.sf-select-option.is-active { background: color-mix(in srgb, var(--sfs-accent) 13%, var(--sfs-bg)); }
.sf-select-option.is-chosen { font-weight: 600; }
.sf-select-option[aria-disabled="true"] { opacity: .45; cursor: default; }
.sf-select-check { flex: none; width: 15px; height: 15px; color: var(--sf-co-link, var(--sfs-accent)); visibility: hidden; }
.sf-select-option.is-chosen:not(.is-placeholder) .sf-select-check { visibility: visible; }
.sf-select-none { padding: 10px; font-size: 14px; color: var(--sfs-muted); }

/* Wider than a narrow column on larger screens, so long names (Dadra & Nagar Haveli and Daman & Diu) fit on a line or two */
@media (min-width: 601px) {
  .sf-select-pop { right: auto; width: max(100%, 280px); }
}

/* Phones and touch screens: bigger rows to tap */
@media (pointer: coarse), (max-width: 600px) {
  .sf-select-option { min-height: 44px; padding: 10px 12px; font-size: 15px; }
  .sf-select-pop > input.sf-select-filter[type="text"] { height: 42px; font-size: 16px; }
  .sf-select-list { max-height: min(320px, 50vh); }
}

@media (prefers-reduced-motion: reduce) {
  .sf-select > .sf-select-btn, .sf-select-caret { transition: none; }
}
