/* popup_viewer.css (copied from koda/popup, used by photo-pop.html) */
:root {
  --pv-overlay: rgba(0, 0, 0, .62);
  --pv-panel: rgba(18, 18, 20, .72);
  --pv-border: rgba(255, 255, 255, .18);
  --pv-text: rgba(255, 255, 255, .92);
  --pv-muted: rgba(255, 255, 255, .65);
  --pv-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  --pv-radius: 18px;
  --pv-blur: 16px;
  --pv-gap: 12px;
  /* コントローラ（下部ボタン群）を二回り小さめに */
  --pv-control-h: 36px;
  /* 右上の閉じるボタン（サブタイトルと重ならないよう小さめに） */
  --pv-close-size: 34px;
  --pv-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

.pv-overlay {
  position: fixed;
  inset: 0;
  background: var(--pv-overlay);
  display: none;
  z-index: 9999;
  /* iOSの長押しメニュー等を抑制（完全ではないが抑止効果あり） */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pv-overlay.pv-open {
  display: block;
}

.pv-panel {
  /* position: absolute; */
  width: 80vw;
  height: 80vh; /* ビューポート高さ基準に変更 */
  max-width: calc(100vw - 160px); /*calc(100vw - 32px);*/
  max-height: calc(100vh - 160px); /*calc(100vh - 32px);*/
  box-sizing: border-box;
  background: var(--pv-panel);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-radius);
  /*box-shadow: var(--pv-shadow);*/
  backdrop-filter: blur(var(--pv-blur));
  -webkit-backdrop-filter: blur(var(--pv-blur));
  overflow: hidden;
  transform: translateZ(0);
}

.pv-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 400px; /* 最小高さを確保 */
  min-width: 300px;  /* 最小幅を確保（親の幅が0になるのを防ぐ） */
  max-width: 100%;
  font-family: var(--pv-font);
  color: var(--pv-text);
}

/* モーダル内での楽譜表示: 親要素にサイズを確保 */
.koda_score_main {
  position: relative;
  width: 100%;
  min-width: 300px;
  min-height: 400px;
}

/* 楽譜ポップアップ内の wrapper に幅を確保（歌詞ポップアップと同じ書式のため最小限のみ） */
.modal-score1-popup .wrapper_popup_common,
.modal-score2-popup .wrapper_popup_common,
.modal-score3-popup .wrapper_popup_common,
[class*="modal-score"] .wrapper_popup_common,
.modal-score1-popup .koda_paragraph_lyrics,
.modal-score2-popup .koda_paragraph_lyrics,
.modal-score3-popup .koda_paragraph_lyrics,
[class*="modal-score"] .koda_paragraph_lyrics {
  width: 100%;
  min-width: 300px;
}

/* 楽譜ポップアップ: 表示時に中央配置（display: flex は showWithFade で設定）
   overscroll-behavior: contain — iOS Safari でモーダル内のタッチ操作が
   親ページのオーバースクロール（pull-to-refresh 等）に伝播するのを防止 */
.modal-score1-popup,
.modal-score2-popup,
.modal-score3-popup,
[class*="modal-score"] {
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: auto;
}

/* 楽譜ポップアップ: 縦方向を90vhまで伸ばし、拡大画像を縦に多く表示できるようにする
   ※ 90vh を変更する場合は下記3箇所をまとめて修正すること
   ※ dvh 行は iOS Safari 対策: vh はアドレスバー非表示時の最大高さを基準にするため
     実際の表示領域より大きくなり、下部コントロールが画面外に押し出される。
     dvh は動的ビューポート高さで、アドレスバー表示状態を反映する。
   ※ padding: 0 は koda-mock-up.css のモバイル用 .modal { padding: 4rem 0 } を打ち消す
     （128px の上下パディングがモーダルの usable 領域を圧迫するため）
   ※ box-sizing: border-box で height/max-height に padding を含める安全策 */
