/* Language picker. Uses the theme tokens from the skill:
   --surface --inset --border --text --text-muted --accent --ring --dur-fast --dur-base --ease-out */

/* The row's button */
.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px 8px 14px;
  font: inherit;
  font-weight: 550;
  color: var(--text);
  background: var(--inset);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.lang-trigger:hover { border-color: var(--border); }
.lang-trigger:active { transform: scale(0.98); }
.lang-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.lang-trigger[aria-expanded="true"] { border-color: var(--accent); }
.lang-chevron {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--text-muted);
  transition: transform var(--dur-base) var(--ease-out);
}
.lang-trigger[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }

/* Click-catcher behind the popup. Invisible on desktop, dimmed on phones. */
.lang-backdrop { position: fixed; inset: 0; z-index: var(--z-popover, 250); background: transparent; }
.lang-backdrop.is-sheet {
  background: rgb(8 8 12 / 0.38);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
.lang-backdrop.is-sheet.is-open { opacity: 1; }

/* The dropdown window */
.lang-pop {
  position: fixed;
  z-index: calc(var(--z-popover, 250) + 1);
  display: flex;
  flex-direction: column;
  width: min(300px, calc(100vw - 24px));
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.08), 0 24px 48px -16px rgb(0 0 0 / 0.35);
  opacity: 0;
  transform: translateY(-6px) scale(0.96);
  pointer-events: none;
  transition: opacity 160ms var(--ease-out), transform 240ms var(--ease-out);
}
.lang-pop.is-up { transform: translateY(6px) scale(0.96); }
.lang-pop.is-open { opacity: 1; transform: none; pointer-events: auto; }

/* Phones: bottom sheet */
.lang-pop.is-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: min(72dvh, 560px);
  padding-bottom: var(--safe-bottom, env(safe-area-inset-bottom));
  padding-inline: var(--safe-left, 0px) var(--safe-right, 0px);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  opacity: 1;
  transform: translateY(100%);
  transition: transform 360ms var(--ease-out);
}
.lang-pop.is-sheet.is-open { transform: none; }
.lang-pop.is-sheet::before {
  content: "";
  flex: none;
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text-muted) 40%, transparent);
}

/* Search */
.lang-search { flex: none; padding: 10px 10px 4px; }
.lang-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--inset);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.lang-search input::placeholder { color: var(--text-muted); }
.lang-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }

/* List */
.lang-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
}
.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.lang-item.is-active { background: var(--inset); }
.lang-item:active { transform: scale(0.985); }
.lang-item.is-enter {
  animation: lang-item-in 260ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 22ms + 40ms);
}
@keyframes lang-item-in { from { opacity: 0; transform: translateY(6px); } }

.lang-text { display: grid; min-width: 0; }
.lang-primary { font-weight: 600; }
.lang-secondary { font-size: 12.5px; color: var(--text-muted); }

.lang-check {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.lang-check svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}
.lang-item[aria-selected="true"] .lang-check { opacity: 1; transform: none; }
.lang-item[aria-selected="true"] .lang-check svg { animation: lang-check-draw 360ms var(--ease-out) 80ms forwards; }
@keyframes lang-check-draw { to { stroke-dashoffset: 0; } }

.lang-empty { padding: 20px 12px; text-align: center; color: var(--text-muted); }

/* Soft crossfade while the language changes (View Transitions API) */
.lang-switching::view-transition-old(root),
.lang-switching::view-transition-new(root) {
  animation-duration: 240ms;
  animation-timing-function: var(--ease-out);
}
