/* B2 Shorts — 全屏上下滑短视频流（沉浸式） */
html.b2-shorts-html,
body.b2-shorts-body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100%;
  height: 100%;
  background: #000 !important;
  overflow: hidden !important;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  /* 必须允许纵向滑动：祖先 touch-action:none 会与子级 pan-y 求交变成 none */
  touch-action: pan-y;
}

/* 隐藏主题页头页脚等，只留 Shorts 壳 */
body.b2-shorts-body > *:not(.shorts-app):not(.shorts-exit-toast):not(script):not(style):not(link) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.shorts-app {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  touch-action: pan-y;
}

.shorts-feed {
  height: 100%;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
  touch-action: pan-y;
  scrollbar-width: none;
}

.shorts-feed::-webkit-scrollbar {
  display: none;
}

.shorts-slide {
  position: relative;
  height: 100%;
  height: 100dvh;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  overflow: hidden;
}

.shorts-stage {
  position: absolute;
  inset: 0;
  background: #000;
}

.shorts-poster {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-color: #000;
  background-size: cover;
  background-position: center;
  filter: blur(10px) brightness(.72);
  transform: scale(1.06);
  opacity: 1;
  transition: opacity .18s ease, visibility .18s ease;
  pointer-events: none;
}

/* 抖音：不用特色图作海报，避免滑入时闪封面文案/抖音感信息 */
.shorts-poster--plain {
  background-image: none !important;
  filter: none;
  transform: none;
}

.shorts-poster.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.9);
  border-radius: 50%;
  animation: shorts-spin .7s linear infinite;
}

@keyframes shorts-spin {
  to { transform: rotate(360deg); }
}

.shorts-poster.is-hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  z-index: 1;
}

.shorts-video {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 关键：iframe 不抢纵向滑动，手势交给 .shorts-feed */
  pointer-events: none;
  /* 未就绪前隐藏，避免滑入时先闪抖音壳层 */
  opacity: 0;
  transition: opacity .1s ease;
}

.shorts-slide.is-active.is-media-ready .shorts-video {
  opacity: 1;
}

/* 可点态：父级/frame/iframe 全部 auto，否则 WebView 会把首点吞掉 */
.shorts-slide.is-pe-open .shorts-video,
.shorts-slide.is-pe-open .shorts-video figure,
.shorts-slide.is-pe-open .shorts-video .douyin-embed__frame,
.shorts-slide.is-pe-open .shorts-video .bili-embed__frame,
.shorts-slide.is-pe-open .shorts-video iframe {
  pointer-events: auto !important;
}

/* 左右边缘接滑动（可点态下中间交给播放器，两侧滑切条） */
.shorts-swipe-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 6;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.shorts-swipe-edge--l { left: 0; }
.shorts-swipe-edge--r { right: 0; }

/* 覆盖抖音 / B站插件移动端 324px 等限制，强制铺满 Shorts 画布
 * 选择器需压过 figure.douyin-embed.douyin-embed--mode-responsive */
.shorts-video figure.douyin-embed,
.shorts-video figure.douyin-embed.douyin-embed--mode-responsive,
.shorts-video figure.douyin-embed.douyin-embed--mode-single,
.shorts-video figure.bili-embed,
.shorts-video figure.bili-embed.bili-embed--mode-responsive,
.shorts-video figure.bili-embed.bili-embed--mode-single,
.shorts-video figure {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

.shorts-video .douyin-embed__frame,
.shorts-video .bili-embed__frame,
.shorts-video figure.douyin-embed .douyin-embed__frame,
.shorts-video figure.bili-embed .bili-embed__frame {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: #000 !important;
  overflow: hidden !important;
  position: relative !important;
  pointer-events: none !important;
}

.shorts-video iframe {
  pointer-events: none !important;
}

/* B站：铺满 */
.shorts-video figure.bili-embed iframe {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  border: 0 !important;
  display: block !important;
  transform: none !important;
}

/*
 * 抖音：iframe 固定手机画幅再 scale（见 shorts.js）。
 * 高度不能跟舞台拉满，否则抖音会渲染「封面底图+小窗」双层。
 */
.shorts-video figure.douyin-embed,
.shorts-video figure.douyin-embed.douyin-embed--mode-responsive,
.shorts-video figure.douyin-embed.douyin-embed--mode-single {
  overflow: hidden !important;
  background: #000 !important;
}

.shorts-video figure.douyin-embed .douyin-embed__frame {
  overflow: hidden !important;
  background: #000 !important;
}

.shorts-video figure.douyin-embed iframe {
  border: 0 !important;
  display: block !important;
  max-width: none !important;
  /* 首帧先锁手机宽，降低未 fit 前出现双层的概率 */
  width: 324px !important;
}

/* 桌面端：居中竖屏画幅 */
@media (min-width: 769px) {
  .shorts-feed {
    background: #0a0a0a;
  }

  .shorts-stage {
    inset: auto;
    top: 0;
    bottom: 0;
    left: 50%;
    width: min(420px, 100vw);
    height: 100%;
    transform: translateX(-50%);
  }

  .shorts-meta {
    left: 50%;
    right: auto;
    width: auto;
    transform: translateX(-50%);
    top: auto;
    bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  }
}

/* 左下角（操作习惯）；略抬高，减少挡到底部进度条 */
.shorts-meta {
  position: absolute;
  left: 16px;
  right: auto;
  top: auto;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  pointer-events: none;
}

.shorts-meta a {
  pointer-events: auto;
  color: #fff;
}

.shorts-meta__detail {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .28);
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-shadow: none;
}

.shorts-meta__detail:active {
  background: rgba(0, 0, 0, .6);
}

/* 再按一次回首页（抖音式居中 toast） */
.shorts-app .shorts-exit-toast,
.shorts-exit-toast {
  position: fixed !important;
  left: 50% !important;
  top: 46% !important;
  z-index: 2147483647 !important;
  transform: translate(-50%, -50%) !important;
  padding: 14px 26px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .84);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .45);
  display: none;
  opacity: 0;
}

.shorts-app .shorts-exit-toast.is-show,
.shorts-exit-toast.is-show {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.shorts-exit-toast[hidden] {
  display: none !important;
}