.modal-score1-popup .modal,
.modal-score2-popup .modal,
.modal-score3-popup .modal,
[class*="modal-score"] .modal {
  max-height: 90vh;
  max-height: 90dvh; /* iOS Safari: 動的ビューポート高さで上書き */
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
}
.modal-score1-popup .modal .modal_content_fit-_fit,
.modal-score2-popup .modal .modal_content_fit-_fit,
.modal-score3-popup .modal .modal_content_fit-_fit,
[class*="modal-score"] .modal .modal_content_fit-_fit,
.modal-score1-popup .modal .w-container,
.modal-score2-popup .modal .w-container,
.modal-score3-popup .modal .w-container,
[class*="modal-score"] .modal .w-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.modal-score1-popup .modal .wrapper_item,
.modal-score2-popup .modal .wrapper_item,
.modal-score3-popup .modal .wrapper_item,
[class*="modal-score"] .modal .wrapper_item {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.modal-score1-popup .wrapper_popup_common,
.modal-score2-popup .wrapper_popup_common,
.modal-score3-popup .wrapper_popup_common,
[class*="modal-score"] .wrapper_popup_common {
  max-height: calc(90vh - 140px);
  max-height: calc(90dvh - 140px); /* iOS Safari: dvhで上書き（90dvhと連動） */
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* 楽譜は座標ずれ防止のため余白なし（ボタン位置と表示領域を一致） */
  padding: 0;
  overflow: hidden; /* style.css の overflow:auto を打ち消し（楽譜は absolute 配置のためスクロール不要） */
}
.modal-score1-popup .koda_paragraph_lyrics,
.modal-score2-popup .koda_paragraph_lyrics,
.modal-score3-popup .koda_paragraph_lyrics,
[class*="modal-score"] .koda_paragraph_lyrics {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* 画像エリアを縦方向に広げて拡大時に多く表示
   ※ overflow: hidden / padding-top: 0 は koda-mock-up.css のモバイル用
     .koda_score_main { overflow: auto; padding-top: 20px } を打ち消す。
     楽譜ビューアーは absolute 配置のため scroll は不要で、padding-top は
     pv-inner の absolute inset:0 配置とズームコントロール位置に干渉する。 */
.modal-score1-popup .koda_score_main,
.modal-score2-popup .koda_score_main,
.modal-score3-popup .koda_score_main,
[class*="modal-score"] .koda_score_main {
  flex: 1;
  min-height: 60vh;
  min-height: 60dvh; /* iOS Safari: dvhで上書き */
  position: relative;
  overflow: hidden;
  padding-top: 0;
}

/* 楽譜ポップアップ: 添付画像の配置に合わせる
   - ズームバー: 画像左下、下端にマージン
   - 前へ・次へ: 画像左右中央、端にマージン
   - 1/4・×: 画像右上（表示画像の端にアンカー）
   - 写真情報: 画像右下、下端にマージン
   すべて画像表示エリア（pv-inner）を基準に配置 */
.modal-score1-popup .pv-inner,
.modal-score2-popup .pv-inner,
.modal-score3-popup .pv-inner,
[class*="modal-score"] .pv-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.modal-score1-popup .pv-stage,
.modal-score2-popup .pv-stage,
.modal-score3-popup .pv-stage,
[class*="modal-score"] .pv-stage {
  position: absolute;
  inset: 0;
  /* スマホ時: タッチ操作をページではなくポップアップ内に閉じる */
  touch-action: none;
  overscroll-behavior: contain;
}
/* ズームバー: 画像左下、下端にマージンでオーバーレイ */
.modal-score1-popup .pv-bottom-bar,
.modal-score2-popup .pv-bottom-bar,
.modal-score3-popup .pv-bottom-bar,
[class*="modal-score"] .pv-bottom-bar {
  position: absolute;
  left: var(--pv-gap);
  right: var(--pv-gap);
  bottom: var(--pv-gap);
}
/* 1/4・×: 画像右上（表示画像コンテンツの端にアンカー） */
.modal-score1-popup .pv-close,
.modal-score2-popup .pv-close,
.modal-score3-popup .pv-close,
[class*="modal-score"] .pv-close {
  position: absolute;
  top: var(--pv-gap);
  right: var(--pv-gap);
}
.modal-score1-popup .pv-counter,
.modal-score2-popup .pv-counter,
.modal-score3-popup .pv-counter,
[class*="modal-score"] .pv-counter {
  position: absolute;
  top: var(--pv-gap);
  right: calc(var(--pv-gap) + var(--pv-close-size) + 8px);
}
/* 前へ・次へ: 画像左右中央、端にマージンでオーバーレイ */
.modal-score1-popup .pv-nav,
.modal-score2-popup .pv-nav,
.modal-score3-popup .pv-nav,
[class*="modal-score"] .pv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.modal-score1-popup .pv-prev,
.modal-score2-popup .pv-prev,
.modal-score3-popup .pv-prev,
[class*="modal-score"] .pv-prev {
  left: var(--pv-gap);
}
.modal-score1-popup .pv-next,
.modal-score2-popup .pv-next,
.modal-score3-popup .pv-next,
[class*="modal-score"] .pv-next {
  right: var(--pv-gap);
}

.pv-stage {
  position: absolute;
  inset: 0;
  /*background: #000;*/
  /* 余りは黒 */
}

.pv-img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* 要件：黒帯を出して収める */
  transform-origin: 50% 50%;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  cursor: grab;
  border: none;
  opacity: 0; /* デフォルトで非表示（ロード完了後にJSで表示） */
  transition: opacity 0.3s ease; /* フェードイン効果 */
  will-change: transform; /* GPU コンポジッティング最適化: ズーム時のレイヤー割当てを事前に確保 */
}

.pv-stage.pv-zoomed .pv-img {
  cursor: grab;
}

.pv-stage.pv-zoomed {
  touch-action: none; /* ズーム時のパンを優先（スマホのスクロール抑制） */
}

.pv-stage.pv-zoomed .pv-img:active {
  cursor: grabbing;
}

.pv-top-left {
  position: absolute;
  top: var(--pv-gap);
  left: var(--pv-gap);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .12);
  /* 右上の閉じるボタン領域を避ける */
  max-width: calc(100% - 3*var(--pv-gap) - var(--pv-close-size));
}

