/* The group language switcher, ported from Takada88 so the look is identical.
   Canonical source: sites/shared/language-switcher/. Takada88 keeps its own copy in
   css/hamille-retained.css; this is the shared one for Handa and Otemachi.
   Adding a language needs one .language-switcher__flag--<code> rule and its image. */

/* Retained language switcher */
.language-switcher {
  position: relative;
  display: flex;
  align-items: center;
  align-self: center;
  flex: 0 0 auto;
  margin-left: 6px;
  padding-left: 2px;
}

.language-switcher--mobile-inline {
  display: none;
}

.language-switcher::before {
  content: "";
  display: block;
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 24px;
  background: rgba(63, 58, 50, 0.16);
  transform: translateY(-50%);
}

.language-switcher__button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  width: 55px;
  min-width: 55px;
  height: 34px;
  padding: 0 2px;
  border: 1px solid rgba(79, 120, 207, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 9px 24px rgba(49, 95, 184, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  color: #285aa8;
  font-family: var(--font-sans);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
  appearance: none;
}

.language-switcher__button:hover,
.language-switcher.is-open .language-switcher__button {
  border-color: rgba(79, 120, 207, 0.42);
  box-shadow:
    0 12px 30px rgba(49, 95, 184, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  color: var(--main-color);
  opacity: 1;
}

.language-switcher__button:focus-visible {
  outline: 2px solid rgba(49, 95, 184, 0.22);
  outline-offset: 3px;
}

.language-switcher__current,
.language-switcher__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.language-switcher__current {
  gap: 2px;
}

.language-switcher__code {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
}

.language-switcher__chevron {
  color: rgba(63, 58, 50, 0.46);
  transition: transform 0.18s ease;
}

.language-switcher.is-open .language-switcher__chevron {
  transform: rotate(180deg);
}

.language-switcher__flag {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 14px;
  border-radius: 3px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  box-shadow:
    inset 0 0 0 1px rgba(63, 58, 50, 0.12),
    0 1px 2px rgba(20, 36, 70, 0.12);
}

.language-switcher__flag--jp {
  background-image: url("../img/common/flag-jp.jpg");
}

.language-switcher__flag--cn {
  background-image: url("../img/common/flag-cn.jpg");
}

.language-switcher__flag--us {
  background-image: url("../img/common/flag-us.jpg");
}

.language-switcher__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 300;
  min-width: 214px;
  padding: 8px;
  border: 1px solid rgba(79, 120, 207, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 18px 48px rgba(25, 45, 88, 0.18),
    0 2px 8px rgba(25, 45, 88, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity 0.16s ease,
    visibility 0.16s ease,
    transform 0.2s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.language-switcher.is-open .language-switcher__menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.language-switcher__menu-title {
  margin: 3px 9px 6px;
  color: rgba(63, 58, 50, 0.5);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.language-switcher .bogo-language-switcher {
  display: grid;
  position: static;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.language-switcher .bogo-language-switcher::before,
.language-switcher .bogo-language-switcher li:not(:last-of-type)::after {
  display: none;
}

.language-switcher .bogo-language-switcher li {
  display: block;
  width: 100%;
}

.language-switcher .bogo-language-switcher li > span {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  width: 100%;
  height: auto;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 11px;
  background: transparent !important;
  color: var(--text-color);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  transition:
    background 0.16s ease,
    color 0.16s ease;
}

.language-switcher .bogo-language-switcher li > span > a {
  display: flex;
  align-items: center;
  width: 100%;
  height: auto;
  background: transparent !important;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.language-switcher .bogo-language-switcher li > span::before {
  content: "";
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 14px;
  border-radius: 3px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  box-shadow:
    inset 0 0 0 1px rgba(63, 58, 50, 0.12),
    0 1px 2px rgba(20, 36, 70, 0.12);
}

.language-switcher .bogo-language-switcher li.ja > span::before {
  background-image: url("../img/common/flag-jp.jpg");
}

.language-switcher .bogo-language-switcher li.zh_CN > span::before,
.language-switcher .bogo-language-switcher li.zh-CN > span::before,
.language-switcher .bogo-language-switcher li.zh > span::before {
  background-image: url("../img/common/flag-cn.jpg");
}

.language-switcher .bogo-language-switcher li.en_US > span::before,
.language-switcher .bogo-language-switcher li.en-US > span::before,
.language-switcher .bogo-language-switcher li.en > span::before {
  background-image: url("../img/common/flag-us.jpg");
}

.language-switcher .bogo-language-switcher li.current > span,
.language-switcher .bogo-language-switcher li > span:hover,
.language-switcher__item:hover,
.language-switcher__item.is-current {
  background: #f1f5ff !important;
  color: #2558ad;
  opacity: 1;
}

.language-switcher .bogo-language-switcher li.current > span::after,
.language-switcher__item.is-current::after {
  content: "";
  display: block;
  flex: 0 0 auto;
  width: 7px;
  height: 12px;
  margin-left: auto;
  border-right: 2px solid var(--main-color);
  border-bottom: 2px solid var(--main-color);
  transform: rotate(45deg);
}

.language-switcher__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 11px;
  color: var(--text-color);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.language-switcher__item-text {
  display: grid;
  gap: 2px;
}

.language-switcher__item-name,
.language-switcher__item-note {
  display: block;
}

.language-switcher__item-note {
  color: rgba(63, 58, 50, 0.46);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.language-switcher__item:hover .language-switcher__item-note,
.language-switcher__item.is-current .language-switcher__item-note {
  color: rgba(37, 88, 173, 0.66);
}

/* Mobile header — docs/design/MOBILE-HEADER-STANDARD.md. The pill is placed from the menu button's
   own variables (--sp-menu-top / --sp-menu-size / --sp-menu-inset, each site's common.css), so it
   centres on the button and sits --sp-header-gap to its left at every width. This used to be
   top:53px / right:78px, which put it 32px below the button on handa; otemachi hid that with a
   local override handa never got. Fixing it HERE fixes both and removes the asymmetry. */
.header_inner > .language-switcher--mobile-inline {
    display: flex;
    align-items: center;
    position: absolute;
    top: var(--sp-menu-top);
    right: calc(var(--sp-menu-inset) + var(--sp-menu-size) + var(--sp-header-gap));
    height: var(--sp-menu-size);
    z-index: 2;
    margin: 0;
    padding: 0;
  }

.header_inner > .language-switcher--mobile-inline::before {
    display: none;
  }

.header_inner > .language-switcher--mobile-inline .language-switcher__button {
    height: 36px;
    padding-right: 2px;
    padding-left: 2px;
  }

.header_inner > .language-switcher--mobile-inline .language-switcher__menu {
    top: 45px;
    right: 0;
  }

.fat-nav_header .language-switcher {
    display: flex;
    align-items: center;
    position: absolute;
    top: var(--sp-menu-top);
    right: calc(var(--sp-menu-inset) + var(--sp-menu-size) + var(--sp-header-gap));
    height: var(--sp-menu-size);
    margin: 0;
    padding: 0;
  }

.fat-nav_header .language-switcher::before {
    display: none;
  }

.fat-nav_header {
    /* The pill's width, one number: the pill below and each site's logo cap (common.css) read it. */
    --sp-pill-w: 68px;
  }

.fat-nav_header .language-switcher__button {
    height: 36px;
    /* 68px with a fixed code slot, as on takada88 and TB. At 55px the flag and the chevron sat
       2-3.6px from the pill's rounded ends (check_mobile_header: pill inset >= 7). 20 flag + 1 +
       21 code + 1 + 10 chevron = 53, centred: 7.5px each side in every language. */
    width: var(--sp-pill-w);
    min-width: var(--sp-pill-w);
    padding-right: 2px;
    padding-left: 2px;
    gap: 1px;
  }

.fat-nav_header .language-switcher__current {
    gap: 1px;
  }

.fat-nav_header .language-switcher__code {
    display: inline-block;
    /* As wide as the widest code: Burmese "MM" is 20.9px in Safari (Hiragino, bold, 0.04em), 20.5
       in Chrome. At 19px it broke onto two lines and at 20 it ran out of the slot — both caught by
       the commit gate when Burmese came to otemachi (2026-09-25), which is why this is not 88's 20:
       88's face draws MM at 19.2. The two gaps (2px -> 1px) gave the 2px back, so the flag, the
       chevron and the centre of every other code sit exactly where they did at 19. */
    width: 21px;
    white-space: nowrap;
    text-align: center;
  }

.fat-nav_header .language-switcher__menu {
    top: 45px;
    right: 0;
  }

.language-switcher__menu {
    min-width: 204px;
  }
