/* ===========================================================================
   JPMate organization pages — 日本語 / English switch (js/lang-switch.js).
   A pill whose thumb slides as soon as it is pressed; the page cross-fades
   straight to the other language. Only the organization pages load this
   file, so only they opt in to cross-document view transitions.
   =========================================================================== */
.organization-page .org-language-switch {
  --to: 0%;
  --lang-ease: cubic-bezier(.22, .8, .24, 1);
  position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch;
  gap: 0; margin-left: auto; flex: none; padding: 3px;
  border: 1px solid var(--site-line); border-radius: 999px; background: var(--site-surface);
  font: 600 12px/1 var(--site-font); letter-spacing: .02em;
}
html[lang="en"] .organization-page .org-language-switch,
html[data-next="en"] .organization-page .org-language-switch { --to: 100%; }
html[data-next="ja"] .organization-page .org-language-switch { --to: 0%; }
.organization-page .org-language-switch .lang-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 999px; background: var(--site-accent);
  transform: translateX(var(--to));
  transition: transform .5s var(--lang-ease), background-color .3s var(--lang-ease);
}
.organization-page .org-language-switch a {
  position: relative; z-index: 1; display: block; padding: 7px 13px; text-align: center; white-space: nowrap;
  color: var(--site-muted); text-decoration: none; border-radius: 999px;
  transition: color .45s var(--lang-ease);
}
.organization-page .org-language-switch a:hover { color: var(--site-ink); }
.organization-page .org-language-switch a[aria-current],
html[data-next="ja"] .organization-page .org-language-switch a[lang="ja"],
html[data-next="en"] .organization-page .org-language-switch a[lang="en"] { color: var(--site-bg); text-decoration: none; }
html[data-next] .organization-page .org-language-switch a[aria-current] { color: var(--site-muted); }
.organization-page .org-language-switch a:focus-visible { outline-offset: 2px; }
/* The contact button beside the switch keeps one width in both languages
   (お問い合わせ: six full-width characters + padding), so the switch never
   moves when the language changes. */
.organization-page .nav .btn-cta { min-width: calc(6em + 32px); }

/* Browsers without cross-document view transitions (Firefox). Leaving: the
   page text fades and softens; the navigation stays put. */
html.lang-out .organization-page .lp > :not(.nav) {
  opacity: 0; filter: blur(4px); transform: translateY(6px);
  transition: opacity .2s cubic-bezier(.4, 0, 1, 1), filter .2s cubic-bezier(.4, 0, 1, 1), transform .2s cubic-bezier(.4, 0, 1, 1);
}
/* Arriving: the content waits, hidden, until its web fonts are ready (so the
   Japanese text never switches font in view), then fades in once. */
html.lang-wait .organization-page .lp > :not(.nav) { opacity: 0; }
@keyframes org-lang-in { from { opacity: 0; filter: blur(4px); transform: translateY(6px); } }
/* backwards, not both: once it ends nothing lingers (a held blur(0) or
   transform would make each section a compositing layer). */
html.lang-in .organization-page .lp > :not(.nav) { animation: org-lang-in .45s cubic-bezier(.22, .8, .24, 1) backwards; }

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
  /* The bar is part of the page's cross-fade (the same bar on both pages, so
     only its words change); the thumb finishes its slide on top, under its
     two labels (otherwise it hides the chosen one until the fade ends).
     Giving the bar its own transition layer lightened its see-through
     background for the first frame. */
  .organization-page .org-language-switch .lang-thumb { view-transition-name: org-lang-thumb; }
  .organization-page .org-language-switch a[lang="ja"] { view-transition-name: org-lang-ja; }
  .organization-page .org-language-switch a[lang="en"] { view-transition-name: org-lang-en; }
  ::view-transition-group(org-lang-thumb) { animation-duration: .4s; animation-timing-function: cubic-bezier(.22, .8, .24, 1); }
  /* The arriving page's fonts are still loading: the cross-fade waits at its
     first frame, so the old page stays on screen. lang-switch.js removes
     lang-hold once they have loaded (at most 1 s) and the cross-fade carries
     on from there. */
  html.lang-hold::view-transition-old(root), html.lang-hold::view-transition-new(root) { animation-play-state: paused; }
}
@media (prefers-reduced-motion: reduce) {
  .organization-page .org-language-switch .lang-thumb, .organization-page .org-language-switch a { transition: none; }
}
