/* ==========================================================================
   共有ボトムシート（ネイティブ風）— レポート出力パネルの SNS 共有
   --------------------------------------------------------------------------
   - 縦積みの SNS ボタン群を撤去し、控えめな「共有アイコン1つ」に集約。
   - 非対応端末では下からせり上がる <dialog> ボトムシート（丸 SNS アイコン）。
   - light/dark 両対応（既存トークン var(--c-surface) 等を参照）。丸アイコンの
     ブランド色はベタ。safe-area / タップ領域44px / 横スクロール禁止に配慮。
   - CSP 厳格: このファイルは外部 CSS。テンプレ側にインライン style は無い。
   ========================================================================== */

/* ---- 共有トリガ（丸アイコン1つ・目立たない位置） ---------------------------- */
.vg-share {
  display: inline-flex;
  align-items: center;
}
.vg-share__open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;   /* タップ領域 */
  min-height: 44px;
  border-radius: 999px;
  color: var(--c-text-muted, #515a66);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.vg-share__open:hover {
  color: var(--c-text, #14181f);
  background: var(--c-surface-hover, rgba(0, 0, 0, .05));
}
.vg-share__open:focus-visible {
  outline: 2px solid var(--c-accent, #1b5fa8);
  outline-offset: 2px;
}
.vg-share__open-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.vg-share__open-ico .vg-feat-ico {
  width: 20px;
  height: 20px;
}

/* ---- レポート PDF 書き出し（「戻れる」導線＋アプリ内エラー表示） ------------- */
.vg-report-pdf {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.vg-report-pdf [data-pdf-trigger] {
  min-height: 44px; /* タップ領域 */
}
.vg-report-pdf [data-pdf-trigger][disabled] {
  opacity: .6;
  cursor: progress;
}
.vg-report-pdf__hint {
  flex-basis: 100%;
}
.vg-report-pdf__msg {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--c-text-muted, #515a66);
}
.vg-report-pdf__msg.is-error {
  color: var(--c-danger, #b42318);
}

/* ---- ボトムシート本体（<dialog>） ------------------------------------------ */
.vg-share-sheet {
  /* 画面下端に固定・中央寄せ・全幅（最大 480px）。showModal で top-layer に載る。 */
  position: fixed;
  inset: auto 0 0 0;
  margin: auto auto 0 auto;   /* 下端中央にピン留め */
  width: 100%;
  max-width: 480px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--c-text, #14181f);
  overflow: visible;
  overscroll-behavior: contain; /* シート内スクロールが背景へ伝播しない（iOS 誤スクロール防止） */
}
.vg-share-sheet::backdrop {
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(1px);
}

.vg-share-sheet__panel {
  background: var(--c-surface, #fff);
  overscroll-behavior: contain; /* パネル内スクロール連鎖を背景へ伝えない */
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid var(--c-border, #d3d9e0);
  border-bottom: none;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .22);
  /* safe-area: iPhone ホームインジケータ分を下に確保 */
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}

.vg-share-sheet__grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--c-border, #d3d9e0);
  margin: 2px auto 12px;
}
.vg-share-sheet__title {
  margin: 0 0 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text, #14181f);
}

/* ---- 丸 SNS アイコンのグリッド（3×2 固定・どの幅でも対称配置） --------------- */
.vg-share-sheet__grid {
  /* flex-wrap の半端折返し（480〜360px で 5+1 等）を避け、常に 3 列 × 2 行の対称配置。 */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: 8px 4px;
  margin: 0 0 8px;
}
.vg-share-item {
  /* 各セルは grid が幅を担う。グリフ幅の基準として 72px を上限に保つ。 */
  width: 100%;
  max-width: 72px;
  min-height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--c-text, #14181f);
  -webkit-tap-highlight-color: transparent;
}
.vg-share-item:hover { background: var(--c-surface-hover, rgba(0, 0, 0, .04)); }
.vg-share-item:focus-visible {
  outline: 2px solid var(--c-accent, #1b5fa8);
  outline-offset: 2px;
}

.vg-share-item__circle {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;               /* グリフは白（ブランド色ベタの上） */
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.vg-share-item__circle svg { display: block; }

/* ブランド色（ベタ塗り） */
.vg-share-item__circle--x         { background: #000000; }
.vg-share-item__circle--line      {
  background: #06C755;
  /* 白グリフ vs #06C755 は 2.26:1（1.4.11 の 3:1 直下）。ブランド色は維持しつつ
     内側 1px の半透明白で視覚境界を補強し、円の輪郭を判別しやすくする。 */
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(255, 255, 255, .4);
}
.vg-share-item__circle--facebook  { background: #1877F2; }
.vg-share-item__circle--messenger { background: #0084FF; }
.vg-share-item__circle--gmail     { background: #EA4335; }
.vg-share-item__circle--copy {
  background: var(--c-surface-2, #eef1f5);
  color: var(--c-text, #14181f);
  border: 1px solid var(--c-border, #d3d9e0);
}

.vg-share-item__label {
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  color: var(--c-text-muted, #515a66);
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vg-share-item.is-copied .vg-share-item__label { color: #06C755; }

/* ---- キャンセル ------------------------------------------------------------ */
.vg-share-sheet__cancel {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--c-border, #d3d9e0);
  background: var(--c-surface-2, #eef1f5);
  color: var(--c-text, #14181f);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.vg-share-sheet__cancel:hover { background: var(--c-surface-hover, #e7ebf1); }
.vg-share-sheet__cancel:focus-visible {
  outline: 2px solid var(--c-accent, #1b5fa8);
  outline-offset: 2px;
}

/* ---- せり上がりアニメーション（reduced-motion 尊重） ------------------------ */
@keyframes vgShareSheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes vgShareBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.vg-share-sheet[open] { animation: vgShareSheetUp .24s cubic-bezier(.22, 1, .36, 1); }
.vg-share-sheet[open]::backdrop { animation: vgShareBackdropIn .24s ease; }

@media (prefers-reduced-motion: reduce) {
  .vg-share-sheet[open],
  .vg-share-sheet[open]::backdrop { animation: none; }
}

/* 狭幅端末（320px）でも 3×2 グリッドを維持（横スクロール禁止）。
   セル間 gap を詰め、円サイズは据え置きで対称配置を崩さない。 */
@media (max-width: 360px) {
  .vg-share-sheet__grid { gap: 8px 2px; }
  .vg-share-item { padding: 8px 0; }
}
