/* Visual polish for the language switcher and the custom <select> menus.
   Loaded after nps-extra.css so it layers on top of the base styles. */

/* ---- Solid, high-contrast menus (they used to be see-through and blended
   into the page background) ---- */
:root {
  --menu-bg: #25103f;
  --menu-bg-hover: #3a1c63;
  --menu-bg-active: #4b2680;
  --menu-border: rgba(216, 180, 254, 0.55);
  --menu-shadow: 0 22px 60px rgba(5, 0, 18, 0.75), 0 0 0 1px rgba(5, 0, 18, 0.6);
  --btn-bg: #2b1450;
}

[data-theme="light"] {
  --menu-bg: #ffffff;
  --menu-bg-hover: #f1e4ff;
  --menu-bg-active: #e4ccff;
  --menu-border: rgba(126, 34, 206, 0.45);
  --menu-shadow: 0 22px 54px rgba(60, 20, 100, 0.28), 0 0 0 1px rgba(126, 34, 206, 0.12);
  --btn-bg: #ffffff;
}

.lang-switcher-menu,
.custom-select-menu {
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  box-shadow: var(--menu-shadow);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.lang-switcher-btn,
.custom-select-btn {
  background: var(--btn-bg);
}

.lang-switcher-option:hover,
.custom-select-option:hover {
  background: var(--menu-bg-hover);
}

.lang-switcher-option.is-active,
.custom-select-option.is-active {
  background: var(--menu-bg-active);
}

/* Inside the sticky header the menu must sit above everything else */
.site-header {
  z-index: 50;
}

@keyframes dd-pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lang-switcher-menu.is-open {
  transform-origin: top right;
  animation: dd-pop 150ms ease-out;
}

.custom-select-menu.is-open {
  transform-origin: top center;
  animation: dd-pop 150ms ease-out;
}

/* Long lists scroll instead of running off the screen */
.lang-switcher-menu {
  max-height: min(60vh, 380px);
  min-width: min(190px, calc(100vw - 32px));
  overflow-y: auto;
}

.lang-switcher-menu,
.custom-select-menu {
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

/* Chevron on the language button; both chevrons flip while open */
.lang-switcher-btn::after {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.custom-select-btn::after {
  transition:
    transform 180ms ease,
    margin 180ms ease;
}

.lang-switcher-btn[aria-expanded="true"]::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.custom-select-btn[aria-expanded="true"]::after {
  transform: rotate(-135deg);
  margin-top: 4px;
}

/* Open state: highlighted border + soft ring */
.lang-switcher-btn,
.custom-select-btn {
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.lang-switcher-btn[aria-expanded="true"],
.custom-select-btn[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);
}

/* Options: smoother hover, clear keyboard focus, checkmark on the selected row */
.lang-switcher-option,
.custom-select-option {
  position: relative;
  padding-right: 34px;
  transition: background 120ms ease;
}

.lang-switcher-option:focus-visible,
.custom-select-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--menu-bg-hover);
}

.lang-switcher-option[aria-selected="true"]::after,
.custom-select-option[aria-selected="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 5px;
  height: 10px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-65%) rotate(45deg);
}

@media (prefers-reduced-motion: reduce) {
  .lang-switcher-menu.is-open,
  .custom-select-menu.is-open {
    animation: none;
  }

  .lang-switcher-btn::after,
  .custom-select-btn::after {
    transition: none;
  }
}
