/* ==========================================================================
   Dropdowns — ONE look, defined once, for every <select> in the portal
   --------------------------------------------------------------------------
   Greg, 2026-10-07: "drop downs are grey and ugly, need all dropdowns across
   the platform uniform with the design of the rest of the software."

   Loaded LAST by index.html, mobile.html and tablet.html, and written against
   the ELEMENT, not a class. Before this, a dropdown looked right only if its
   author remembered the right class: `.select` on the desktop, `.m-input` on
   the phone, and anything else (`.input rectabs__pick`, `.select--sm`, a bare
   `select`) fell back to the browser's own grey control. An element rule means
   no variant can miss it.

   What it matches: the desktop .input / .select fields (44px, 17px, 11px
   radius, white, accent focus ring), on all three. A phone dropdown keeps the
   HEIGHT its .m-input variant gives it (46px, --sm 44px) so it stands level
   with the text field beside it, but gets the same 17px text (the --sm 15.5px
   was under what a 65-year-old reads).

   The open list on a phone or tablet is the operating system's picker, on
   purpose: it is the one 65-year-olds know (`color-scheme: light` keeps it
   light). On a DESKTOP mouse the list is drawn by js/selectmenu.js as a
   `.selmenu` panel (see the end of this file), so it matches the closed field.

   The class-free sizes live here too: `.select--sm` is the compact dropdown
   for a table row; nothing else resizes a dropdown.
   ========================================================================== */

:root {
  --select-line: rgba(16, 24, 32, .16);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235C6871' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
}

/* ---- A single-choice dropdown ------------------------------------------- */

