/* Musiveo Translate - switcher + toast. Dark-mode aware via Musiveo vars with fallbacks. */
.mt-switcher { font-family: inherit; }
.mt-dropdown { position: relative; display: inline-block; max-width: 100%; }
.mt-dropdown__btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 0; max-width: 100%; overflow: hidden;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--mt-bg, #111318); color: var(--mt-fg, #fff);
  border: 1px solid var(--mt-border, rgba(255,255,255,.14));
  font-size: 13.5px; font-weight: 600; line-height: 1;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.mt-dropdown__btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.mt-dropdown__btn .mt-chev { opacity: .7; flex: none; }
.mt-dropdown__btn .mt-code { flex: none; }
/* Truncate the language name when the column is narrow (sidebar). */
.mt-dropdown__btn [data-mt-current-label] {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mt-menu {
  position: absolute; z-index: 9999; top: calc(100% + 8px); right: 0; min-width: 230px;
  max-width: calc(100vw - 32px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--mt-menu-bg, #1a1d24); color: var(--mt-menu-fg, #fff);
  border: 1px solid var(--mt-border, rgba(255,255,255,.12)); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.4); max-height: 320px; overflow: auto;
}
.mt-menu[hidden] { display: none; }
/* Auto-flip variants set by JS when the menu would leave the viewport. */
.mt-menu.is-left { left: 0; right: auto; }
.mt-menu.is-up { top: auto; bottom: calc(100% + 8px); }
/* Floating variant for the collapsed icon rail (which clips overflow). */
.mt-menu.is-fixed { position: fixed; z-index: 10001; }
/* Narrow contexts (sidebar / widgets): never exceed the column. */
#aside .mt-dropdown, .sidebar .mt-dropdown, .widget .mt-dropdown { max-width: 100%; }
#aside .mt-menu, .sidebar .mt-menu, .widget .mt-menu { min-width: 0; width: max-content; }
.mt-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border: 0; background: transparent; color: inherit;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; text-align: left;
}
.mt-menu button:hover, .mt-menu button.is-active { background: rgba(255,255,255,.08); }
.mt-menu button small { opacity: .55; font-weight: 400; margin-left: auto; }
.mt-code {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px;
  background: rgba(255,255,255,.1); font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.mt-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--mt-border, rgba(255,255,255,.14));
  background: transparent; color: inherit; cursor: pointer; font-size: 13px; font-weight: 600;
}
.mt-pill.is-active { background: var(--mt-accent, #6c5ce7); border-color: transparent; color: #fff; }
.mt-pill__code { font-size: 11px; opacity: .7; font-weight: 800; }
.mt-compact { position: relative; display: inline-block; }
.mt-compact__btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer;
  background: var(--mt-bg, #111318); color: var(--mt-fg, #fff);
  border: 1px solid var(--mt-border, rgba(255,255,255,.14)); font-weight: 800; font-size: 12px;
}
.mt-compact .mt-menu { right: 0; left: auto; min-width: 190px; }
.mt-globe { flex: none; }
.mt-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: #111318; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 10000; opacity: 0;
  transition: opacity .3s ease, transform .3s ease; box-shadow: 0 12px 34px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12); pointer-events: none; max-width: 90vw;
}
.mt-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Japanese / CJK typography guard: keep headings readable after translation. */
body.mt-lang-ja, body.mt-lang-cjk { overflow-wrap: break-word; }
body.mt-lang-ja h1, body.mt-lang-ja h2, body.mt-lang-ja h3,
body.mt-lang-cjk h1, body.mt-lang-cjk h2, body.mt-lang-cjk h3 {
  line-break: strict; word-break: normal; letter-spacing: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", system-ui, sans-serif;
}
html[data-mt-lang="ar"] body { direction: rtl; }

@media (prefers-color-scheme: light) {
  .mt-dropdown__btn { --mt-bg: #f1f2f6; --mt-fg: #14161b; --mt-border: rgba(0,0,0,.1); }
  .mt-menu { --mt-menu-bg: #fff; --mt-menu-fg: #14161b; }
  .mt-menu button:hover, .mt-menu button.is-active { background: rgba(0,0,0,.06); }
  .mt-code { background: rgba(0,0,0,.07); }
}

/* Collapsed sidebar icon rail: behave like .nav menu items (theme.css
 * #menu-state:checked rules). Label hidden, icon centered, tooltip on hover.
 * Same breakpoint the theme uses for the folded rail. The .is-rail class is
 * toggled by JS (syncRail) so it works regardless of DOM placement; the
 * #menu-state selectors remain as a pure-CSS fallback. */
@media (min-width: 782px) {
  /* The theme hides these wrappers when collapsed; keep them for the switcher. */
  #menu-state:checked ~ .site-sidebar .site-sidebar-header:has([data-mt-switcher]),
  #menu-state:checked ~ .site-sidebar .site-sidebar-footer:has([data-mt-switcher]),
  #menu-state:checked ~ .site-sidebar .site-sidebar-header.has-mt-rail,
  #menu-state:checked ~ .site-sidebar .site-sidebar-footer.has-mt-rail {
    display: block;
    padding: 0.5rem 0;
  }
  #menu-state:checked ~ .site-sidebar .site-sidebar-header:has([data-mt-switcher]) > :not(:has([data-mt-switcher])),
  #menu-state:checked ~ .site-sidebar .site-sidebar-footer:has([data-mt-switcher]) > :not(:has([data-mt-switcher])) {
    display: none;
  }
  #menu-state:checked ~ .site-sidebar [data-mt-switcher],
  [data-mt-switcher].is-rail {
    display: flex;
    justify-content: center;
    position: relative;
  }
  #menu-state:checked ~ .site-sidebar [data-mt-switcher] .mt-dropdown,
  [data-mt-switcher].is-rail .mt-dropdown {
    display: flex;
    justify-content: center;
  }
  #menu-state:checked ~ .site-sidebar [data-mt-switcher] .mt-dropdown__btn,
  [data-mt-switcher].is-rail .mt-dropdown__btn {
    justify-content: center;
    padding: 0.375rem 0;
    min-width: 44px;
  }
  #menu-state:checked ~ .site-sidebar [data-mt-switcher] [data-mt-current-label],
  #menu-state:checked ~ .site-sidebar [data-mt-switcher] .mt-chev,
  #menu-state:checked ~ .site-sidebar [data-mt-switcher] .mt-pill__name,
  [data-mt-switcher].is-rail [data-mt-current-label],
  [data-mt-switcher].is-rail .mt-chev,
  [data-mt-switcher].is-rail .mt-pill__name {
    display: none;
  }
  /* Hover tooltip, same look as the collapsed .nav item tooltip. */
  #menu-state:checked ~ .site-sidebar [data-mt-switcher]:hover [data-mt-current-label],
  [data-mt-switcher].is-rail:hover [data-mt-current-label] {
    display: block;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, 0);
    background-color: var(--color-grey-400, #333);
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
    line-height: 1;
    padding: 4px 6px 5px 6px;
    margin: 0 0 6px 0;
    white-space: nowrap;
    z-index: 10002;
  }
}