.pv-title {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: .2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--pv-muted);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pv-bottom-right {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px;
  color: var(--pv-muted);
  max-width: min(70%, 520px);
}

.pv-place {
  text-align: left;
  color: var(--pv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-date {
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-bottom-left {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .40);
  border: 1px solid rgba(255, 255, 255, .12);
}

.pv-bottom-bar {
  position: absolute;
  left: var(--pv-gap);
  right: var(--pv-gap);
  bottom: var(--pv-gap);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none; /* 背景クリックを通す */
}

.pv-bottom-bar > * {
  pointer-events: auto; /* ボタン等は操作できるように戻す */
}

.pv-btn {
  height: var(--pv-control-h);
  min-width: var(--pv-control-h);
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: var(--pv-text);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation; /* ダブルタップズーム防止 */
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}

.pv-btn:hover {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(255, 255, 255, .26);
}

.pv-btn:active {
  transform: translateY(1px) scale(.99);
}

.pv-zoom {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--pv-muted);
  min-width: 64px;
  text-align: center;
}

.pv-close {
  position: absolute;
  top: var(--pv-gap);
  right: var(--pv-gap);
  height: var(--pv-close-size);
  width: var(--pv-close-size);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(0, 0, 0, .25);
  color: var(--pv-text);
  cursor: pointer;
  touch-action: manipulation; /* ダブルタップズーム防止 */
  z-index: 10; /* 画像やステージより前面に表示 */
}

.pv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 52px;
  width: 52px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(0, 0, 0, .25);
  touch-action: manipulation; /* ダブルタップズーム防止 */
  color: var(--pv-text);
  cursor: pointer;
}

.pv-prev {
  left: var(--pv-gap);
}

