/* Language picker with inline SVG flags.
 *
 * Shared by the application, the sign-in page and the admin panel, so it only
 * relies on the colour variables all three define.
 */
.flagpicker { position: relative; display: inline-block; }

.flagpicker-native {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flagpicker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-soft, var(--panel));
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.flagpicker-trigger:hover { border-color: var(--accent); }

.flagpicker-trigger:focus-visible,
.flagpicker-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flagpicker-caret { font-size: 10px; color: var(--muted); }

/* A fixed box keeps the three flags optically equal despite their different
   aspect ratios. */
.flagpicker-flag {
  display: inline-flex;
  width: 22px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}

.flagpicker-flag svg { width: 100%; height: 100%; display: block; }

/* The flag must never be the click target itself: it covers the middle of the
   button, and a shape inside it reports itself as the event target, which
   made the centre of the control feel dead. */
.flagpicker-flag, .flagpicker-flag * { pointer-events: none; }

.flagpicker-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  margin: 0;
  padding: 5px;
  min-width: 100%;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel, #0d2019);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
}

.flagpicker-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  min-height: 40px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.flagpicker-option:hover { background: rgba(183, 243, 75, .10); }

.flagpicker-option.is-selected { color: var(--accent); font-weight: 700; }

/* Inside a form the picker is a field like any other: full width, same height
   and the same rounding as the inputs above it. */
.gate-field .flagpicker { display: block; }

.gate-field .flagpicker-trigger {
  width: 100%;
  min-height: 48px;
  height: auto;
  padding: 0 14px;
  border-radius: 13px;
  justify-content: flex-start;
  gap: 10px;
  font-size: 15px;
  /* The header uses --bg-soft; inside the form the inputs use --panel, and
     the picker has to match its neighbours, not the header. */
  background: var(--panel);
}

.gate-field .flagpicker-caret { margin-left: auto; }

.gate-field .flagpicker-list { left: 0; right: 0; }

.gate-field .flagpicker-option { min-height: 46px; font-size: 15px; }

@media (max-width: 540px) {
  /* The form field always keeps its name; only the compact header picker
     drops it. */
  .gate-field .flagpicker-trigger .flagpicker-label { display: inline; }
}

@media (max-width: 540px) {
  .flagpicker-trigger { padding: 0 8px; gap: 6px; }
  /* The name is dropped on narrow screens; the flag carries the meaning and
     the full names stay visible in the open list. */
  .flagpicker-trigger .flagpicker-label { display: none; }
}
