/* ============================================================
   LJ SELECT — custom dropdown
   ------------------------------------------------------------
   A native <select> can be styled shut but not open: the option list is an
   OS widget, which is why every dropdown on the site looked like a Windows
   dialog the moment you clicked it. This replaces the visible control with a
   real listbox we own, while the original <select> stays in the DOM as the
   source of truth — every existing `.value` read, `change` listener and
   `required` validation keeps working untouched (see js/lj-select.js).
   ============================================================ */

.ljs {
  position: relative;
  width: 100%;
  min-width: 0;
  font-family: var(--font-family-body);
}

/* The original select. Kept in flow and sized — NOT display:none — because a
   browser refuses to report a validation message on a control it cannot
   focus, and four selects on this site are `required`. Invisible and
   click-through; the trigger below is what people actually interact with. */
.ljs__native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
  appearance: none;
}

/* ── Trigger ── */
.ljs__trigger {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.ljs__trigger:hover { border-color: var(--color-border-light); }
.ljs__trigger:focus-visible,
.ljs.is-open .ljs__trigger {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.15);
}

.ljs__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Placeholder-ish first option ("Select a category…") reads as a prompt, not
   as a chosen value. */
.ljs.is-empty .ljs__label { color: var(--color-text-dim); font-weight: 400; }

.ljs__chev {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.ljs.is-open .ljs__chev { transform: rotate(180deg); }

.ljs__trigger[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
  background: var(--color-bg-surface);
}

/* ── Menu ── */
.ljs__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  max-height: 288px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 6px;
  /* Opens upward when there isn't room below — JS sets this class. */
}
.ljs__menu[hidden] { display: none; }
.ljs--up .ljs__menu {
  top: auto;
  bottom: calc(100% + 6px);
}

.ljs__opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* One highlight style for both mouse hover and keyboard focus, so the two
   never disagree about which row is active. */
.ljs__opt.is-active { background: var(--color-bg-alt); }
.ljs__opt[aria-selected="true"] { font-weight: 700; color: var(--color-heading); }
.ljs__opt[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }

.ljs__check {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  opacity: 0;
  color: var(--color-heading);
}
.ljs__opt[aria-selected="true"] .ljs__check { opacity: 1; }

/* Native <optgroup> carried across as a heading. */
.ljs__group {
  padding: 0.5rem 0.7rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* ── Directory filter bar variant ──
   There the control sits inside .dir-filter-group, which already draws the
   surface, border and icon — so the trigger drops its own chrome and just
   supplies the label and chevron. */
.dir-filter-group .ljs { flex: 1; }
.dir-filter-group .ljs__trigger {
  background: transparent;
  border: 0;
  padding: 10px 0;
  font-size: var(--font-size-sm);
  font-weight: 500;
}
.dir-filter-group .ljs__trigger:hover { border: 0; }
.dir-filter-group .ljs__trigger:focus-visible,
.dir-filter-group .ljs.is-open .ljs__trigger {
  border: 0;
  box-shadow: none;
}
/* The group itself shows the focus ring instead, so icon + control light up
   together rather than a ring appearing inside a bordered box. */
.dir-filter-group:has(.ljs.is-open) { border-color: var(--color-accent); }
.dir-filter-group .ljs__menu {
  left: -12px;
  right: -12px;
}

/* ── Dark surfaces ──
   Some panels (portal wizard steps on dark, admin drawers) sit on a dark
   ground. Opt in with .ljs--dark on the wrapper. */
.ljs--dark .ljs__trigger {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.ljs--dark .ljs__menu {
  background: #14141a;
  border-color: rgba(255, 255, 255, 0.14);
}
.ljs--dark .ljs__opt { color: rgba(255, 255, 255, 0.86); }
.ljs--dark .ljs__opt.is-active { background: rgba(255, 255, 255, 0.09); }
.ljs--dark .ljs__opt[aria-selected="true"] { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .ljs__chev { transition: none; }
}
