/* md_images.css - v55 テキストエディタの画像 (行の下の埋め込み / 一覧 / ビューワー) */

/* ===== 行の下の画像 ===== */
.mdx-embed { display: block; margin: 6px 0 8px; line-height: 0; text-align: left; cursor: default; }
.mdx-embed.mdx-al-center { text-align: center; }
.mdx-embed.mdx-al-right { text-align: right; }
.mdx-embed-box {
  position: relative; display: inline-block;
  max-width: 100%; min-width: 60px; min-height: 40px;
  border-radius: 10px; overflow: hidden;
  background: var(--bg-sunk);
  box-shadow: 0 0 0 1px var(--border);
  transition: box-shadow .15s;
  vertical-align: top;
}
.mdx-embed-box img { display: block; width: 100%; height: auto; max-width: 100%; cursor: zoom-in; }
.mdx-embed-box:not([style]) img { width: auto; max-height: 70vh; }
.mdx-embed-box:hover, .mdx-embed.is-resizing .mdx-embed-box { box-shadow: 0 0 0 2px var(--accent); }
.mdx-embed-box.is-missing { min-width: 220px; min-height: 64px; }
.mdx-embed-box.is-missing::after {
  content: '画像が見つかりません: ' attr(data-name);
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1.4; color: var(--fg-dim); padding: 6px; text-align: center;
}
/* 操作バー (マウスを乗せたときだけ) */
.mdx-embed-bar {
  position: absolute; left: 8px; top: 8px; display: flex; gap: 2px;
  padding: 3px; border-radius: 8px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(-3px); transition: opacity .12s, transform .12s;
  line-height: 1.3;
}
.mdx-embed-box:hover .mdx-embed-bar { opacity: 1; transform: none; }
.mdx-embed.is-resizing .mdx-embed-bar { opacity: 0; }
.mdx-eb {
  font-size: 11px; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  color: var(--fg-mute); white-space: nowrap;
}
.mdx-eb::before { content: attr(data-t); }
.mdx-eb:hover { background: var(--bg-sunk); color: var(--fg); }
.mdx-eb.is-on { color: var(--accent-fg, #fff); background: var(--accent); }
.mdx-eb--del:hover { color: var(--danger); }
/* 大きさ変更のつまみ (右下) */
.mdx-embed-grip {
  position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize;
  opacity: 0; transition: opacity .12s;
  background:
    linear-gradient(135deg, transparent 50%, var(--accent) 50%) right bottom / 14px 14px no-repeat;
  border-bottom-right-radius: 10px;
}
.mdx-al-right .mdx-embed-grip { right: auto; left: 0; cursor: nesw-resize; transform: scaleX(-1); }
.mdx-embed-box:hover .mdx-embed-grip, .mdx-embed.is-resizing .mdx-embed-grip { opacity: 1; }
.mdx-embed-size { display: none; }
.mdx-embed.is-resizing .mdx-embed-size {
  display: block; position: absolute; right: 8px; top: 8px;
  font-size: 11px; line-height: 1.5; padding: 1px 8px; border-radius: 9px;
  background: var(--accent); color: var(--accent-fg, #fff);
}
.mdx-embed-size::before { content: attr(data-t); }
.mdx--static .mdx-embed { display: none; }

/* ===== テキストの下の画像一覧 ===== */
.mdx-gallery { margin: 14px 0 4px 22px; padding-top: 10px; border-top: 1px dashed var(--border); }
.mdx--compact .mdx-gallery { margin-top: 6px; padding-top: 6px; }
.mdx-gallery-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mdx-gallery-title { font-size: 11px; letter-spacing: .14em; color: var(--fg-dim); }
.mdx-gallery-count { font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.mdx-gallery .mdx-gallery-add {
  margin-left: auto; font-size: 11px; padding: 2px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--fg-mute); line-height: 1.5;
}
.mdx-gallery .mdx-gallery-add:hover { color: var(--fg); border-color: var(--fg-dim); }
.mdx-gallery-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mdx-gallery-list:empty { display: none; }
.mdx-gallery .mdx-gallery-item {
  width: 112px; height: 80px; padding: 0; border: 0; border-radius: 8px; overflow: hidden;
  background: var(--bg-sunk); cursor: zoom-in; box-shadow: 0 0 0 1px var(--border);
  transition: box-shadow .12s, transform .12s;
}
.mdx-gallery .mdx-gallery-item:hover { box-shadow: 0 0 0 2px var(--accent); transform: translateY(-1px); }
.mdx-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mdx-gallery-item.is-missing { opacity: .4; cursor: default; }

/* ===== ビューワー ===== */
.mdx-viewer {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(10, 10, 10, .88);
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; grid-template-rows: auto minmax(0, 1fr);
  color: #f2f2f2;
}
.mdx-viewer-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 12.5px; }
.mdx-viewer-cap { margin-right: auto; opacity: .85; white-space: pre; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.mdx-viewer .mdx-viewer-btn {
  font-size: 12px; padding: 4px 12px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.1); color: #f2f2f2; border: 1px solid rgba(255,255,255,.18);
}
.mdx-viewer .mdx-viewer-btn:hover { background: rgba(255,255,255,.2); }
.mdx-viewer .mdx-viewer-nav {
  align-self: center; justify-self: center; width: 44px; height: 44px; border-radius: 50%;
  font-size: 26px; line-height: 1; cursor: pointer;
  background: rgba(255,255,255,.08); color: #f2f2f2; border: 0;
}
.mdx-viewer .mdx-viewer-nav:hover { background: rgba(255,255,255,.2); }
.mdx-viewer.is-single .mdx-viewer-nav { visibility: hidden; }
.mdx-viewer-stage { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 0 0 22px; overflow: hidden; }
.mdx-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; cursor: zoom-in; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.mdx-viewer-stage.is-actual { overflow: auto; align-items: flex-start; justify-content: flex-start; }
.mdx-viewer-stage.is-actual .mdx-viewer-img { max-width: none; max-height: none; cursor: zoom-out; margin: auto; }