.pv-next {
  right: var(--pv-gap);
}

.pv-counter {
  position: absolute;
  top: calc(var(--pv-gap) + 54px);
  right: var(--pv-gap);
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .30);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px;
  color: var(--pv-muted);
}

.pv-hidden {
  display: none !important;
}

/* スマホ対応（ボタンがはみ出ないように詰める） */
@media (max-width: 640px) {
  :root {
    --pv-gap: 8px;
    /* スマホはさらに小さく（コントローラが2段になりやすいので） */
    --pv-control-h: 26px;
    --pv-radius: 14px;
    --pv-close-size: 28px;
  }

  .pv-title {
    font-size: 13px;
  }

  .pv-bottom-left {
    gap: 6px;
    padding: 6px 8px;
    max-width: calc(100% - 2*var(--pv-gap));
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* スマホは縦積みにして、日付をコントローラの上へ */
  .pv-bottom-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pv-bottom-right {
    align-self: flex-end;
    order: 0;
    max-width: 100%;
  }

  .pv-bottom-left {
    order: 1;
  }

  .pv-btn {
    min-width: var(--pv-control-h);
    padding: 0 7px;
    border-radius: 10px;
    font-size: 11px;
  }

  .pv-zoom {
    min-width: 44px;
    font-size: 10px;
  }

  .pv-nav {
    height: 42px;
    width: 42px;
    border-radius: 14px;
  }

  .pv-close { border-radius: 12px; }
}

/* ==================== 2026-03-17 追加 ====================
   横向きモバイル対応（楽譜ポップアップ）

   【問題】
   iPhone 横向き時、ビューポート高さが ~340px しかないのに対し
   モーダルが 90dvh(≈306px) + ヘッダー ~80px + min-height:60vh(≈204px)
   で合計 ~360px を要求し、縦幅不足で操作不能になる。

   【対策】
   - モーダル高さ: 90dvh → 100dvh に最大化
   - ヘッダー: ギターアイコン非表示、タイトルを横並び1行に圧縮
   - min-height: 60vh / 400px の固定制約を解除
   - 閉じるボタンを縮小
   ※ JS 側 (COMMENT_TEST.html の applyScoreModalSize) と連動
   ※ 詳細: docs/comment_test_height_auto_fix.md
   ========================================================= */
@media (orientation: landscape) and (max-height: 500px) {

  /* モーダル本体を100dvhに拡大 */
  [class*="modal-score"] .modal {
    max-height: 100vh;
    max-height: 100dvh; /* iOS Safari: dvh で上書き（vh→dvhの順で記述すること） */
    border-radius: 0;
  }

  /* ヘッダー領域を1行に圧縮 */
  [class*="modal-score"] .wrapper_item_title {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    padding: 2px 8px;
  }

  /* ギターアイコンを非表示 */
  [class*="modal-score"] .wrapper_item_title .icon_item_title {
    display: none;
  }

  /* タイトル・サブタイトルをインラインに */
  [class*="modal-score"] .wrapper_item_title .text_item_title {
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.2;
  }
  [class*="modal-score"] .wrapper_item_title .text_item_popup_content_name {
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.2;
  }

  /* 閉じるボタンを小さく・マージン縮小 */
  [class*="modal-score"] .btn_pop_close {
    width: 28px;
    height: 28px;
    font-size: 22px;
    line-height: 22px;
    margin-bottom: -1.5rem;
    top: -1.5rem;
  }

  /* wrapper_popup_common: ヘッダー圧縮分を反映 */
  [class*="modal-score"] .wrapper_popup_common {
    max-height: calc(100vh - 70px);
    max-height: calc(100dvh - 70px); /* iOS Safari: dvh で上書き */
  }

  /* koda_score_main: min-heightを解除して縦幅に収まるようにする */
  [class*="modal-score"] .koda_score_main {
    min-height: 0;
  }

  /* pv-inner: 固定min-heightを解除 */
  [class*="modal-score"] .pv-inner {
    min-height: 0;
  }
}

