/* ===== Language selector (css/lang-select.css, on every page) =====
   The site's quiet pill (the mode pills' colours) that opens a list of the
   12 languages. A <details>, so it works without JavaScript. */
.lang-select {
  position: relative;
  z-index: 40;
  flex: none;
  font-family: system-ui, sans-serif;
}

.lang-select-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 34px;
  padding: 0 0.85rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: #aaa;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: rgba(30, 30, 40, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.lang-select-button::-webkit-details-marker { display: none; }
.lang-select-button::marker { content: ''; }

/* A 44 px tap target round the 34 px pill */
.lang-select-button::after {
  content: '';
  position: absolute;
  inset: -5px -4px;
}

.lang-select-button:hover,
.lang-select[open] > .lang-select-button {
  color: #fff;
  border-color: rgba(0, 255, 127, 0.45);
}

.lang-select-button:focus-visible {
  outline: 2px solid #00FF7F;
  outline-offset: 3px;
}

.lang-select-code { display: none; }

.lang-select-chevron {
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease, margin 0.2s ease;
}

.lang-select[open] .lang-select-chevron {
  margin-top: 3px;
  transform: rotate(225deg);
}

.lang-select-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  min-width: 11rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 6rem);
  max-height: calc(100dvh - 6rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
  background: rgba(10, 16, 12, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.lang-select-list a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 0.8rem;
  border-radius: 9px;
  color: #ccc;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.lang-select-list a:hover {
  color: #fff;
  background: rgba(0, 255, 127, 0.08);
}

.lang-select-list a:focus-visible {
  outline: 2px solid #00FF7F;
  outline-offset: -2px;
}

.lang-select-list a[aria-current="page"] {
  color: #00FF7F;
  font-weight: 600;
}

/* In a nav: at the right, after the nav's own link. The nav sits above the
   header that follows it, so the open list covers the page, not the other
   way round. */
.wn-nav,
.top-nav {
  z-index: 50;
}

.wn-nav .nav-back,
.top-nav .nav-store-link {
  margin-left: auto;
}

.lang-select--nav { margin-left: 0.75rem; }

/* The home page has no nav: the hero's top right corner, where the other
   pages' navs end, outside the flow so nothing in the hero moves */
.lang-select--corner {
  position: absolute;
  top: 1.25rem;
  right: max(2rem, calc(50% - 400px + 2rem));
}

@media (max-width: 768px) {
  .lang-select--corner {
    top: 1rem;
    right: 1rem;
  }
}

/* Phones: the short code, and the list in two columns of 44 px rows */
@media (max-width: 640px) {
  .lang-select-name { display: none; }
  .lang-select-code { display: inline; }

  .lang-select-list {
    display: grid;
    grid-template-columns: repeat(2, auto);
    min-width: 0;
  }

  .lang-select-list a {
    min-height: 44px;
    font-size: 0.875rem;
  }
}

@media (pointer: coarse) {
  .lang-select-list a { min-height: 44px; }
}

/* Play page phones: the store link takes a row of its own under the logo
   and the selector */
@media (max-width: 520px) {
  .top-nav {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    row-gap: 0.75rem;
  }

  .top-nav .nav-brand { grid-area: 1 / 1; }
  .top-nav .lang-select { grid-area: 1 / 3; margin-left: 0; }

  .top-nav .nav-store-link {
    grid-area: 2 / 1 / 3 / 4;
    justify-self: center;
    margin-left: 0;
  }
}

@media (max-width: 359px) {
  .lang-select-list a { padding: 0 0.6rem; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lang-select-button,
  .lang-select-chevron { transition: none; }
}
