/* ============================================================
   indexf.php 専用スタイル
   PC（621px以上）のページ内メニューを、ウィンドウ右側の
   「インデックス」開閉メニューに変更する。

   ・index.php および既存CSS（base/layout/entry/header）には
     一切変更を加えない追加ファイル。
   ・desk-index.js が <html> に .has-desk-index を付与した
     ときだけ有効になるため、JS無効時は従来の横並びナビの
     まま表示される（フォールバック）。
   ・スマホ（620px以下）は従来どおり .mobile-index-menu を使う。

   ボタンの配置（開閉どちらでも同じ位置に見えるようにしている）
     上18px  … 閉：☰ インデックス  ／ 開：× インデックス
     上68px  … 閉・開とも ✉ お申し込みはこちら
   ============================================================ */

/* 各ボタンは既定で非表示。PC幅（621px以上）かつJS有効時のみ表示する。
   スマホ表示では従来の .mobile-index-menu を使うため、
   これらが混ざらないようにする。 */
.desk-index-toggle,
.desk-index-cta,
.desk-index-head,
.desk-index-entry {
  display: none;
}

@media (min-width: 621px) {

  /* ------------------------------------------------------------
     ボタン共通のチップ形状
     閉じているとき（☰ / ✉）と開いているとき（× / ✉）で
     位置・大きさがずれないよう、同じ寸法を共有する。
     ------------------------------------------------------------ */
  html.has-desk-index .desk-index-toggle,
  html.has-desk-index .desk-index-close,
  html.has-desk-index .desk-index-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* いちばん長い「お申し込みはこちら」に合わせた寸法。
         アイコン14 + 間隔8 + 文字9字×(14px + letter-spacing.04em)131
         + 左右padding32 + border2 ≒ 187px → 余裕をみて 192px */
    width: 192px;
    min-height: 42px;
    padding: 8px 16px;
    color: #fff;
    background: var(--teal, #061a2d);
    border: 1px solid rgb(255 255 255 / .34);
    border-radius: 4px;
    box-shadow: 0 10px 26px rgb(0 0 0 / .26);
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .04em;
    white-space: nowrap;
    cursor: pointer;
  }

  html.has-desk-index .desk-index-toggle:focus-visible,
  html.has-desk-index .desk-index-close:focus-visible,
  html.has-desk-index .desk-index-cta:focus-visible {
    outline: 2px solid var(--turquoise, #c8a04a);
    outline-offset: 2px;
  }

  /* アイコン幅を揃えて、どのボタンでも文字の開始位置を同じにする */
  html.has-desk-index .desk-index-toggle-icon,
  html.has-desk-index .desk-index-close-icon,
  html.has-desk-index .desk-index-cta b {
    width: 14px;
    font-weight: inherit;
    text-align: center;
  }

  html.has-desk-index .desk-index-toggle-icon { font-size: 15px; }
  html.has-desk-index .desk-index-close-icon { font-size: 18px; }
  html.has-desk-index .desk-index-cta b { font-size: 15px; }

  /* ---------- 開閉ボタン（紺）のホバー ---------- */
  html.has-desk-index .desk-index-toggle:hover,
  html.has-desk-index .desk-index-close:hover {
    background: #0b2b47;
    border-color: var(--turquoise, #c8a04a);
  }

  /* 閉じているときの申し込みボタンは、テーマ曲と同じ赤 */
  html.has-desk-index .desk-index-cta {
    background: var(--red, #7e1824);
  }

  html.has-desk-index .desk-index-cta:hover {
    background: #99202f;
    border-color: var(--turquoise, #c8a04a);
  }

  /* ------------------------------------------------------------
     閉じているときに右上へ固定する2つのボタン
     ページ最上部から常に表示する（スクロール連動なし）。
       上端18px ＋ ボタン高さ42px ＋ 間隔8px = 68px
     ------------------------------------------------------------ */
  html.has-desk-index .desk-index-toggle,
  html.has-desk-index .desk-index-cta {
    position: fixed;
    z-index: 130;
    right: 18px;
    transition: opacity .2s ease, background-color .18s ease,
                border-color .18s ease, visibility 0s linear 0s;
  }

  html.has-desk-index .desk-index-toggle { top: 18px; }
  html.has-desk-index .desk-index-cta { top: 68px; }

  /* 開いているあいだは、同じ位置にヘッダー帯の2つが来るので隠す */
  html.has-desk-index.desk-index-open .desk-index-toggle,
  html.has-desk-index.desk-index-open .desk-index-cta {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition-delay: 0s, 0s, 0s, .2s;
  }

  /* ------------------------------------------------------------
     メニュー本体（右からのドロワー）
     閉じているあいだは display:none。
     page.js が .page-index-flyer の高さを測って追従ボタンの
     表示タイミングを決めているため、visibility:hidden ではなく
     display:none にして高さ0を保つ。

     幅はボタン192px + ヘッダー帯の左右余白36px = 228px が収まる寸法。
       232px − 左右padding32 − 番号26 − 間隔12 = 文字部 162px
     ------------------------------------------------------------ */
  html.has-desk-index .page-index.page-index-flyer {
    position: fixed;
    z-index: 125;
    top: 0;
    right: 0;
    display: none;
    flex-direction: column;
    width: min(232px, 86vw);
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 0 18px;
    background: rgb(255 253 247 / .98);
    border-bottom: 0;
    border-left: 1px solid #e4e7e1;
    box-shadow: -18px 0 44px rgb(11 70 85 / .18);
    backdrop-filter: blur(10px);
  }

  html.has-desk-index.desk-index-open .page-index.page-index-flyer {
    display: flex;
    animation: desk-index-in .24s ease both;
  }

  @keyframes desk-index-in {
    from { opacity: 0; transform: translateX(22px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  /* ------------------------------------------------------------
     メニュー上部のヘッダー帯（閉じるボタン＋申し込みの行）
     上・右の余白を固定ボタンと同じ 18px にすることで、
     開閉してもインデックスボタンが同じ位置に見える。
     sticky で貼り付くので、下までスクロールしても
     申し込みの行は出たままになる。
     ------------------------------------------------------------ */
  html.has-desk-index .page-index.page-index-flyer .desk-index-head {
    position: sticky;
    z-index: 2;
    top: 0;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    padding: 18px 18px 0;
    background: rgb(255 253 247 / .98);
    border-bottom: 1px solid #e4e7e1;
    backdrop-filter: blur(10px);
  }

  /* ------------------------------------------------------------
     開いているときの「お申し込みはこちら」
     ボタンではなくメニュー項目と同じ書式にする。
     アイコン・文字ともテーマ曲と同じ赤。
     ヘッダー帯の左右余白を打ち消して、他の項目と同じ幅に合わせる。
     ------------------------------------------------------------ */
  html.has-desk-index .page-index.page-index-flyer .desk-index-entry {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: calc(100% + 36px);
    margin: 14px -18px 0;
    padding: 13px 16px;
    color: var(--red, #7e1824);
    background: none;
    border: 0;
    border-top: 1px solid #ebe6dc;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
  }

  html.has-desk-index .page-index.page-index-flyer .desk-index-entry:hover,
  html.has-desk-index .page-index.page-index-flyer .desk-index-entry:focus-visible {
    background: #f6ece9;
    outline: none;
  }

  html.has-desk-index .page-index.page-index-flyer .desk-index-entry b {
    flex: 0 0 26px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    background: var(--red, #7e1824);
    font-size: 13px;
  }

  /* ---------- メニュー項目（縦並び） ---------- */
  html.has-desk-index .page-index.page-index-flyer a {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    padding: 13px 16px;
    border-bottom: 1px solid #ebe6dc;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
    text-align: left;
  }

  html.has-desk-index .page-index.page-index-flyer a:last-child {
    border-bottom: 0;
  }

  /* 横並び時の区切り線は不要 */
  html.has-desk-index .page-index.page-index-flyer a + a::before {
    display: none;
  }

  html.has-desk-index .page-index.page-index-flyer a:hover,
  html.has-desk-index .page-index.page-index-flyer a:focus-visible {
    color: var(--teal, #061a2d);
    background: #f4efe4;
    outline: none;
  }

  html.has-desk-index .page-index.page-index-flyer a b {
    flex: 0 0 26px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    background: var(--teal, #061a2d);
    font-size: 11px;
  }

  /* テーマ曲の音符アイコンは従来どおり赤のまま残す */
  html.has-desk-index .page-index.page-index-flyer .page-index-theme b {
    color: #fff;
    background: var(--red, #7e1824);
  }

  /* ---------- 固定ナビが無くなった分のオフセット調整 ---------- */
  html.has-desk-index .mobile-flyer-gallery [id] {
    scroll-margin-top: 16px;
  }

  html.has-desk-index main section[id] {
    scroll-margin-top: 16px;
  }
}


/* ============================================================
   スマホ（620px以下）：黒い帯のインデックスをＰＣと同じ内容にする
   （desk-index.js の末尾の処理で作る要素の見た目）
   ============================================================ */
@media (max-width: 620px) {
  /* 帯の「✉ お申し込み」ボタン（インデックスの左） */
  .mobile-index-menu .mobile-entry-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 5px 10px;
    color: #fff;
    background: var(--red, #7e1824);
    border: 1px solid #d3a844;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
  }
  .mobile-index-menu .mobile-entry-cta b {
    width: 14px;
    font-size: 14px;
    font-weight: inherit;
    text-align: center;
  }

  /* 一覧の幅：長い項目（テーマ曲など）に引っぱられて画面いっぱいに広がらないよう、
     幅を抑えて、長い項目は折り返す */
  .mobile-index-menu .mobile-index-panel {
    width: min(270px, calc(100vw - 72px)) !important;
    max-width: none !important;
    padding: 0 0 env(safe-area-inset-bottom, 0px) !important;
    /* スマホのブラウザでは 100vh がアドレスバーの裏まで含むため、一覧の下が画面外に隠れる。
       実際に見えている高さ（dvh）で上限を決め、最後の項目まで スクロールできるようにする。 */
    max-height: calc(100vh - 120px) !important;
    max-height: calc(100dvh - 56px) !important;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-index-panel .mobile-index-entry,
  .mobile-index-panel a {
    padding: 11px 12px !important;
    white-space: normal !important;
    line-height: 1.35 !important;
  }
  .mobile-index-panel a span,
  .mobile-index-panel .mobile-index-entry span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* 一覧：番号付き（ＰＣのメニューと同じ並び） */
  .mobile-index-panel .mobile-index-entry,
  .mobile-index-panel a {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    font-size: 15px !important;
  }
  .mobile-index-panel .mobile-index-entry {
    margin: 0;
    padding: 14px 12px;
    color: #fff;
    background: var(--red, #7e1824);
    border: 0;
    border-bottom: 1px solid #343434;
    font-family: var(--serif);
    font-weight: 900;
    line-height: 1.35;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
  }
  .mobile-index-panel a b,
  .mobile-index-panel .mobile-index-entry b {
    flex: 0 0 26px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #111;
    background: #f1cc71;
    font-family: sans-serif;
    font-size: 11px;
    font-weight: 800;
  }
  .mobile-index-panel .mobile-index-entry b {
    color: var(--red, #7e1824);
    background: #fff;
    font-size: 13px;
  }
  .mobile-index-panel a.mobile-index-theme b {
    color: #fff;
    background: var(--red, #7e1824);
  }
}
