/* ============================================================
   qn-menu.css
   QNシリーズ共通ハンバーガーメニュー（QN-PLAYER配布・fetchで読み込む）

   置き場所: https://qonny-game.github.io/QN-PLAYER/qn-menu.css
   各アプリはこのファイルをコピーせず、qn-menu.js が fetch して
   <style> タグとして注入する。更新はこのファイル1箇所で全アプリに反映される。

   前提: 各アプリの :root には既に --accent-primary 等のCSS変数が
   定義されている（QNAUDIOデザインシステム）。このメニューはテーマ切替時、
   その変数を body の inline style で上書きすることで見た目を変える。
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

/* ---------- Color themes ---------- */
/* テーマ名ごとの配色。qn-menu.js が data-theme 属性を body に付けて切り替える。
   各アプリ本体の :root 定義とは独立しており、テーマ選択時のみこちらが優先される。 */
/* テーマごとのCSSカスタムプロパティ(--accent-primary等)とスウォッチの
   背景グラデーション(.qn-swatch-*)は、qn-menu.js内のQN_THEMES配列から
   動的に生成され、<style id="qnThemeGeneratedCss">として注入される。
   このファイルには個別テーマの記述を持たせない（唯一のソースはJS側の配列）。
   rainbowだけは例外的に下の方に固定で残っている。 */

/* ---------- Hamburger button & popup container ---------- */
.qn-menu-wrapper {
  position: relative;
  display: inline-block;
}

#qnMenuBtn {
  background: #18181b;
  border: 1px solid #27272a;
  color: var(--text-bright);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 130ms cubic-bezier(0.2, 0, 0, 1), border-color 130ms cubic-bezier(0.2, 0, 0, 1), box-shadow 130ms cubic-bezier(0.2, 0, 0, 1);
}
#qnMenuBtn:hover,
#qnMenuBtn.active {
  background: #27272a;
  border-color: var(--accent-primary, #3b82f6);
  box-shadow: 0 0 12px var(--accent-glow, rgba(59, 130, 246, 0.35));
}
#qnMenuBtn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.qn-menu-popup {
  /* #appHeader等、ホスト側の祖先要素がposition:relativeでスタッキング
     コンテキストを作っているケースがあり、その場合absoluteだとこの
     z-index: 1000は祖先の外側では通用せず、サイドバー等（z-index: 400台）の
     下に潜ってしまうことがある。fixedにしてスタッキングコンテキストの
     階層そのものから切り離し、常に最前面に出るようにする。
     top/leftはJS側（positionPopup）でボタンの実際の画面座標から
     計算してインラインstyleで設定するため、ここでは初期値のみ持たせる。 */
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  /* カラーテーマ等コンテンツが増えて画面の高さを超える場合に備え、
     ビューポート基準で上限を設け、はみ出す分は内部スクロールにする。
     上下マージン分(16px×2)を差し引いた値をJS側のpositionPopupの
     margin(8px)の考え方に合わせて確保している。 */
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #121215;
  border: 1px solid #27272a;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 16px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
.qn-menu-popup.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
/* open-upward（上向きに開く時）は、top/leftの具体的なpx値をJS側で
   計算してインラインstyleに設定するため、ここでは開くアニメーションの
   初期transformだけを上向き用に変える。位置(top/left)の指定は持たない。 */
.qn-menu-popup.open-upward {
  transform: translateY(8px);
}
.qn-menu-popup.open-upward.open {
  transform: translateY(0);
}

/* 中身がmax-heightを超えた時の内部スクロールバー（Webkit系）。
   .sidebar-sectionの細いスクロールバーと同じデザインに揃える。 */
.qn-menu-popup::-webkit-scrollbar {
  width: 5px;
}
.qn-menu-popup::-webkit-scrollbar-track {
  background: transparent;
}
.qn-menu-popup::-webkit-scrollbar-thumb {
  background: var(--accent-primary, #3b82f6);
  border-radius: 3px;
  opacity: 0.6;
}

@media (max-width: 480px) {
  .qn-menu-popup {
    width: calc(100vw - 32px);
    max-width: 320px;
  }
}

/* ---------- Sections & nav links ---------- */
.qn-menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #27272a;
  padding-bottom: 14px;
}
.qn-menu-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.qn-menu-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #6b6b7b;
}

.qn-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #1c1c24;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-bright);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: background 130ms cubic-bezier(0.2, 0, 0, 1), border-color 130ms cubic-bezier(0.2, 0, 0, 1), color 130ms cubic-bezier(0.2, 0, 0, 1);
}
.qn-nav-btn:hover {
  background: #27272a;
  border-color: var(--accent-primary, #3b82f6);
  color: var(--accent-hover-1, #2563eb);
}
.qn-nav-btn.current {
  background: var(--accent-primary, #3b82f6);
  border-color: var(--accent-primary, #3b82f6);
  color: #ffffff;
  pointer-events: none;
}
.qn-nav-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ---------- Color swatches & glow switch ---------- */
.qn-theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qn-theme-swatch {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 130ms cubic-bezier(0.2, 0, 0, 1), border-color 130ms cubic-bezier(0.2, 0, 0, 1), box-shadow 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.qn-theme-swatch:hover {
  transform: scale(1.1);
  border-color: var(--text-pure-white);
}
.qn-theme-swatch.active {
  border: 2px solid #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
  transition: transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 130ms cubic-bezier(0.2, 0, 0, 1), box-shadow 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 各テーマのスウォッチ背景(.qn-swatch-*)もqn-menu.js内のQN_THEMES配列から
   動的に生成される。rainbowだけは例外でこのすぐ下に固定で残っている。 */

.qn-swatch-rainbow {
  background: conic-gradient(from 0deg, var(--danger), #f97316, #f59e0b, #84cc16, #10b981, #14b8a6, #06b6d4, #0ea5e9, #3b82f6, #6366f1, #8b5cf6, #a855f7, #ec4899, #f43f5e, var(--danger));
  animation: qn-rainbow-spin 4s linear infinite;
}
@keyframes qn-rainbow-spin {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

.qn-glow-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.qn-glow-toggle-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--icon-muted);
}

.qn-glow-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #2a2a35;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.qn-glow-switch[aria-checked="true"] {
  background: var(--accent-primary, #3b82f6);
  animation: qn-glow-switch-pulse 3s ease-in-out infinite;
}
@keyframes qn-glow-switch-pulse {
  0%, 100% { box-shadow: 0 0 4px var(--accent-glow, rgba(59, 130, 246, 0.35)); }
  50% { box-shadow: 0 0 12px var(--accent-glow, rgba(59, 130, 246, 0.35)); }
}
.qn-glow-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-bright);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.qn-glow-switch[aria-checked="true"] .qn-glow-switch-knob {
  transform: translateX(18px);
}

/* ---------- Keyboard shortcuts table (Section hidden entirely when the
   host app defines no window.QN_SHORTCUTS) ---------- */
.qn-shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.qn-shortcut-table th,
.qn-shortcut-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.qn-shortcut-table th {
  color: var(--icon-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 11px;
}
.qn-shortcut-table td {
  color: var(--text-bright);
}
.qn-shortcut-table kbd {
  background: #252530;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 11px;
  color: var(--accent-primary, #3b82f6);
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
