/*
 * Twinkle Trimmings: 定制化产品详情页 —— 媒体区 + 信息区
 *
 * 仅由 [tt_product_detail] 使用，只在本模块的 .tt-pd / .tt-mv 作用域内生效，
 * 不产生全局选择器，避免污染 Elementor 与其它模块。
 */

/* ==========================================================================
   1. 外层与品牌变量
   ========================================================================== */
.tt-pd {
  --tt-primary: var(--e-global-color-primary, #7f4c15);
  --tt-accent: var(--e-global-color-03899bb, #aa440f);
  --tt-light: var(--e-global-color-1f04b25, #fdf3d8);
  --tt-text: var(--e-global-color-text, #333333);
  --tt-line: rgba(0, 0, 0, 0.1);

  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  font-family: inherit;
  border: 1px dashed var(--tt-primary, #7f4c15);
  border-radius: 12px;
  padding: 20px;
  color: var(--tt-text);
  font-family: var(
    --e-global-typography-primary-font-family,
    "Poppins",
    sans-serif
  );
}

@media (min-width: 992px) {
  .tt-pd {
    flex-direction: row;
    align-items: flex-start;
    gap: 44px;
  }
  /* PC 端媒体区与描述区 1 : 1 */
  .tt-pd-media {
    flex: 1 1 50%;
    min-width: 0;
  }
  .tt-pd-info {
    flex: 1 1 50%;
    min-width: 0;
  }
}

@media (max-width: 991px) {
  .tt-pd-media,
  .tt-pd-info {
    width: 100%;
  }
}

/* ==========================================================================
   2. 媒体区：主视图
   ========================================================================== */
/* 媒体块宽度：视觉上跟随视口宽度做响应式，且不超过 480px。
   主视图与缩略图条都以此为宽度基准，从而保证两者左右对齐。 */
.tt-mv {
  width: min(100%, clamp(300px, 50vw, 540px));
  margin: 0 auto;
}

/* 主视图：固定 1:1 比例，内容不足时用底色留白（object-fit: contain）。
   若想换比例，只改这一处即可，例如 4 / 3 或 16 / 9。 */
.tt-mv-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
}

.tt-mv-item {
  display: flex;
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}

.tt-mv-item.is-active {
  opacity: 1;
  visibility: visible;
}

.tt-mv-image,
.tt-mv-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

/* 主视图两侧的切换箭头（补充切换方式） */
.tt-mv-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: #333 !important;
  font-size: 28px !important;
  line-height: 1 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  display: flex !important;
  justify-content: center !important;
  text-align: center !important;
  transition:
    background 0.2s,
    color 0.2s;
}

.tt-mv-arrow:hover,
button.tt-mv-arrow:focus-visible,
button.tt-mv-arrow:focus {
  background: var(--tt-accent) !important;
  color: #fff !important;
}

.tt-mv-arrow:focus-visible {
  outline: 2px solid var(--tt-primary);
  outline-offset: 2px;
}

.tt-mv-prev {
  left: 10px;
}

.tt-mv-next {
  right: 10px;
}

/* ==========================================================================
   3. 媒体区：缩略图条
   —— 用 6 等分网格：正好 6 个时铺满整行，与上方主视图左右对齐；
      少于 6 个时尺寸保持一致（不会变大），因此永远不会出现横向滚动条。
   ========================================================================== */
.tt-mv-thumbs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tt-mv-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0 !important;
  border: 2px solid transparent !important;
  border-radius: 6px !important;
  overflow: hidden;
  background: #f2f2f2;
  cursor: pointer;
  transition:
    border-color 0.2s,
    opacity 0.2s;
  opacity: 0.6;
}

/* 缩略图内的图片与视频首帧统一按 1:1 裁切填满 */
.tt-mv-thumb img,
.tt-mv-thumb-video {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.tt-mv-thumb-video {
  pointer-events: none;
}

.tt-mv-thumb:hover {
  background-color: var(--tt-accent) !important;
  opacity: 1;
}

/* 当前选中的缩略图高亮 */
.tt-mv-thumb.is-active {
  border-color: var(--tt-accent) !important;
  opacity: 1;
}

.tt-mv-thumb:focus-visible {
  outline: 2px solid var(--tt-primary);
  outline-offset: 2px;
}

/* 视频缩略图右下角的播放角标 */
.tt-mv-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
}

.tt-mv-badge::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent #fff;
}

@media (max-width: 767px) {
  /* 缩略图仍走 6 等分网格，这里只收紧间距，避免挤压与滚动条 */
  .tt-mv-thumbs {
    gap: 6px;
    margin-top: 10px;
  }
  .tt-mv-arrow {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .tt-mv-prev {
    left: 6px;
  }
  .tt-mv-next {
    right: 6px;
  }
}

/* ==========================================================================
   4. 信息区（默认只输出产品描述，标题由 show_title="yes" 打开）
   ========================================================================== */
.tt-pd-title {
  margin: 0 0 16px;
  font-size: 1.9rem;
  line-height: 1.25;
  color: var(--tt-primary);
}

.tt-pd-desc {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #747474;
}

.tt-pd-desc p {
  margin: 0 0 1em;
}

.tt-pd-desc p:last-child {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .tt-pd-desc {
    font-size: 0.8rem;
  }
  .tt-pd-title {
    font-size: 1.5rem;
  }
}

/* ==========================================================================
   5. 工具类
   ========================================================================== */
.tt-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .tt-mv-item,
  .tt-mv-thumb,
  .tt-mv-arrow {
    transition: none;
  }
}
