/* Million Solutions 3.0 — 共通ハンバーガーメニュー
 * ダーク（ホーム・ストリーム）とライト（カタログ・法務）の2テーマ。
 * 各ページは .ms-menu-toggle に data-menu-theme="dark|light" を指定する。
 * 固定配置が必要なページは .ms-menu-toggle--fixed を追加する。
 */

.ms-menu-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ms-line, rgba(181, 213, 244, 0.22));
  border-radius: 12px;
  background: var(--ms-toggle-bg, rgba(8, 17, 27, 0.56));
  color: var(--ms-ink, #f7f9fc);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(14px);
  flex: 0 0 auto;
}

.ms-menu-toggle:hover,
.ms-menu-toggle:focus-visible {
  border-color: var(--ms-accent, #5be7ff);
  box-shadow: 0 0 0 3px var(--ms-glow, rgba(91, 231, 255, 0.18)), 0 12px 30px var(--ms-shadow, rgba(0, 0, 0, 0.4));
  outline: none;
}

.ms-menu-toggle:active {
  transform: scale(0.96);
}

.ms-menu-toggle--fixed {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 80;
}

.ms-menu-burger {
  position: relative;
  display: block;
  width: 22px;
  height: 16px;
}

.ms-menu-burger span {
  position: absolute;
  left: 0;
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease, top 0.28s ease;
}

.ms-menu-burger span:nth-child(1) { top: 0; }
.ms-menu-burger span:nth-child(2) { top: 7px; }
.ms-menu-burger span:nth-child(3) { top: 14px; }

.ms-menu-toggle[aria-expanded="true"] .ms-menu-burger span:nth-child(1) {
  top: 7px;
  transform: rotate(45deg);
}
.ms-menu-toggle[aria-expanded="true"] .ms-menu-burger span:nth-child(2) {
  opacity: 0;
}
.ms-menu-toggle[aria-expanded="true"] .ms-menu-burger span:nth-child(3) {
  top: 7px;
  transform: rotate(-45deg);
}

.ms-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--ms-backdrop, rgba(0, 0, 0, 0.55));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.ms-menu-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ms-menu-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: min(380px, 92vw);
  padding: 20px 0 24px;
  background: var(--ms-panel-bg, rgba(6, 13, 22, 0.92));
  border-left: 1px solid var(--ms-panel-border, rgba(91, 231, 255, 0.28));
  box-shadow: -32px 0 80px var(--ms-panel-shadow, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(28px);
  transform: translateX(105%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0.2, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ms-menu-panel.is-open {
  transform: translateX(0);
}

.ms-menu-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--ms-accent, #5be7ff), var(--ms-accent-2, #ffd166));
  opacity: 0.85;
}

.ms-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 22px 18px;
  border-bottom: 1px solid var(--ms-divider, rgba(181, 213, 244, 0.16));
}

.ms-menu-head-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ms-menu-head-mark {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--ms-accent, #5be7ff), var(--ms-accent-2, #ffd166));
  box-shadow: 0 0 16px var(--ms-glow, rgba(91, 231, 255, 0.3));
}

