/* Lazy Haven — language switcher. A flag dropdown living in the nav bar, on dark. */

.langswitch {
  position: relative;
  display: inline-flex;
}

/* Hidden flag sprite — referenced by <use>, takes no layout space. */
.langswitch__sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Trigger ---------------------------------------------------------------- */

.langswitch__current {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 40px;
  padding: 0.3em 0.6em;
  list-style: none;
  cursor: pointer;
  color: var(--c-text-on-dark);
  border-radius: 999px;
  background: var(--c-line-dark);
  -webkit-user-select: none;
  user-select: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.langswitch__current::-webkit-details-marker {
  display: none;
}

.langswitch__current:hover {
  background: color-mix(in srgb, var(--c-mist) 22%, transparent);
}

.langswitch__current:focus-visible {
  outline: 2px solid var(--c-thermal-bright);
  outline-offset: 2px;
}

/* Rounded flag chip ------------------------------------------------------ */

.langswitch__flag {
  flex: 0 0 auto;
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.langswitch__flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

.langswitch__code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
}

.langswitch__chevron {
  width: 0.7em;
  height: auto;
  opacity: 0.75;
  transition: transform var(--dur-fast) var(--ease-out);
}

.langswitch[open] .langswitch__chevron {
  transform: rotate(180deg);
}

/* Menu ------------------------------------------------------------------- */

.langswitch__menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  min-width: 12rem;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--c-blackwater);
  border: 1px solid var(--c-line-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-dark);
}

.langswitch__option {
  display: flex;
  align-items: center;
  gap: 0.65em;
  padding: 0.6em 0.7em;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--c-text-on-dark-dim);
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.langswitch__option:hover {
  background: var(--c-line-dark);
  color: var(--c-text-on-dark);
}

.langswitch__option.is-active {
  color: var(--c-text-on-dark);
  font-weight: 600;
}

.langswitch__option:focus-visible {
  outline: 2px solid var(--c-thermal-bright);
  outline-offset: -2px;
}

/* Subtle open animation (skipped under reduced motion). */
@media (prefers-reduced-motion: no-preference) {
  .langswitch[open] .langswitch__menu {
    animation: langswitch-in var(--dur-fast) var(--ease-out);
  }
  @keyframes langswitch-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .langswitch__current,
  .langswitch__option,
  .langswitch__chevron {
    transition: none;
  }
}
