/* select-menu.css — every select's chevron, and the dropdown list select-menu.js shows for it.
 *
 * Loaded by every page that can show a select (the console, the sign-in and set-up pages, the
 * public call page), after the page's own sheets. Two parts:
 *
 *   1. THE CLOSED SELECT. One chevron for every select, drawn here and nowhere else: inset from
 *      the edge, with room kept for it so a long value never runs under it.
 *   2. THE OPEN LIST (.sd-selmenu): a rounded card below or above the select, or a bottom sheet
 *      on a phone, built by select-menu.js. It sits on <body>, or inside the dialog its select is
 *      in; there its z-index counts inside the dialog's own layer.
 *
 * Colours come from the console's tokens (echo-tokens.css), which the call page loads too; each
 * has a fallback so the list still reads on a page without them. Dark mode is
 * :root[data-theme="dark"] on both. Motion uses the shared motion tokens, with fallbacks, and
 * stops under prefers-reduced-motion.
 */

/* ---- 1. the closed select ------------------------------------------------------------------

   The chevron is a background image, so it is a data: URI (the console's and the call page's
   Content-Security-Policy allow `img-src data:`), one per colour: a URI cannot read a token.
   The `http%3A` in each keeps the SVG namespace from reading as a web address it is not.

   WHY !important. Page sheets style their selects with the `background:` shorthand at higher
   specificity than this rule (a dark field, a disabled field, a sunk filter), and the
   shorthand resets the image, so the chevron would vanish on exactly those fields. This sheet
   is meant to be the one place a select gets its chevron, so the chevron's image, place, size
   and repeat, and the room kept for it, are !important. Nothing else here is.

   WHY PHYSICAL SIDES. The chevron sits at the end of the PAGE's line (the right in English, the
   left in Arabic), not at the end of the select's own text: a time-zone select marked dir="ltr"
   on an Arabic page keeps its chevron on the left like the fields around it. Logical properties
   (padding-inline-end) follow the element's own direction, so this uses left/right keyed on
   <html dir>. The other side's padding stays the page's.

   WHICH SELECTS. The same ones select-menu.js opens its list for: not `multiple`, and a `size`
   of 0 or 1 or none (a dropdown; a size over 1 is a list box the browser draws). A size spelt
   any other way is not one the product writes.

   NOT HERE: the call page's language select (.pc-lang__select) is an invisible layer over the
   page's own language button (call.css), which draws its own look. It opens our list like any
   select, and this part draws nothing on it. */
