/* =====================================================================
   DOTZSO · Video Reels + Lightbox  |  原生 CSS，无依赖
   v1.0  —  命名空间统一 dz-，避免与主题/页面构建器样式冲突
   ===================================================================== */

.dz-reels {
  --dz-accent: #e46fa6;
  --dz-ink: #2b2530;
  --dz-radius: 16px;
  --dz-gap: 14px;
  padding: 64px 20px 72px;
  background: linear-gradient(180deg, #ffffff 0%, #fbf7fb 100%);
  font-family: inherit;
  box-sizing: border-box;
}
.dz-reels *,
.dz-lightbox * { box-sizing: border-box; }

.dz-reels__head { max-width: 760px; margin: 0 auto 30px; text-align: center; }
.dz-reels__title {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--dz-ink);
  line-height: 1.4;
}
.dz-reels__subtitle {
  margin: 0;
  font-size: clamp(13px, 1.4vw, 15px);
  color: #6b626f;
  line-height: 1.8;
}

/* --- 横向卡片轨道：桌面 5 列，窄屏 scroll-snap --- */
.dz-reels__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--dz-gap);
  max-width: 1180px;
  margin: 0 auto;
}
/* --- 窄屏（平板 / 手机）：原生横向滚动，无 JS 也能滑 --- */
@media (max-width: 1024px) {
  .dz-reels__grid {
    display: flex;
    gap: var(--dz-gap);
    overflow-x: auto;
    overscroll-behavior-x: contain;   /* 防止横滑触发浏览器「返回上一页」手势 */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;            /* Firefox 隐藏滚动条 */
    padding: 0 20px 8px;
    scroll-padding-inline: 20px;
  }
  .dz-reels__grid::-webkit-scrollbar { display: none; }  /* Chrome / Safari */
  .dz-reels__grid .dz-reel { flex: 0 0 240px; scroll-snap-align: start; }
  /* 提高特异性，避免被后面 .dz-reels__nav{display:none} 覆盖 */
  .dz-reels .dz-reels__nav { display: flex; }
}

/* --- 手机：两侧露边 + 居中吸附 + 箭头 / 计数导航 --- */
@media (max-width: 767px) {
  .dz-reels {
    --dz-card-w: min(78vw, 340px);                       /* 卡片宽：两侧各露约 11vw */
    --dz-peek: max(12px, calc((100vw - var(--dz-card-w)) / 2));
    padding: 44px 0 48px;
  }
  .dz-reels__head { padding-inline: 20px; margin-bottom: 24px; }
  .dz-reels__grid {
    gap: 12px;
    padding-inline: var(--dz-peek);                     /* 首尾也能滚到正中 */
    scroll-padding-inline: var(--dz-peek);
  }
  .dz-reels__grid .dz-reel { flex-basis: var(--dz-card-w); scroll-snap-align: center; }
}

