/* --------------------------------------------------------------- language */
/* A deliberate, quiet control: the field stays the subject, but the switch is
   easy to find on the title, the inoculation console and in the player menu. */

.language-slot {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.language-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(170, 246, 255, 0.2);
  border-radius: 999px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0) 48%),
    rgba(4, 16, 22, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(226, 253, 255, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px) saturate(1.16);
  -webkit-backdrop-filter: blur(10px) saturate(1.16);
  color: rgba(198, 241, 249, 0.76);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.language-control:hover,
.language-control:focus-within {
  border-color: rgba(184, 249, 255, 0.42);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 48%),
    rgba(7, 27, 35, 0.66);
  color: #e8fdff;
}

.language-globe {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  pointer-events: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
}

.language-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 32px;
  padding: 8px 27px 8px 31px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 8px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
}

.language-select:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(157, 241, 255, 0.56);
}

.language-select option {
  background: #06151b;
  color: #e5fbff;
  font-size: 12px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.language-chevron {
  position: absolute;
  right: 11px;
  width: 5px;
  height: 5px;
  margin-top: -2px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  pointer-events: none;
  opacity: 0.68;
}

/* The title has the sound control in the top-right; the language switch holds
   the matching top-left corner and disappears with the title stage. */
.language-slot-intro {
  position: absolute;
  z-index: 6;
  top: clamp(16px, 2.8vw, 28px);
  left: clamp(16px, 3vw, 32px);
}

.language-slot-intro .language-control {
  min-height: 38px;
}

.language-slot-intro .language-select {
  min-height: 36px;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 8.5px;
}

/* In the inoculation console the language switch sits with the key legend,
   outside the actual choices, so it never competes with Sporulate. */
.start-actions-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

#overlay .start-actions-left .keys {
  max-width: none;
  min-width: 0;
}

.language-slot-picker .language-control {
  min-height: 30px;
  background: rgba(4, 16, 22, 0.34);
}

.language-slot-picker .language-select {
  min-height: 28px;
  padding: 7px 24px 7px 28px;
  font-size: 7.5px;
}

.language-slot-picker .language-globe {
  left: 9px;
  width: 13px;
  height: 13px;
}

.language-slot-picker .language-chevron {
  right: 9px;
}

/* Player menu: a normal setting row, aligned with the other controls. */
.player-menu-language {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.player-menu-language .language-control {
  min-width: 178px;
  width: 100%;
  border-color: rgba(127, 232, 255, 0.16);
  background: rgba(2, 8, 11, 0.5);
  box-shadow: inset 0 1px 0 rgba(226, 253, 255, 0.06);
}

.player-menu-language .language-select {
  min-height: 30px;
  font-size: 8px;
}

.player-menu-language .language-select:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(127, 232, 255, 0.56);
}

html[lang='ja'] .language-select,
html[lang='zh-CN'] .language-select {
  letter-spacing: 0.02em;
  text-transform: none;
}

@media (max-width: 640px) {
  .language-slot-intro {
    top: 12px;
    left: 12px;
  }

  .language-slot-intro .language-control {
    min-height: 34px;
  }

  .language-slot-intro .language-select {
    min-height: 32px;
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 8px;
  }

  .start-actions-left {
    width: 100%;
    justify-content: center;
  }

  .language-slot-picker {
    justify-content: center;
  }

  .player-menu-language {
    width: 100%;
  }

  .player-menu-language .language-control {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .language-control {
    transition: none;
  }
}


/* CJK glyphs fall back to a webfont when the client has no Chinese/Japanese face. */
html:lang(ja) body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans JP", "Hiragino Sans", "Yu Gothic", monospace;
}

html:lang(zh) body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", monospace;
}
