.menu {
  justify-content: flex-start;
}

.menu .links {
  margin-left: auto;
}

.brand-switch {
  --thumb-shift: 0%;
  position: relative;
  z-index: 1;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  min-width: 124px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.56)),
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 58%);
  box-shadow:
    0 8px 16px rgba(11, 34, 28, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  overflow: hidden;
}

.brand-switch[data-brand="human"] {
  --thumb-shift: calc(100% + 2px);
}

.brand-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  bottom: 3px;
  width: calc(50% - 4px);
  border-radius: inherit;
  background: linear-gradient(155deg, color-mix(in srgb, var(--accent, #297066) 78%, white), var(--accent, #297066));
  box-shadow:
    0 8px 14px color-mix(in srgb, var(--accent, #297066) 28%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
  transform: translateX(var(--thumb-shift));
  transition: transform 340ms cubic-bezier(0.22, 0.9, 0.27, 1.05), background 280ms ease;
  will-change: transform;
}

.brand-option {
  position: relative;
  z-index: 2;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--text, #173b2a) 70%, white 30%);
  cursor: pointer;
  transition: color 210ms ease, transform 180ms ease;
}

.brand-option:hover {
  transform: translateY(-1px);
}

.brand-option.is-active {
  color: #ffffff;
}

.brand-option:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent, #297066) 55%, white);
  outline-offset: 1px;
}

.brand-switch.notranslate,
.brand-switch.notranslate * {
  unicode-bidi: isolate;
}

.brand-switch.is-switching {
  animation: switchPulse 450ms ease;
}

@keyframes switchPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

body.brand-switching .page {
  animation: pageSwitchOut 720ms cubic-bezier(0.2, 0.72, 0.24, 1) forwards;
}

body:not(.brand-switching) .page {
  opacity: 1;
  transform: none;
  filter: none;
}

.brand-transition-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform-origin: var(--switch-x, 50%) var(--switch-y, 50%);
  mix-blend-mode: screen;
}

body:not(.brand-switching) .brand-transition-layer {
  display: none !important;
}

.brand-transition-layer::before {
  content: "";
  position: absolute;
  inset: -46vmax;
  background:
    radial-gradient(circle at var(--switch-x, 50%) var(--switch-y, 50%), rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at calc(var(--switch-x, 50%) + 24vw) calc(var(--switch-y, 50%) + 20vh), var(--switch-end, rgba(39, 112, 102, 0.44)), rgba(39, 112, 102, 0) 52%),
    radial-gradient(circle at calc(var(--switch-x, 50%) - 20vw) calc(var(--switch-y, 50%) + 24vh), var(--switch-start, rgba(95, 186, 172, 0.42)), rgba(95, 186, 172, 0) 62%);
  filter: blur(62px) saturate(138%);
}

.brand-transition-layer::after {
  content: "";
  position: absolute;
  left: var(--switch-x, 50%);
  top: var(--switch-y, 50%);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.62);
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--switch-end, rgba(39, 112, 102, 0.4)) 55%, white),
    0 0 42px color-mix(in srgb, var(--switch-start, rgba(95, 186, 172, 0.4)) 64%, white);
  opacity: 0;
}

.brand-transition-layer.is-active {
  animation: switchCloud 980ms cubic-bezier(0.18, 0.76, 0.24, 1) forwards;
}

.brand-transition-layer.is-active::after {
  animation: switchHalo 980ms cubic-bezier(0.15, 0.74, 0.25, 1) forwards;
}

@keyframes switchCloud {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  42% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.92);
  }
}

@keyframes switchHalo {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.62);
  }
  30% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(62);
  }
}

@keyframes pageSwitchOut {
  to {
    opacity: 0.08;
    transform: translateY(-12px) scale(0.984);
    filter: blur(3.2px) saturate(120%);
  }
}

@media (max-width: 980px) {
  .menu {
    justify-content: flex-start;
  }

  .menu .links {
    margin-left: 0;
  }

  .brand-switch {
    min-width: 116px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-switch-thumb,
  .brand-option,
  .brand-switch,
  body.brand-switching .page,
  .brand-transition-layer.is-active,
  .brand-transition-layer.is-active::after {
    animation: none !important;
    transition: none !important;
  }
}