/* --- 轮播导航（默认隐藏，仅 ≤767px 显示） --- */
.dz-reels__nav {
  display: none;
  align-items: center; justify-content: center;
  gap: 16px; margin-top: 20px;
}
.dz-reels__arrow {
  width: 38px; height: 38px;
  border: 1px solid #ece2ea; border-radius: 10px;
  background: #fff; color: #2b2530;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(43, 37, 48, .06);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.dz-reels__arrow svg { width: 14px; height: 14px; }
.dz-reels__arrow:hover:not(:disabled) {
  background: var(--dz-accent); border-color: var(--dz-accent); color: #fff;
}
.dz-reels__arrow:disabled { opacity: .32; cursor: default; }
.dz-reels__arrow:focus-visible { outline: 3px solid var(--dz-accent); outline-offset: 3px; }
.dz-reels__counter {
  min-width: 62px; text-align: center;
  font-size: 13px; color: #9b929e; letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}
.dz-reels__counter b { color: #2b2530; font-weight: 700; }

/* --- 单张卡片 --- */
.dz-reel {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  padding: 0;
  border: 0;
  border-radius: var(--dz-radius);
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(160deg, #f7dbe7, #a58ab8 55%, #3b3358);
  box-shadow: 0 2px 10px rgba(43, 37, 48, .08);
  isolation: isolate;
  text-align: left;
  color: #fff;
  transition: transform .28s ease, box-shadow .28s ease;
}
.dz-reel:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(43, 37, 48, .18); }
.dz-reel:active { transform: translateY(-1px); }
.dz-reel:focus-visible { outline: 3px solid var(--dz-accent); outline-offset: 3px; }

/* 每张卡片一个底色，图片未加载时也不塌 */
.dz-reel[data-tone="1"] { background: linear-gradient(160deg, #ffd6e0, #c48cb2 55%, #582a4a); }
.dz-reel[data-tone="2"] { background: linear-gradient(160deg, #ffc4ba, #d65660 55%, #481426); }
.dz-reel[data-tone="3"] { background: linear-gradient(160deg, #ffba7c, #7e4ab4 55%, #1c1856); }
.dz-reel[data-tone="4"] { background: linear-gradient(160deg, #cef0e2, #60b2b0 55%, #184854); }
.dz-reel[data-tone="5"] { background: linear-gradient(160deg, #ffd69e, #b07858 55%, #24343a); }

.dz-reel__poster {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
}
.dz-reel__shade {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,.32) 0%, rgba(0,0,0,0) 26%, rgba(0,0,0,0) 58%, rgba(0,0,0,.72) 100%);
  pointer-events: none;
}
.dz-reel__badge,
.dz-reel__duration {
  position: absolute; top: 12px; z-index: 2;
  font-size: 11px; line-height: 1;
  padding: 6px 9px; border-radius: 6px;
  background: rgba(20, 18, 24, .62);
  backdrop-filter: blur(4px);
  color: #fff; letter-spacing: .02em;
}
.dz-reel__badge { left: 12px; }
.dz-reel__duration { right: 12px; }
.dz-reel__duration::before {
  content: ""; display: inline-block;
  width: 5px; height: 5px; margin-right: 5px;
  border-radius: 50%; background: var(--dz-accent); vertical-align: 1px;
}
.dz-reel__meta {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 16px 14px 14px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
}
.dz-reel__text { min-width: 0; }
.dz-reel__name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  font-size: 13.5px; font-weight: 700; line-height: 1.45;
  text-shadow: 0 1px 4px rgba(0,0,0,.35);
  text-wrap: balance;            /* 两行时均衡断行，避免末行只剩一个字 */
  overflow: hidden;
}
.dz-reel__author { display: block; margin-top: 4px; font-size: 11px; opacity: .85; }
.dz-reel__play {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: background .2s ease, transform .2s ease;
}
.dz-reel__play svg { width: 12px; height: 12px; fill: #2b2530; margin-left: 2px; }
.dz-reel:hover .dz-reel__play { background: var(--dz-accent); transform: scale(1.06); }
.dz-reel:hover .dz-reel__play svg { fill: #fff; }

/* --- 弹窗 / Lightbox --- */
.dz-lightbox {
  position: fixed; inset: 0; z-index: 2147483000;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(20, 17, 26, .86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .22s ease;
}
.dz-lightbox.is-open { display: flex; opacity: 1; }
.dz-lightbox__panel {
  position: relative;
  /* 宽度三重约束：视口宽 / (可用高 × 比例) / 上限。
     高度由 aspect-ratio 自然推导，不会像 max-height 那样压扁画面。
     --dz-ar = 视频宽 / 视频高，由 JS 在打开时写入（默认 .5625 = 9:16）。 */
  width: min(92vw, calc(76vh * var(--dz-ar, .5625)), 1100px);
  transform: translateY(12px) scale(.98);
  transition: transform .26s cubic-bezier(.2,.8,.2,1), width .28s cubic-bezier(.2,.8,.2,1);
}
.dz-lightbox.is-open .dz-lightbox__panel { transform: none; }
.dz-lightbox__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--dz-ar, .5625);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  transition: aspect-ratio .28s cubic-bezier(.2,.8,.2,1);
}
.dz-lightbox__media,
.dz-lightbox__media video,
.dz-lightbox__media iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0; display: block;
}
/* contain：比例探测完成前 / 声明值与实际不符时只留黑边，绝不裁掉画面 */
.dz-lightbox__media video { object-fit: contain; background: #000; }
.dz-lightbox__media iframe { background: #000; }
.dz-lightbox__close {
  position: absolute; top: -14px; right: -14px;
  width: 38px; height: 38px;
  border: 0; border-radius: 50%;
  background: #fff; color: #2b2530;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  z-index: 3;
}
.dz-lightbox__close:hover { background: var(--dz-accent); color: #fff; }
.dz-lightbox__close:focus-visible { outline: 3px solid var(--dz-accent); outline-offset: 3px; }
.dz-lightbox__caption {
  margin-top: 12px; text-align: center; color: #fff;
  font-size: 14px; line-height: 1.6;
}
.dz-lightbox__caption small { display: block; opacity: .68; font-size: 12px; }
.dz-lightbox__fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; text-align: center; color: #fff; font-size: 14px; line-height: 1.8;
}

@media (max-width: 560px) {
  .dz-lightbox { padding: 14px; }
  .dz-lightbox__panel { width: min(94vw, calc(78vh * var(--dz-ar, .5625))); }
  .dz-lightbox__close { top: -10px; right: -6px; width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .dz-reel, .dz-lightbox, .dz-lightbox__panel, .dz-lightbox__frame, .dz-reel__play { transition: none !important; }
  .dz-reels__grid { scroll-behavior: auto; }
}

/* 弹窗打开时锁定页面滚动 */
body.dz-lightbox-open { overflow: hidden; }
