/* ------------------------------------------------
   Custom Select (Base)
   ------------------------------------------------ */
.gb-custom-select {
  position: relative;
  display: inline-block;
  min-width: var(--btn-min-width, 12rem);
  max-width: var(--content-width, 84.375rem);
  margin-inline: auto;
  width: 100%;
  box-sizing: border-box;
}

/* Toggle button */
.gb-custom-select__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--btn-min-height, 2.75rem);
  min-width: var(--btn-min-width, 12rem);
  padding: var(--btn-padding-block, 0.6rem) var(--btn-padding-inline, 1rem);
  font: 500 var(--btn-font-size, 1rem)/1.2 var(--body-font, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif);
  border: 1px solid var(--primary);
  border-radius: var(--btn-border-radius, 0.5rem);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-focus) 100%);
  color: var(--text-on-primary);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--btn-shadow);
  transition: background var(--btn-transition, 0.2s), box-shadow var(--btn-transition, 0.2s), color var(--btn-transition, 0.2s);
}

/* Caret */
.gb-custom-select__toggle::after {
  content: "";
  inline-size: 1.25em;
  block-size: 1.25em;
  margin-inline-start: 0.75rem;
  background: currentColor;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5z'/></svg>") no-repeat center/contain;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5z'/></svg>") no-repeat center/contain;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.gb-custom-select__toggle[aria-expanded=true]::after {
  transform: rotate(-180deg);
}

/* Dropdown menu */
.gb-custom-select__menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--primary-ultra-light);
  border: 1px solid var(--border-light);
  border-radius: var(--btn-border-radius, 0.5rem);
  /* Use elevation tokens for consistent shadows */
  box-shadow: 0 6px 18px var(--role-elevation-2);
  z-index: 1000;
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.25rem);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
  max-height: min(50vh, 20rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.gb-custom-select:hover .gb-custom-select__menu,
.gb-custom-select:focus-within .gb-custom-select__menu,
.gb-custom-select__menu[data-open=true] {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

/* Menu items */
.gb-custom-select__menu li a,
.gb-custom-select__menu li button {
  display: block;
  padding: 0.6rem 1rem;
  font-size: var(--text-s);
  font-family: var(--body-font, inherit);
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.gb-custom-select__menu li :is(a, button):hover,
.gb-custom-select__menu li :is(a, button):focus {
  background: var(--primary-ultra-light);
  color: var(--primary-dark);
  outline: none;
}

/* Disabled child select */
.gb-custom-select.child-select.disabled .gb-custom-select__toggle {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.gb-custom-select.child-select.disabled .gb-custom-select__menu {
  display: none !important;
}

/* Mobile full width */
@media (max-width: 640px) {
  .gb-custom-select,
  .gb-custom-select__toggle {
    width: 100%;
    min-width: 100%;
  }
}
/* High contrast */
@media (forced-colors: active) {
  .gb-custom-select__toggle {
    border: 1px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
    box-shadow: none;
  }
  .gb-custom-select__toggle:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
/* ------------------------------------------------
   Specialty Filter Overrides & Theming
   ------------------------------------------------ */
.ere-specialty-filter .gb-custom-select:hover .gb-custom-select__menu,
.ere-specialty-filter .gb-custom-select:focus-within .gb-custom-select__menu {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.ere-specialty-filter .gb-custom-select:hover .gb-custom-select__toggle::after {
  transform: none;
}

.ere-select__control {
  text-align: center;
  text-align-last: center;
}

.ere-select__control option {
  text-align: center;
  color: var(--text-primary);
  background: var(--bg-body);
}

/* Theming */
.ere-specialty-filter .ere-field.is-primary :is(.ere-select__control, .gb-custom-select__toggle) {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-focus) 100%);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

.ere-specialty-filter .ere-field.is-secondary :is(.ere-select__control, .gb-custom-select__toggle) {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-focus) 100%);
  color: var(--text-on-secondary);
  border-color: var(--secondary);
}

.ere-specialty-filter .ere-field.is-surface :is(.ere-select__control, .gb-custom-select__toggle) {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* Filter actions */
.ere-specialty-filter .ere-filter-actions[hidden] {
  display: none !important;
}

.ere-specialty-filter .ere-filter-actions:not([hidden]) {
  display: grid;
  gap: var(--space-xs, 0.5rem);
  margin-block-start: var(--space-sm, 0.75rem);
}

@media (min-width: 48rem) {
  .ere-specialty-filter .ere-filter-actions:not([hidden]) {
    grid-template-columns: var(--grid-auto-2, repeat(2, 1fr));
  }
}
.ere-specialty-filter .ere-filter-actions .btn {
  width: 100%;
  justify-content: center;
}

/* Grid for the fields */
.ere-fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-s);
}

@media (min-width: 48rem) {
  .ere-fields-grid {
    grid-template-columns: var(--grid-1);
    align-items: start;
    gap: var(--space-m);
  }
}
/* Ensure controls fill their grid cells */
.gb-custom-select__toggle,
.ere-select__control {
  width: 100%;
  max-width: 100%;
}

/* Filter frame */
.ere-specialty-filter {
  --pad: clamp(.75rem, 1.8vw, 1rem);
  --gap: .65rem;
  padding: var(--pad);
  border-radius: var(--radius-l);
  background: color-mix(in oklch, var(--bg-surface) 92%, white 8%);
  box-shadow: 0 10px 24px var(--shadow-xs);
}

/* Vertical rhythm */
.ere-specialty-filter .ere-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ere-specialty-filter .ere-field + .ere-field {
  margin-block-start: var(--gap);
}

/* Labels */
.ere-specialty-filter .ere-field > label {
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* Native select control */
.ere-select__control {
  appearance: none;
  -webkit-appearance: none;
  inline-size: 100%;
  min-block-size: 3rem;
  border-radius: var(--btn-border-radius, 0.5rem);
  border: 1px solid transparent;
  padding: 0.7rem 1rem;
  padding-right: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--btn-shadow);
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.1rem 1.1rem;
}

/* White caret on color fills */
.ere-specialty-filter .ere-field.is-primary .ere-select__control {
  background-image: linear-gradient(135deg, var(--primary) 0%, var(--primary-focus) 100%), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='%23ffffff'><path d='M7 10l5 5 5-5z'/></svg>");
}

.ere-specialty-filter .ere-field.is-secondary .ere-select__control {
  background-image: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-focus) 100%), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='%23ffffff'><path d='M7 10l5 5 5-5z'/></svg>");
}

.ere-specialty-filter .ere-field.is-surface .ere-select__control {
  background-image: linear-gradient(var(--bg-surface), var(--bg-surface)), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' fill='%23000000'><path d='M7 10l5 5 5-5z'/></svg>");
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

/* States */
.ere-select__control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.06);
}

.ere-select__control:focus-visible {
  outline: 3px solid var(--focus-ring-primary-outline);
  outline-offset: 2px;
  box-shadow: 0 0 0 0.2rem var(--focus-shadow-primary);
}

/* Dense variant */
.ere-specialty-filter.is-dense {
  --gap: .5rem;
  --pad: .75rem;
}

/* Hide field when templated as hidden */
.ere-specialty-filter .ere-field[hidden],
.ere-specialty-filter .ere-field.is-hidden {
  display: none !important;
}