.ms-menu-head-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--ms-ink, #f7f9fc);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-menu-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--ms-line, rgba(181, 213, 244, 0.22));
  border-radius: 10px;
  background: transparent;
  color: var(--ms-ink, #f7f9fc);
  cursor: pointer;
  transition: border-color 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.ms-menu-close:hover {
  border-color: var(--ms-accent, #5be7ff);
  color: var(--ms-accent, #5be7ff);
  transform: rotate(90deg);
}

.ms-menu-close svg {
  width: 18px;
  height: 18px;
}

.ms-menu-body {
  padding: 16px 14px 8px;
  flex: 1 1 auto;
}

.ms-menu-group {
  margin-bottom: 6px;
}

.ms-menu-group-label {
  display: block;
  padding: 14px 12px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-faint, #718094);
}

.ms-menu-link {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--ms-ink, #f7f9fc);
  text-decoration: none;
  transition: background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.ms-menu-link + .ms-menu-link {
  margin-top: 2px;
}

.ms-menu-link:hover,
.ms-menu-link:focus-visible {
  background: var(--ms-link-hover, rgba(91, 231, 255, 0.08));
  box-shadow: inset 3px 0 0 var(--ms-accent, #5be7ff);
  outline: none;
}

.ms-menu-link:active {
  transform: scale(0.99);
}

.ms-menu-link.is-active {
  background: var(--ms-link-active, rgba(91, 231, 255, 0.14));
  box-shadow: inset 3px 0 0 var(--ms-accent-2, #ffd166);
}

.ms-menu-link.is-active .ms-menu-link-label {
  color: var(--ms-accent-2, #ffd166);
}

.ms-menu-link-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ms-icon-bg, rgba(91, 231, 255, 0.12));
  color: var(--ms-accent, #5be7ff);
  flex-shrink: 0;
}

.ms-menu-link:hover .ms-menu-link-icon {
  background: var(--ms-icon-bg-hover, rgba(91, 231, 255, 0.22));
  box-shadow: 0 0 14px var(--ms-glow, rgba(91, 231, 255, 0.28));
}

.ms-menu-link-icon svg {
  width: 20px;
  height: 20px;
}

.ms-menu-link-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ms-menu-link-label {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--ms-ink, #f7f9fc);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-menu-link-desc {
  font-size: 12px;
  line-height: 1.35;
  color: var(--ms-faint, #718094);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-menu-foot {
  padding: 14px 22px 4px;
  margin-top: auto;
  border-top: 1px solid var(--ms-divider, rgba(181, 213, 244, 0.16));
  font-size: 11px;
  color: var(--ms-faint, #718094);
  line-height: 1.6;
}

.ms-menu-foot strong {
  color: var(--ms-ink, #f7f9fc);
  font-weight: 800;
}

/* スタガー表示（開いたとき項目が順に出る） */
.ms-menu-panel.is-open .ms-menu-link {
  animation: ms-menu-in 0.34s ease backwards;
}
.ms-menu-panel.is-open .ms-menu-group:nth-child(1) .ms-menu-link:nth-child(2) { animation-delay: 0.06s; }
.ms-menu-panel.is-open .ms-menu-group:nth-child(2) .ms-menu-link:nth-child(2) { animation-delay: 0.1s; }
.ms-menu-panel.is-open .ms-menu-group:nth-child(2) .ms-menu-link:nth-child(3) { animation-delay: 0.14s; }
.ms-menu-panel.is-open .ms-menu-group:nth-child(3) .ms-menu-link:nth-child(2) { animation-delay: 0.18s; }
.ms-menu-panel.is-open .ms-menu-group:nth-child(3) .ms-menu-link:nth-child(3) { animation-delay: 0.22s; }
.ms-menu-panel.is-open .ms-menu-group:nth-child(3) .ms-menu-link:nth-child(4) { animation-delay: 0.26s; }

@keyframes ms-menu-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ms-menu-toggle,
  .ms-menu-backdrop,
  .ms-menu-panel,
  .ms-menu-link,
  .ms-menu-close,
  .ms-menu-burger span {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== ダークテーマ（ホーム・ストリーム） ===== */
.ms-menu-toggle[data-menu-theme="dark"],
.ms-menu-toggle[data-menu-theme="dark"] ~ .ms-menu-backdrop .ms-menu-panel,
[data-menu-theme="dark"].ms-menu-toggle {
  --ms-ink: #f7f9fc;
  --ms-faint: #7e8da0;
  --ms-line: rgba(181, 213, 244, 0.22);
  --ms-accent: #5be7ff;
  --ms-accent-2: #ffd166;
  --ms-glow: rgba(91, 231, 255, 0.28);
  --ms-shadow: rgba(0, 0, 0, 0.5);
  --ms-toggle-bg: rgba(8, 17, 27, 0.6);
  --ms-backdrop: rgba(0, 0, 0, 0.6);
  --ms-panel-bg: rgba(6, 13, 22, 0.94);
  --ms-panel-border: rgba(91, 231, 255, 0.3);
  --ms-panel-shadow: rgba(0, 0, 0, 0.6);
  --ms-divider: rgba(181, 213, 244, 0.16);
  --ms-link-hover: rgba(91, 231, 255, 0.1);
  --ms-link-active: rgba(91, 231, 255, 0.16);
  --ms-icon-bg: rgba(91, 231, 255, 0.14);
  --ms-icon-bg-hover: rgba(91, 231, 255, 0.26);
}

/* ===== ライトテーマ（カタログ・法務） ===== */
.ms-menu-toggle[data-menu-theme="light"] {
  --ms-ink: #0c111d;
  --ms-faint: #667085;
  --ms-line: #d9e0ea;
  --ms-accent: #008c8c;
  --ms-accent-2: #b98500;
  --ms-glow: rgba(0, 140, 140, 0.22);
  --ms-shadow: rgba(15, 23, 42, 0.14);
  --ms-toggle-bg: rgba(255, 255, 255, 0.92);
  --ms-backdrop: rgba(15, 23, 42, 0.4);
  --ms-panel-bg: rgba(255, 255, 255, 0.96);
  --ms-panel-border: rgba(0, 140, 140, 0.32);
  --ms-panel-shadow: rgba(15, 23, 42, 0.22);
  --ms-divider: #e9eef5;
  --ms-link-hover: rgba(0, 140, 140, 0.08);
  --ms-link-active: rgba(0, 140, 140, 0.12);
  --ms-icon-bg: rgba(0, 140, 140, 0.12);
  --ms-icon-bg-hover: rgba(0, 140, 140, 0.2);
}

.ms-menu-panel[data-menu-theme="dark"] {
  --ms-ink: #f7f9fc;
  --ms-faint: #7e8da0;
  --ms-line: rgba(181, 213, 244, 0.22);
  --ms-accent: #5be7ff;
  --ms-accent-2: #ffd166;
  --ms-glow: rgba(91, 231, 255, 0.28);
  --ms-divider: rgba(181, 213, 244, 0.16);
  --ms-link-hover: rgba(91, 231, 255, 0.1);
  --ms-link-active: rgba(91, 231, 255, 0.16);
  --ms-icon-bg: rgba(91, 231, 255, 0.14);
  --ms-icon-bg-hover: rgba(91, 231, 255, 0.26);
}

.ms-menu-panel[data-menu-theme="light"] {
  --ms-ink: #0c111d;
  --ms-faint: #667085;
  --ms-line: #d9e0ea;
  --ms-accent: #008c8c;
  --ms-accent-2: #b98500;
  --ms-glow: rgba(0, 140, 140, 0.22);
  --ms-divider: #e9eef5;
  --ms-link-hover: rgba(0, 140, 140, 0.08);
  --ms-link-active: rgba(0, 140, 140, 0.12);
  --ms-icon-bg: rgba(0, 140, 140, 0.12);
  --ms-icon-bg-hover: rgba(0, 140, 140, 0.2);
}

@media (max-width: 640px) {
  .ms-menu-toggle {
    width: 44px;
    height: 44px;
  }
  .ms-menu-panel {
    width: 92vw;
  }
  .ms-menu-link {
    padding: 13px 12px;
  }
}
