/*
 * KV左下の「セクション」メニュー。
 * 設計の参考: Material 3 の FAB メニュー(ボタンが×に変形し、項目がボタンの位置から順に展開する)、
 * 展開は起点(ボタン)から広がる transform-origin、約200〜300msの短い動き、
 * Apple の Liquid Glass 系の「すりガラス + 細い明るい縁 + 内側のハイライト」。
 * ボタン本体の見た目は、テーマ共通のボタン定義(style.css)を使う。
 */

/* 画面の左下に固定して、スクロールしても付いてくる。KVの中にいるときも同じ位置(右下の切り替えボタンと高さが揃う) */
.xs-aqw-menu {
  bottom: max(clamp(12px, 2vw, 24px), env(safe-area-inset-bottom));
  left: max(clamp(12px, 2vw, 24px), env(safe-area-inset-left));
  margin: 0 !important;
  position: fixed;
  z-index: 90;
}

.xs-aqw-menu[hidden] {
  display: none;
}

.xs-aqw-menu .xs-aqw-menu__trigger {
  /* テーマの共通ボタン定義と同じ値。テーマのCSSが古いままキャッシュされていても崩れないよう、基本をここにも持つ */
  align-items: center;
  background: var(--xs-color-accent-strong, #115e59);
  border: 1px solid var(--xs-color-accent-strong, #115e59);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(2, 18, 28, 0.3);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  gap: 0.6rem;
  justify-content: center;
  line-height: 1.4;
  margin: 0;
  padding: 0.45rem 1rem 0.45rem 0.85rem;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.xs-aqw-menu .xs-aqw-menu__trigger:hover,
.xs-aqw-menu .xs-aqw-menu__trigger:focus-visible {
  background: var(--xs-color-accent, #0f766e);
  border-color: var(--xs-color-accent, #0f766e);
  transform: translateY(-1px);
}

.xs-aqw-menu .xs-aqw-menu__trigger:active {
  transform: translateY(0);
}

/* ≡ が × に変形するアイコン */
.xs-aqw-menu__icon {
  background: currentColor;
  border-radius: 2px;
  display: block;
  height: 2px;
  position: relative;
  transition: background-color 120ms ease;
  width: 16px;
}

.xs-aqw-menu__icon::before,
.xs-aqw-menu__icon::after {
  background: currentColor;
  border-radius: 2px;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  top: 0;
  transition: transform 260ms cubic-bezier(0.34, 1.4, 0.64, 1);
  width: 100%;
}

.xs-aqw-menu__icon::before {
  transform: translateY(-5px);
}

.xs-aqw-menu__icon::after {
  transform: translateY(5px);
}

.xs-aqw-menu.is-open .xs-aqw-menu__icon {
  background: transparent;
}

.xs-aqw-menu.is-open .xs-aqw-menu__icon::before {
  transform: rotate(45deg);
}

.xs-aqw-menu.is-open .xs-aqw-menu__icon::after {
  transform: rotate(-45deg);
}

/* 項目の入れ物。ボタンの真上に、左下を起点にして開く */
.xs-aqw-menu__panel {
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  background: rgba(6, 32, 46, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  bottom: calc(100% + 10px);
  box-shadow: 0 18px 48px rgba(2, 18, 28, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  left: 0;
  max-width: min(320px, calc(100vw - 24px));
  min-width: 264px;
  opacity: 0;
  padding: 6px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  transform: translateY(10px) scale(0.94);
  transform-origin: left bottom;
  transition: transform 160ms ease-in, opacity 140ms ease, visibility 0s linear 160ms;
  visibility: hidden;
}

.xs-aqw-menu.is-open .xs-aqw-menu__panel {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition: transform 320ms cubic-bezier(0.34, 1.4, 0.64, 1), opacity 160ms ease, visibility 0s;
  visibility: visible;
}

.xs-aqw-menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.xs-aqw-menu__list > li {
  margin: 0;
  opacity: 0;
  padding: 0;
  transform: translateY(8px);
  transition: opacity 120ms ease;
}

.xs-aqw-menu__list > li + li {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* ボタンに近い項目から順に現れる */
.xs-aqw-menu.is-open .xs-aqw-menu__list > li {
  opacity: 1;
  transform: none;
  transition: opacity 200ms ease, transform 320ms cubic-bezier(0.34, 1.4, 0.64, 1);
  transition-delay: calc(var(--xs-aqw-delay, 0) * 45ms + 50ms);
}

.xs-aqw-menu__list a {
  align-items: center;
  border-radius: 12px;
  color: #fff;
  display: flex;
  font-size: 0.92rem;
  font-weight: 600;
  gap: 0.8rem;
  line-height: 1.35;
  padding: 0.7rem 0.9rem;
  position: relative;
  text-decoration: none;
  transition: background-color 140ms ease;
}

.xs-aqw-menu__list a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.xs-aqw-menu__list a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.xs-aqw-menu__no {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.xs-aqw-menu__label {
  flex: 1;
}

/* 今いるセクション */
.xs-aqw-menu__list a::after {
  background: #8fe9ff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(143, 233, 255, 0.8);
  content: "";
  height: 7px;
  transform: scale(0);
  transition: transform 220ms cubic-bezier(0.34, 1.6, 0.64, 1);
  width: 7px;
}

.xs-aqw-menu__list a[aria-current="location"]::after {
  transform: scale(1);
}

.xs-aqw-menu__list a[aria-current="location"] .xs-aqw-menu__no {
  opacity: 1;
}

/* すりガラスが使えない/透明を減らす設定のときは、濃い単色にして文字を読みやすく保つ */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .xs-aqw-menu__panel {
    background: rgba(6, 32, 46, 0.96);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .xs-aqw-menu__panel {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: #0a2a3b;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xs-aqw-menu__panel,
  .xs-aqw-menu.is-open .xs-aqw-menu__panel,
  .xs-aqw-menu__list > li,
  .xs-aqw-menu.is-open .xs-aqw-menu__list > li {
    transform: none;
    transition-delay: 0s;
    transition-duration: 120ms;
  }

  .xs-aqw-menu__icon::before,
  .xs-aqw-menu__icon::after,
  .xs-aqw-menu__list a::after {
    transition: none;
  }
}