select:not([multiple]):not([size]),
select[size="1"]:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 38px 10px 12px;
  /* background-COLOR and -image, never the shorthand: it would wipe the chevron.
     Solid white, never translucent: a see-through white went grey on any tinted
     or dark panel, which is most of what "grey" was. */
  background-color: var(--card, var(--surface, #fff));
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  border: 1px solid var(--select-line);
  border-radius: 11px;
  color: var(--ink, #101820);
  color-scheme: var(--ui-scheme, light);
  font-family: inherit;
  font-size: var(--fs-body, 1.0625rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease;
}
select:not([multiple]):not([size]):hover,
select[size="1"]:not([multiple]):hover { border-color: var(--mist, #C2C6C8); }
select:not([multiple]):not([size]):focus,
select[size="1"]:not([multiple]):focus {
  outline: none;
  border-color: var(--accent, #BB2031);
  box-shadow: 0 0 0 3.5px var(--tint, rgba(187, 32, 49, .10));
}

/* Error: a rule that sets the colour AND the ring, so a field the form flagged
   (lib.js adds .select--err; the phone sets aria-invalid) is plainly red. */
select.select--err:not([multiple]),
select.m-input--err:not([multiple]),
select[aria-invalid="true"]:not([multiple]) { border-color: var(--crimson, #BB2031); }
select.select--err:not([multiple]):focus,
select.m-input--err:not([multiple]):focus,
select[aria-invalid="true"]:not([multiple]):focus { box-shadow: 0 0 0 3.5px rgba(187, 32, 49, .14); }

/* Disabled: pale and flat, still readable. */
select:disabled:not([multiple]) {
  background-color: var(--band, #F4F6F8);
  border-color: var(--hair-soft, #E6EAEE);
  color: var(--steel-lt, var(--mute, #8A949B));
  cursor: not-allowed;
  opacity: 1;
}

/* The compact dropdown for a table row or a dense toolbar: 40px, 15px text. */
select.select--sm:not([multiple]) {
  min-height: 40px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: var(--fs-label, .9375rem);
}

/* ---- The options --------------------------------------------------------- */

select option, select optgroup {
  background-color: var(--ui-surface, #fff);
  color: var(--ink, #101820);
  font-size: var(--fs-body, 1.0625rem);
  font-weight: 400;
}
select option:disabled { color: var(--steel-lt, #8A949B); }

/* ---- A list box (multiple / size > 1) ------------------------------------ */
/* Not a dropdown: no chevron, rows stack. It still gets the field's skin. */

select[multiple], select[size]:not([size="1"]) {
  box-sizing: border-box;
  max-width: 100%;
  padding: 6px;
  background-color: var(--card, var(--surface, #fff));
  background-image: none;
  border: 1px solid var(--select-line);
  border-radius: 11px;
  color: var(--ink, #101820);
  color-scheme: var(--ui-scheme, light);
  font-family: inherit;
  font-size: var(--fs-body, 1.0625rem);
  line-height: 1.25;
}
select[multiple]:focus, select[size]:not([size="1"]):focus {
  outline: none;
  border-color: var(--accent, #BB2031);
  box-shadow: 0 0 0 3.5px var(--tint, rgba(187, 32, 49, .10));
}
select[multiple] option, select[size]:not([size="1"]) option { padding: 6px 8px; border-radius: 6px; }

/* ---- The open list on a desktop (js/selectmenu.js) ------------------------- */
/* Greg, 2026-10-07: "They are not in line or have been cleaned up." The browser's
   own popup is grey, translucent and blue-highlighted, and cannot be styled. On a
   fine pointer the portal draws its own: the card colour whatever sits behind it
   (never translucent), the field's hairline and 11px radius, the same raised shadow
   as the account menu, 44px rows of 17px text, and the portal's red tint (not
   macOS blue) for the highlighted row. Positioned inline by the script (fixed,
   below the field or flipped above it). */

.selmenu {
  position: fixed;
  z-index: 5100;                   /* above modals (60-61) and full-screen overlays (.ma-overlay 5000), under sign-in (.bpwrap 9000) and mobile modals (10000+) */
  box-sizing: border-box;
  margin: 0;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--card, var(--surface, #fff));
  border: 1px solid var(--hair, #D3DAE1);
  border-radius: 11px;
  box-shadow: var(--elev-raised, 0 12px 32px -8px rgba(16, 24, 32, .24));
  color: var(--ink, #101820);
  color-scheme: var(--ui-scheme, light);
  font-family: inherit;
  font-size: var(--fs-body, 1.0625rem);
  line-height: 1.25;
  animation: pop .13s ease;
}

.selmenu__opt {
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--ink, #101820);
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.selmenu__text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* The check mark sits in a reserved 16px slot on every row, so the words do not
   shift when the selection moves; it is drawn only on the selected one. */
.selmenu__opt::after {
  content: "";
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
}
.selmenu__opt.is-selected { color: var(--ui-link, var(--accent-dark, #94141F)); font-weight: 600; }
.selmenu__opt.is-selected::after {
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The highlighted row: under the pointer or on the keyboard, one state. */
.selmenu__opt.is-active { background-color: var(--tint, rgba(187, 32, 49, .10)); color: var(--ui-link, var(--accent-dark, #94141F)); }

.selmenu__opt[aria-disabled="true"] { color: var(--steel-lt, #8A949B); cursor: not-allowed; }

/* An <optgroup> label: a small heading, not a choice. */
.selmenu__group {
  box-sizing: border-box;
  padding: 12px 12px 4px;
  color: var(--steel, #5C6871);
  font-size: var(--fs-badge, .875rem);
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.25;
  text-transform: uppercase;
  cursor: default;
}
.selmenu__opt + .selmenu__group { margin-top: 4px; border-top: 1px solid var(--hair-soft, #E6EAEE); }

/* The field that owns an open list keeps its focus ring (it keeps focus). */
select[aria-expanded="true"] {
  border-color: var(--accent, #BB2031);
  box-shadow: 0 0 0 3.5px var(--tint, rgba(187, 32, 49, .10));
}

@media (prefers-reduced-motion: reduce) { .selmenu { animation: none; } }
