/* Figma language trigger and dropdown: 8858:26630 / 8858:27755. */
.furpsy-language {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  height: var(--language-height);
  --language-arrow: url("../../icons/language-arrow-small.svg");
  --language-arrow-active: url("../../icons/language-arrow-small-active.svg");
  --language-arrow-disabled: url("../../icons/language-arrow-small-disabled.svg");
  --language-icon-size: 16px;
  --language-code-width: 13px;
  --language-height: var(--furpsy-type-body-medium-s-line-height);
}

.furpsy-language--large {
  --language-arrow: url("../../icons/language-arrow-large.svg");
  --language-arrow-active: url("../../icons/language-arrow-large-active.svg");
  --language-arrow-disabled: url("../../icons/language-arrow-large-disabled.svg");
  --language-icon-size: 20px;
  --language-code-width: 17px;
  --language-height: var(--furpsy-type-body-medium-l-line-height);
}

.furpsy-language__trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
  height: var(--language-height);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--furpsy-color-grey-100);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.3s ease;
}

.furpsy-language__code {
  min-width: var(--language-code-width);
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: from-font;
  text-underline-position: from-font;
  transition: text-decoration-color 0.3s ease;
}

.furpsy-language__arrow {
  position: relative;
  display: block;
  flex: 0 0 var(--language-icon-size);
  width: var(--language-icon-size);
  height: var(--language-icon-size);
}

.furpsy-language__arrow::before,
.furpsy-language__arrow::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  mask: var(--language-arrow) center / var(--language-icon-size) var(--language-icon-size) no-repeat;
  transition: opacity 0.3s ease;
}

.furpsy-language__arrow::after {
  mask-image: var(--language-arrow-active);
  opacity: 0;
}

.furpsy-language__trigger:hover:not(:disabled) .furpsy-language__code,
.furpsy-language__trigger[aria-expanded="true"] .furpsy-language__code {
  text-decoration-color: currentColor;
}

.furpsy-language__trigger[aria-expanded="true"] {
  color: var(--furpsy-color-opacity-primary-100);
}

.furpsy-language__trigger[aria-expanded="true"] .furpsy-language__arrow::before {
  opacity: 0;
}

.furpsy-language__trigger[aria-expanded="true"] .furpsy-language__arrow::after {
  opacity: 1;
}

.furpsy-language__trigger::after {
  content: '';
  position: absolute;
  inset: -4px -8px;
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: 30px;
  pointer-events: none;
  transition: border-color 0.3s ease;
}

.furpsy-language__trigger:focus-visible {
  outline: none;
}

.furpsy-language__trigger:focus-visible::after {
  border-color: var(--furpsy-color-primary-30);
}

.furpsy-language__trigger:disabled {
  color: var(--furpsy-color-grey-50);
  cursor: default;
}

.furpsy-language__trigger:disabled .furpsy-language__code {
  text-decoration-color: transparent;
}

.furpsy-language__trigger:disabled .furpsy-language__arrow::before {
  mask-image: var(--language-arrow-disabled);
}

.furpsy-language__options {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 221px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
  background: var(--furpsy-color-opacity-white-100);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 10px 50px rgba(22, 22, 22, 0.16);
  z-index: 1001;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.furpsy-language:has(> .furpsy-language__trigger[aria-expanded="true"]) > .furpsy-language__options {
  opacity: 1;
  transform: translateY(0);
  transition-duration: 200ms;
}

.furpsy-language__options[hidden] {
  display: none;
}

.furpsy-language__options[inert] {
  pointer-events: none;
}

.furpsy-language__options li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.furpsy-language__options a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 40px;
  text-decoration: none;
  color: var(--furpsy-color-grey-60);
  transition: color 160ms ease, background-color 160ms ease;
}

.furpsy-language__options a:hover,
.furpsy-language__options a:focus-visible,
.furpsy-language__options a[aria-current] {
  color: var(--furpsy-color-grey-100);
  background: var(--furpsy-color-primary-10);
}

.furpsy-language__options a:focus-visible {
  outline: 2px solid var(--furpsy-color-primary-30);
  outline-offset: -2px;
}

.furpsy-language__flag {
  position: relative;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
}

.furpsy-language__flag img {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 24px;
  height: 24px;
  max-width: none;
}

/* A single Small control serves both existing desktop and mobile promo layouts. */
.promo-bar > .furpsy-language {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.mobile-choose-language .furpsy-language {
  position: static;
}

/* Open upward in the existing mobile menu so the list stays inside the viewport. */
.mobile-choose-language .furpsy-language__options {
  top: auto;
  bottom: calc(100% + 4px);
  right: 0;
  left: auto;
  box-shadow: 0 -10px 50px rgba(22, 22, 22, 0.16);
  transform: translateY(4px);
}

@media (prefers-reduced-motion: reduce) {
  .furpsy-language__trigger,
  .furpsy-language__code,
  .furpsy-language__arrow,
  .furpsy-language__arrow::before,
  .furpsy-language__arrow::after,
  .furpsy-language__trigger::after,
  .furpsy-language__options,
  .furpsy-language:has(> .furpsy-language__trigger[aria-expanded="true"]) > .furpsy-language__options,
  .furpsy-language__options a {
    transition: none;
  }
}
