/* 言語切替ドロップダウン ＋ 他言語版の案内バナー（stak_task 38）
 *
 * 対象: 営業7ページの ja / en / zh 版だけが読み込む。記事ページ（site.css / post.css）とは無関係。
 * 生成: migration/scripts/82_i18n_build.py と 83_i18n_patch_ja.py が <head> に <link> を挿入する。
 *
 * 設計の要点
 *   - <details>/<summary> を使うので開閉に JS が要らない（外側クリックで閉じる分だけ JS を使う）。
 *   - タップ領域は最低 40px 角。旧版は高さ 20px しかなく「押しにくい」と実際に指摘を受けた。
 *   - 置き場所は <nav> 直下。.nav-links はモバイルで position:fixed のドロワーに変わるため、
 *     その中に入れるとハンバーガーを開くまで言語切替に辿り着けない。
 */

.lang-switch {
  position: relative;
  display: inline-block;
  margin-left: 12px;
  vertical-align: middle;
}

/* ボタンは枠も背景も持たない。ナビの他項目と同じ「ただのテキスト」に見せる。
 * 枠付きの白い箱にすると、丸ピルの Contact ボタンや枠なしのナビ項目と形が揃わず浮く。
 * タップ領域は padding で 40px を確保する。 */
.lang-switch > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .15s ease;
}

.lang-switch > summary::-webkit-details-marker { display: none; }
.lang-switch > summary::marker { content: ""; }

.lang-switch > summary:hover { background: rgba(0, 0, 0, .06); }
.lang-switch[open] > summary { background: rgba(0, 0, 0, .06); }
.lang-switch > summary:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }

.lang-switch .ls-globe { width: 16px; height: 16px; flex: none; color: #55554f; }

.lang-switch .ls-caret {
  width: 13px;
  height: 13px;
  flex: none;
  color: #8a8a85;
  transition: transform .18s ease;
}
.lang-switch[open] > summary .ls-caret { transform: rotate(180deg); }

.lang-switch .ls-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 168px;
  padding: 5px;
  margin: 0;
  list-style: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .06);
}

.lang-switch .ls-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  color: #3a3a36;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.lang-switch .ls-menu a:hover { background: #f2f2f0; color: #111; }

.lang-switch .ls-menu a[aria-current="true"] {
  background: #f2f2f0;
  color: #111;
  font-weight: 500;
}

.lang-switch .ls-check { width: 15px; height: 15px; flex: none; opacity: 0; }
.lang-switch .ls-menu a[aria-current="true"] .ls-check { opacity: 1; }

/* 狭い画面ではボタンを地球儀アイコンだけにする（40×40 のタップ領域は維持） */
@media (max-width: 900px) {
  .lang-switch { margin-left: 4px; }
  .lang-switch > summary { padding: 0; width: 40px; justify-content: center; gap: 0; }
  .lang-switch > summary .ls-cur,
  .lang-switch > summary .ls-caret { display: none; }
  .lang-switch .ls-globe { width: 20px; height: 20px; }

  /* ⚠️ ここが画面外にはみ出していた。
   * モバイルではボタンがロゴのすぐ右（画面の左寄り）に来るため、right:0 で右揃えすると
   * メニューが画面の左端から飛び出して「日本語」の1文字目が切れる。
   * 左揃えに変え、さらに画面幅を超えないよう上限を付ける。 */
  .lang-switch .ls-menu {
    right: auto;
    left: 0;
    max-width: calc(100vw - 24px);
  }
}

/* ── 他言語版の案内バナー ───────────────────────────
 * ブラウザの言語設定を見て「英語版があります」と知らせるだけ。自動リダイレクトはしない。
 * Googlebot は言語情報を送らずに米国からクロールするため、自動転送すると
 * 日本語版がインデックスから落ちる恐れがある。
 */
.lang-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 9px 16px;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.lang-hint.is-on { display: flex; }
.lang-hint a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.lang-hint button {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  opacity: .65;
}
.lang-hint button:hover { opacity: 1; background: rgba(255, 255, 255, .12); }

@media (max-width: 640px) {
  .lang-hint { gap: 8px; padding: 8px 10px; font-size: 12px; }
}

@media print { .lang-switch, .lang-hint { display: none; } }