select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2355504A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  -webkit-appearance: none;
  appearance: none;
  /* --sd-chev-hide is set only while select-menu.js lays a turning copy over the chevron. */
  background-image: var(--sd-chev-hide, var(--sd-chev)) !important;
  background-repeat: no-repeat !important;
  background-size: 12px 12px !important;
  background-position: right 15px center !important;
  cursor: pointer;
}
:root:not([dir="rtl"]) select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) { padding-right: 40px !important; }
:root[dir="rtl"] select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) {
  padding-left: 40px !important;
  background-position: left 15px center !important;
}
select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select):disabled {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23A8A198' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  cursor: not-allowed;
}
:root[data-theme="dark"] select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23BDB7AF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] select:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select):disabled {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2367615A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* The Calls page's filter pills turn ink-dark when a filter is on: the chevron turns light. */
select.sd-hc-select.is-on:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23ECEAE6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] select.sd-hc-select.is-on:not([multiple]):is(:not([size]), [size=""], [size="0"], [size="1"]):not([data-native-select]):not(.pc-lang__select) {
  --sd-chev: url("data:image/svg+xml,%3Csvg xmlns='http%3A//www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%231B1A19' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* While the list is open a copy of the chevron turns over this one (select-menu.js). */
select[data-menu-chevron] { --sd-chev-hide: none; }

/* The turning copy: fixed over the select's own chevron, turned half a circle while open. */
.sd-selmenu-chev {
  position: fixed;
  z-index: 1998;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  transition: transform var(--motion-fast, 120ms) var(--motion-ease-out, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.sd-selmenu-chev[data-state="open"] { transform: rotate(180deg); }
.sd-selmenu-chev[data-state="closing"] {
  transform: rotate(0deg);
  transition-timing-function: var(--motion-ease-in, cubic-bezier(0.4, 0, 1, 1));
}

/* ---- 2. the open list ----------------------------------------------------------------------- */

.sd-selmenu {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line, #E1DED9);
  border-radius: 16px;
  background: var(--surface, #FFFFFF);
  color: var(--ink, #1D1B19);
  box-shadow: var(--sh-float, 0 2px 6px rgb(40 34 28 / 0.06), 0 22px 48px -18px rgb(40 34 28 / 0.28));
  font: inherit;
  font-size: var(--text-small, 0.9375rem);
  line-height: 1.4;
  text-align: start;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* A dark page's cards are --surface; the list floats above them, one step lighter. */
:root[data-theme="dark"] .sd-selmenu {
  background: var(--surface-2, #2E2C29);
  border-color: var(--surface-3, #383532);
}
.sd-selmenu *, .sd-selmenu *::before, .sd-selmenu *::after { box-sizing: border-box; }

/* The search box, for long lists. 16px text stops a phone zooming into it. */
.sd-selmenu__search { position: relative; flex: none; padding: 2px 2px 8px; }
.sd-selmenu__input {
  display: block;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line, #E1DED9);
  border-radius: 12px;
  background: var(--surface-2, #F4F3F0);
  color: var(--ink, #1D1B19);
  font: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.sd-selmenu[dir="rtl"] .sd-selmenu__input { padding: 0 38px 0 12px; }
.sd-selmenu__input::placeholder { color: var(--ink-3, #67615A); opacity: 1; }
.sd-selmenu__input:focus { border-color: var(--focus, #A84A0C); }
:root[data-theme="dark"] .sd-selmenu__input:not(:focus) { border-color: var(--surface-3, #383532); }
:root[data-theme="dark"] .sd-selmenu__input { background: var(--surface-3, #383532); }
.sd-selmenu__find {
  position: absolute;
  top: 14px;
  inset-inline-start: 13px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink-3, #67615A);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.sd-selmenu__list {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
  scrollbar-width: thin;
}
.sd-selmenu__list[hidden] { display: none; }
/* Inside a dialog the menu is inside the console's shell, whose focus ring for every focusable
   element (sadaa.css, FOCUS) would ring the list and square the search box. The list shows its
   focus as the active row's ring, the search box as its border. */
.sd-selmenu .sd-selmenu__list:focus-visible { box-shadow: none; border-radius: 0; }
.sd-selmenu .sd-selmenu__input:focus-visible { box-shadow: none; border-radius: 12px; }

.sd-selmenu__opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--ink, #1D1B19);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
/* An option's own direction (a Latin time zone in an Arabic list) changes how its words run,
   not which side they sit on: every row lines up with the list. */
.sd-selmenu__text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; text-align: match-parent; }
.sd-selmenu__opt:hover, .sd-selmenu__opt.is-active { background: var(--surface-2, #F4F3F0); }
:root[data-theme="dark"] .sd-selmenu__opt:hover, :root[data-theme="dark"] .sd-selmenu__opt.is-active { background: var(--surface-3, #383532); }
/* The row the keys are on carries a ring, so it is clear without a pointer. */
.sd-selmenu[data-input="keyboard"] .sd-selmenu__opt.is-active { outline: 2px solid var(--focus, #A84A0C); outline-offset: -2px; }
/* The value the select has: bold, with a tick. (aria-selected follows the active row instead.) */
.sd-selmenu__opt.is-chosen { font-weight: 700; }
.sd-selmenu__opt[aria-disabled="true"] { color: var(--ink-3, #67615A); cursor: default; }
.sd-selmenu__opt[aria-disabled="true"]:hover { background: transparent; }
.sd-selmenu__check {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ember-ink, #A84A0C);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}
.sd-selmenu__opt.is-chosen .sd-selmenu__check { visibility: visible; }

.sd-selmenu__group {
  padding: 10px 14px 4px;
  color: var(--ink-3, #67615A);
  font-size: var(--text-meta, 0.8125rem);
  font-weight: 700;
}
.sd-selmenu__groupbox + .sd-selmenu__groupbox { margin-top: 4px; border-top: 1px solid var(--line, #E1DED9); }

.sd-selmenu__empty { padding: 12px 14px; color: var(--ink-3, #67615A); }
.sd-selmenu__empty:empty { display: none; }

/* ---- the phone: a bottom sheet ---- */
.sd-selmenu[data-placement="sheet"] {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  max-height: 70dvh;
  padding: 8px 8px max(12px, env(safe-area-inset-bottom));
  border-width: 1px 0 0;
  border-radius: 22px 22px 0 0;
  font-size: 16px;
}
.sd-selmenu__handle {
  flex: none;
  width: 40px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 999px;
  background: var(--line-strong, #8C857D);
  opacity: 0.45;
}
.sd-selmenu__title {
  flex: none;
  padding: 0 14px 10px;
  color: var(--ink, #1D1B19);
  font-weight: 700;
  font-size: 17px;
}
.sd-selmenu[data-placement="sheet"] .sd-selmenu__search { padding: 0 6px 8px; }
.sd-selmenu[data-placement="sheet"] .sd-selmenu__input { height: 44px; }
.sd-selmenu[data-placement="sheet"] .sd-selmenu__find { top: 14px; inset-inline-start: 17px; }
.sd-selmenu[data-placement="sheet"] .sd-selmenu__opt { min-height: 48px; padding: 11px 16px; border-radius: 12px; }
.sd-selmenu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1999;
  background: var(--scrim, rgb(29 27 25 / 0.32));
  -webkit-tap-highlight-color: transparent;
}

/* ---- motion: a short fade and slide away from the select (down when the list is below it, up
   when above), the sheet up from the bottom; leaving runs the same way back. Closing never
   waits for this: the value and focus are back before the list starts to fade. */
.sd-selmenu[data-placement="below"] { animation: sd-selmenu-in-below var(--motion-base, 180ms) var(--motion-ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both; }
.sd-selmenu[data-placement="above"] { animation: sd-selmenu-in-above var(--motion-base, 180ms) var(--motion-ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both; }
.sd-selmenu[data-placement="sheet"] { animation: sd-selmenu-in-sheet calc(var(--motion-base, 180ms) + 60ms) var(--motion-ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both; }
.sd-selmenu-backdrop { animation: sd-selmenu-fade-in var(--motion-base, 180ms) var(--motion-ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both; }
.sd-selmenu[data-state="closing"], .sd-selmenu-backdrop[data-state="closing"] { pointer-events: none; }
.sd-selmenu[data-placement="below"][data-state="closing"] { animation: sd-selmenu-out-below var(--motion-base, 180ms) var(--motion-ease-in, cubic-bezier(0.4, 0, 1, 1)) both; }
.sd-selmenu[data-placement="above"][data-state="closing"] { animation: sd-selmenu-out-above var(--motion-base, 180ms) var(--motion-ease-in, cubic-bezier(0.4, 0, 1, 1)) both; }
.sd-selmenu[data-placement="sheet"][data-state="closing"] { animation: sd-selmenu-out-sheet var(--motion-base, 180ms) var(--motion-ease-in, cubic-bezier(0.4, 0, 1, 1)) both; }
.sd-selmenu-backdrop[data-state="closing"] { animation: sd-selmenu-fade-out var(--motion-base, 180ms) var(--motion-ease-in, cubic-bezier(0.4, 0, 1, 1)) both; }

@keyframes sd-selmenu-in-below { from { opacity: 0; transform: translateY(calc(-1 * var(--motion-rise, 6px))); } }
@keyframes sd-selmenu-in-above { from { opacity: 0; transform: translateY(var(--motion-rise, 6px)); } }
@keyframes sd-selmenu-in-sheet { from { transform: translateY(100%); } }
@keyframes sd-selmenu-out-below { to { opacity: 0; transform: translateY(calc(-1 * var(--motion-rise, 6px))); } }
@keyframes sd-selmenu-out-above { to { opacity: 0; transform: translateY(var(--motion-rise, 6px)); } }
@keyframes sd-selmenu-out-sheet { to { transform: translateY(100%); } }
@keyframes sd-selmenu-fade-in { from { opacity: 0; } }
@keyframes sd-selmenu-fade-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sd-selmenu, .sd-selmenu-backdrop, .sd-selmenu-chev { animation: none !important; transition: none !important; }
}
/* Screenshot runs (?shot=1) freeze motion, as the console's own rule does for .sd-app. */
:root[data-shot="1"] .sd-selmenu, :root[data-shot="1"] .sd-selmenu-backdrop, :root[data-shot="1"] .sd-selmenu-chev { animation: none !important; transition: none !important; }
