/*!
 * MVKit v1.1.0 | MIT
 * 通用视频播放器 & 图片预览器样式
 */

/* ════════════════════════════════════════════
 * 0. 宿主元素基础
 * ════════════════════════════════════════════ */

.mv-mounted {
  position: relative;
  overflow: hidden;
}

/* 宿主没给高度时，视频按 16:9 自适应 */
[data-mv="video"].mv-mounted:not([style*="height"]) {
  aspect-ratio: 16 / 9;
}

/* ════════════════════════════════════════════
 * 1. 视频播放器（vp- 前缀）
 * ════════════════════════════════════════════ */

/* ── 包裹层（容器查询上下文） ── */
.vp-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: inline-size;
  container-name: vp-wrapper;
}

/* ── 播放器容器 ── */
.vp-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #000;
  overflow: hidden;
  border-radius: 4px;
}

.vp-container video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

/* ── 底部渐变遮罩 ── */
.vp-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.vp-container:hover .vp-gradient,
.vp-container.vp-paused .vp-gradient {
  opacity: 1;
}

/* ── 中央大播放按钮 ── */
.vp-big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 5;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    background 0.2s ease;
}

.vp-container.vp-paused .vp-big-play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.vp-big-play:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: translate(-50%, -50%) scale(1.1);
}

.vp-big-play:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.vp-big-play svg {
  width: 32px;
  height: 32px;
  margin-left: 4px;
}

/* ── 底部控件栏 ── */
.vp-controls {
  position: relative;
  z-index: 10;
  padding: 0 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.vp-container:hover .vp-controls,
.vp-container.vp-paused .vp-controls {
  opacity: 1;
  transform: translateY(0);
}

/* ── 进度条 ── */
.vp-progress-wrap {
  position: relative;
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 0;
}

.vp-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: visible;
  transition: height 0.15s ease;
}

.vp-progress-wrap:hover .vp-progress-track {
  height: 6px;
}

.vp-progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.vp-progress-played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: none;
}

.vp-progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
  pointer-events: none;
}

.vp-progress-wrap:hover .vp-progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.vp-progress-tooltip {
  position: absolute;
  bottom: 100%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  margin-bottom: 8px;
}

.vp-progress-wrap:hover .vp-progress-tooltip {
  opacity: 1;
}

/* ── 按钮栏 ── */
.vp-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vp-buttons-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vp-buttons-right {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

/* ── 单个控制按钮 ── */
.vp-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  transition:
    background 0.2s ease,
    transform 0.15s ease;
  flex-shrink: 0;
  line-height: 1;
}

.vp-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.vp-btn:active {
  transform: scale(0.92);
}

.vp-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.vp-btn-play svg {
  width: 22px;
  height: 22px;
}

/* ── 时间显示 ── */
.vp-time {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0 6px;
  user-select: none;
  line-height: 36px;
}

/* ── 全屏按钮 ── */
.vp-btn-fullscreen svg {
  width: 18px;
  height: 14px;
}

/* ── 倍速按钮 ── */
.vp-btn-speed {
  width: auto;
  min-width: 40px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  user-select: none;
}

.vp-btn-speed.active {
  color: #4ecdc4;
}

/* ── 二级菜单通用（深色毛玻璃） ── */
.vp-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  background: rgba(20, 20, 20, 0.88);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
  min-width: 100px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.95);
  transition:
    opacity 0.2s ease,
    visibility 0s ease 0.2s,
    transform 0.2s ease;
  z-index: 100;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

.vp-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.2s ease,
    visibility 0s,
    transform 0.2s ease;
}

/* ── 倍速菜单 ── */
.vp-speed-menu {
  right: 0;
  min-width: 70px;
  max-width: 80px;
}

.vp-speed-menu .vp-menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
}

.vp-speed-menu .vp-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.vp-speed-menu .vp-menu-item.active {
  color: #4ecdc4;
  font-weight: 700;
}

/* ── 音量 ── */
.vp-volume-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.vp-volume-menu {
  right: 50%;
  transform: translateX(50%) translateY(8px) scale(0.95);
  min-width: 44px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.vp-volume-menu.open {
  transform: translateX(50%) translateY(0) scale(1);
}

/* 悬停热区桥接（防止鼠标移到菜单途中断开） */
.vp-volume-wrap::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 12px;
  z-index: 99;
}

.vp-volume-slider-wrap {
  width: 40px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.vp-volume-track {
  position: relative;
  width: 4px;
  height: 100px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: visible;
}

.vp-volume-filled {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  pointer-events: none;
  transition: none !important;
}

.vp-volume-thumb {
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, 50%);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: none !important;
}

.vp-volume-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 8px;
  text-align: center;
  user-select: none;
}

/* ── 更多选项菜单 ── */
.vp-more-menu {
  right: 0;
  min-width: 120px;
}

.vp-more-menu .vp-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
  text-align: left;
}

.vp-more-menu .vp-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.vp-more-menu .vp-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── 画中画返回横幅 ── */
.vp-pip-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(20, 20, 20, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition:
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.vp-pip-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.vp-pip-banner-text {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.vp-pip-return-btn {
  padding: 6px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
  white-space: nowrap;
}

.vp-pip-return-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ── 加载指示器 ── */
.vp-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: vp-spin 0.8s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.vp-container.vp-loading .vp-loading {
  opacity: 1;
}

@keyframes vp-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ════════════════════════════════════════════
 * 2. 图片预览器（lb-img- 前缀，与 JS 类名一致）
 * ════════════════════════════════════════════ */

/* ── 图片包裹层 ── */
.lb-img-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  transition: background 0.5s ease;
}

.lb-img-wrapper.grabbing {
  cursor: grabbing;
}

.lb-img-wrapper:not(.zoomed) {
  cursor: default;
}

/* ── 模糊背景层（缩放时显示） ── */
.lb-img-blur-bg {
  position: absolute;
  /* 内扩量必须大于模糊半径，否则 40px 模糊会在四周产生透明毛边 */
  top: -80px;
  left: -80px;
  right: -80px;
  bottom: -80px;
  filter: blur(40px) saturate(1.2);
  -webkit-filter: blur(40px) saturate(1.2);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 0;
  pointer-events: none;
}

/* ── 图片本体 ── */
.lb-img-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.3s ease;
  transform-origin: center center;
  will-change: transform;
  z-index: 1;
  position: relative;
}

/* 拖拽时取消过渡（跟手） */
.lb-img-wrapper.dragging img {
  transition: none;
}

/* ── 图片控制按钮 ── */
.lb-img-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.lb-img-controls button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    background 0.2s,
    transform 0.2s;
}

.lb-img-controls button:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: scale(1.1);
}

.lb-img-controls button:active {
  transform: scale(0.95);
}

/* ════════════════════════════════════════════
 * 3. 响应式微调（基于容器查询）
 * ════════════════════════════════════════════ */

/* 小容器内压缩控件尺寸 */
@container vp-wrapper (max-width: 480px) {
  .vp-btn {
    width: 32px;
    height: 32px;
  }
  .vp-btn svg {
    width: 18px;
    height: 18px;
  }
  .vp-time {
    font-size: 12px;
    padding: 0 4px;
    line-height: 32px;
  }
  .vp-big-play {
    width: 56px;
    height: 56px;
  }
  .vp-big-play svg {
    width: 26px;
    height: 26px;
  }
}
