/* The language button and its menu (lang.js, src/lang.ts): the site's header
   and footer, and a maker's page when they turn it on. Its colors come from
   the page it is on: the site's tokens, or a template's. */
.lang-menu, .lang-pop {
  --lm-bg: var(--bg-raised, var(--card-solid, var(--card, #fff)));
  --lm-text: var(--text, #1f1e1d);
  --lm-dim: var(--text-dim, var(--muted, #6f6c64));
  --lm-line: var(--line-strong, var(--line, rgba(0, 0, 0, .14)));
  --lm-hover: var(--bg-hover, var(--soft, rgba(0, 0, 0, .05)));
  --lm-accent: var(--accent, #ae4f2c);
  --lm-input: var(--bg-input, var(--bg, transparent));
}
.lang-menu { position: relative; display: inline-flex; }

/* A flag is a disc; a hairline in the text's color keeps a white one (Japan,
   Korea) from melting into a light page, and drawn as an outline it sits over
   the image, not under it. */
.lang-flag {
  width: 20px; height: 20px; flex: 0 0 20px; display: block; border-radius: 50%;
  outline: 1px solid color-mix(in srgb, var(--lm-text) 16%, transparent); outline-offset: -1px;
}

.lang-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; min-width: 36px; padding: 0 8px; margin: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--lm-dim);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.lang-btn:hover, .lang-btn[aria-expanded='true'] { background: var(--lm-hover); color: var(--lm-text); }
.lang-btn:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }
.lang-header .lang-btn { width: 36px; padding: 0; }
/* A narrow phone signed out has no room beside Log in and Get started: the
   footer's button stays. */
@media (max-width: 440px) { .nav:has(.nav-login) .lang-header { display: none; } }
.lang-chev { opacity: .7; transition: transform .2s; }
.lang-btn[aria-expanded='true'] .lang-chev { transform: rotate(180deg); }
.lang-footer .lang-btn { padding: 0 10px 0 8px; margin-left: -8px; }

/* A maker's page: a glass disc in the corner across from the badge. */
.lang-page { position: fixed; left: 16px; bottom: 16px; z-index: 20; }
.lang-page .lang-btn {
  width: 40px; height: 40px; padding: 0;
  background: color-mix(in srgb, var(--card, #fff) 86%, transparent); border: 1px solid var(--line, rgba(0, 0, 0, .12));
  box-shadow: var(--shadow, 0 4px 14px -6px rgba(0, 0, 0, .3));
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.lang-page .lang-btn:hover { background: color-mix(in srgb, var(--card, #fff) 96%, transparent); }
.lang-page .lang-flag { width: 22px; height: 22px; flex-basis: 22px; }

/* ---- the menu: on <body>, placed by lang.js beside its button ---- */
.lang-pop {
  position: fixed; z-index: 1010;
  width: 300px; max-height: min(460px, calc(100vh - 96px));
  display: flex; flex-direction: column;
  border: 1px solid var(--lm-line); border-radius: 14px;
  background: var(--lm-bg); color: var(--lm-text);
  box-shadow: var(--shadow-menu, 0 12px 28px rgba(0, 0, 0, .18));
  overflow: hidden; text-align: left;
  animation: lang-in .14s ease-out;
}
.lang-pop:focus { outline: none; }
@keyframes lang-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.lang-pop.up { animation-name: lang-in-up; }
@keyframes lang-in-up { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .lang-pop { animation: none; } }

.lang-search { position: relative; padding: 10px 10px 6px; }
.lang-search svg { position: absolute; left: 21px; top: 50%; margin-top: 2px; transform: translateY(-50%); color: var(--lm-dim); pointer-events: none; }
.lang-search input {
  width: 100%; height: 36px; padding: 0 10px 0 32px; box-sizing: border-box;
  border: 1px solid var(--lm-line); border-radius: 9px; background: var(--lm-input); color: var(--lm-text);
  font: inherit; font-size: 14px;
}
.lang-search input:focus { outline: none; border-color: var(--lm-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lm-accent) 18%, transparent); }
.lang-search input::-webkit-search-cancel-button { display: none; }

.lang-list { list-style: none; margin: 0; padding: 2px 6px 6px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; }
.lang-group { padding: 10px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lm-dim); }
.lang-row {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 8px;
  border-radius: 8px; color: var(--lm-text); text-decoration: none; font-size: 14px; line-height: 1.25;
}
.lang-row:hover, .lang-row:focus-visible { background: var(--lm-hover); text-decoration: none; outline: none; }
.lang-row[aria-current='true'] { font-weight: 650; }
.lang-native { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: isolate; }
.lang-en { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--lm-dim); font-size: 12.5px; text-align: right; }
.lang-check { flex: 0 0 16px; color: var(--lm-accent); }
.lang-empty { padding: 18px 10px; color: var(--lm-dim); font-size: 14px; text-align: center; }
.lang-note { margin: 0; padding: 8px 14px 10px; border-top: 1px solid var(--lm-line); color: var(--lm-dim); font-size: 12px; }

/* A phone: a sheet along the bottom edge, over a dimmed page, thumbs' reach. */
.lang-scrim { display: none; }
@media (max-width: 560px) {
  .lang-pop {
    left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom));
    width: auto; max-height: min(72vh, 560px); border-radius: 18px;
    animation-name: lang-sheet;
  }
  @keyframes lang-sheet { from { opacity: 0; transform: translateY(16px); } }
  .lang-scrim { display: block; position: fixed; inset: 0; z-index: 1005; background: rgba(0, 0, 0, .32); animation: lang-fade .14s ease-out; }
  @keyframes lang-fade { from { opacity: 0; } }
  /* 16px or iOS zooms the page when the field takes focus. */
  .lang-search input { height: 42px; font-size: 16px; }
  .lang-row { min-height: 46px; }
}
