/* Memo site: the language picker and per-language type (CONTRACT §8). Same materials as site.css. */

/* Onest covers Latin and Cyrillic; Devanagari, Japanese and Korean fall back to system faces */
:root:lang(hi) { --font: "Onest", "Noto Sans Devanagari", "Nirmala UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
:root:lang(ja) { --font: "Onest", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans JP", "Noto Sans CJK JP", -apple-system, "Segoe UI", sans-serif; }
:root:lang(ko) { --font: "Onest", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", -apple-system, "Segoe UI", sans-serif; }
.lang-n:lang(hi) { font-family: "Onest", "Noto Sans Devanagari", "Nirmala UI", sans-serif; }
.lang-n:lang(ja) { font-family: "Onest", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", sans-serif; }
.lang-n:lang(ko) { font-family: "Onest", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif; }
/* The serif accent has no italic in these scripts: set it upright, and give the glyphs their own spacing */
:root:is(:lang(hi), :lang(ja), :lang(ko)) :is(.display, .h2, .h-page) em { font-style: normal; }
:root:is(:lang(hi), :lang(ja), :lang(ko)) :is(.display, .h2, .h-page) { letter-spacing: 0; }
:root:lang(ja) :is(h1, h2, h3) { word-break: auto-phrase; }
:root:lang(ko) :is(h1, h2, h3, p, li) { word-break: keep-all; }
/* Spain writes the currency after the amount: 19 US$/mes (the markup keeps the English order of the spans) */
:root:lang(es-ES) .price .cur { order: 1; }
:root:lang(es-ES) .price .per { order: 2; }

/* A redirect to the visitor's language is on its way */
html.lang-go { visibility: hidden; }
html.lang-open { overflow: hidden; }

/* ---------- Footer control ---------- */
.foot-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px 0 11px; margin: -4px 0;
  border: 0; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text-2); font-size: 13.5px; line-height: 1; cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.lang-btn:hover { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }
.lang-btn svg { flex: none; width: 16px; height: 16px; color: var(--text-3); }
.lang-btn:hover svg { color: var(--emerald); }

/* ---------- Picker ---------- */
.lang-dlg {
  width: min(760px, calc(100vw - 32px)); max-width: none; max-height: min(640px, calc(100dvh - 48px));
  padding: 0; border: 0; border-radius: 20px; overflow: hidden;
  background: var(--surface); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 48px 100px -30px #000;
}
.lang-dlg::backdrop { background: rgba(4, 6, 5, 0.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.lang-dlg[open] { animation: lang-in 0.24s var(--ease-out); }
.lang-dlg[open]::backdrop { animation: lang-fade 0.24s var(--ease-out); }
@keyframes lang-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes lang-fade { from { opacity: 0; } }
/* Leaving (lang.js adds .is-closing, then closes on animationend): faster than the way in, and no taps meanwhile */
.lang-dlg[open].is-closing { animation: lang-out 0.2s var(--ease-out) forwards; pointer-events: none; }
.lang-dlg[open].is-closing::backdrop { animation: lang-fade-out 0.2s var(--ease-out) forwards; }
@keyframes lang-out { to { opacity: 0; transform: translateY(6px) scale(0.985); } }
@keyframes lang-fade-out { to { opacity: 0; } }
.lang-box { display: flex; flex-direction: column; max-height: inherit; }
.lang-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 16px 10px 26px; }
.lang-h { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.lang-x {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--text-2); cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.lang-x:hover { color: var(--text); background: var(--surface-2); }
.lang-x svg { width: 20px; height: 20px; }
.lang-list {
  list-style: none; margin: 0; padding: 6px 16px 20px; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
}
.lang-opt {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 3px;
  min-height: 62px; padding: 10px 40px 10px 12px; border-radius: 12px;
  color: var(--text); text-decoration: none; transition: background-color 0.15s var(--ease);
}
.lang-opt:hover { background: var(--surface-2); }
.lang-opt[aria-current="true"] { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
.lang-opt:focus-visible { outline-offset: -2px; border-radius: 12px; }
.lang-n { font-size: 15px; font-weight: 500; line-height: 1.3; }
.lang-e { font-size: 13px; line-height: 1.3; color: var(--text-3); }
.lang-ck { position: absolute; top: 50%; right: 14px; width: 18px; height: 18px; margin-top: -9px; color: var(--emerald); visibility: hidden; }
.lang-opt[aria-current="true"] .lang-ck { visibility: visible; }

/* Phone: one column in a sheet from the bottom */
@media (max-width: 600px) {
  .lang-dlg { width: 100%; max-height: 90dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .lang-dlg[open] { animation-name: lang-up; }
  @keyframes lang-up { from { transform: translateY(24px); opacity: 0; } }
  .lang-dlg[open].is-closing { animation-name: lang-down; }
  @keyframes lang-down { to { transform: translateY(24px); opacity: 0; } }
  .lang-head { padding: 16px 12px 8px 22px; }
  .lang-list { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)); }
  .lang-opt { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) { .lang-dlg[open], .lang-dlg[open]::backdrop, .lang-dlg[open].is-closing { animation: none; } }
