:root{
  --cx-gold:#d4af37;

  /* 透镜尺寸：自适应（不再手动调 px） */
  --cx-lens: clamp(120px, 18vw, 200px);

  /* XRAY 最大宽度（默认交给 .media，不限死） */
  --cx-max: 1100px;

  /* 统一圆角（只在顶部用） */
  --cx-radius: 20px;
}

/* ===============================
   XRAY BASE
================================ */

.codex-xray{
  width:100%;
  max-width:var(--cx-max);
  margin:0;
  padding:0;
  box-sizing:border-box;
  position:relative;
}

/* viewer：不做“卡片”，像原生图片 */
.codex-xray__viewer{
  position:relative;
  width:100%;
  aspect-ratio:16 / 9;     /* ✅ 和你站内产品图一致 */
  overflow:hidden;

  background:transparent;
  border:none;
  box-shadow:none;

  touch-action:none;
  cursor:crosshair;
  user-select:none;
  -webkit-user-select:none;
  -webkit-user-drag:none;
}

/* ===============================
   IMAGE LAYERS
================================ */

.codex-xray__layer{
  position:absolute;
  inset:0;
  pointer-events:none;

  /* ✅ 铺满裁切，和 <img> 行为一致 */
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
}

.codex-xray__layer--package{ z-index:1; }
.codex-xray__layer--inside{
  z-index:2;
  clip-path:circle(0px at 0px 0px);
  will-change:clip-path;
}

/* ===============================
   LENS
================================ */

.codex-xray__lens{
  position:absolute;
  top:0; left:0;

  width:var(--cx-lens);
  height:var(--cx-lens);

  border:2px solid var(--cx-gold);
  border-radius:50%;
  box-shadow:
    0 0 40px rgba(0,0,0,0.85),
    inset 0 0 18px rgba(212,175,55,0.25);

  z-index:3;
  pointer-events:none;
  display:none;

  margin-left:calc(var(--cx-lens) / -2);
  margin-top:calc(var(--cx-lens) / -2);

  will-change:transform;
}

/* ===============================
   LOADER
================================ */

.codex-xray__loader{
  position:absolute;
  inset:0;
  z-index:20;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;

  background:rgba(10,10,10,0.35);
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);

  font-size:11px;
  letter-spacing:3px;
  color:var(--cx-gold);
  text-transform:uppercase;
  text-align:center;
  padding:18px;
  box-sizing:border-box;

  transition:opacity .5s ease;
}

.codex-xray__loader small{
  color:#666;
  letter-spacing:.5px;
  text-transform:none;
  font-size:12px;
  line-height:1.35;
  max-width:36ch;
}

.codex-xray.is-ready .codex-xray__loader{
  opacity:0;
  pointer-events:none;
}

/* ===============================
   INFO (media 中默认隐藏)
================================ */

.codex-xray__info{
  text-align:center;
  margin-top:24px;
  pointer-events:none;
}

.media .codex-xray__info{
  display:none;
}

/* ===============================
   MEDIA CONTEXT (最关键)
================================ */

/* 跟 .media 图片完全一致 */
.media .codex-xray{
  width:100%;
  max-width:none;
}

/* 只保留【上圆角】，底部直角 */
.media .codex-xray__viewer{
  border-radius: var(--cx-radius) var(--cx-radius) 0 0;
}

/* 确保图层不偷偷带圆角 */
.media .codex-xray__layer{
  border-radius:0;
}

/* ===============================
   ACCESSIBILITY
================================ */

@media (prefers-reduced-motion: reduce){
  .codex-xray__loader{ transition:none; }
}

/* ===== XRAY lens size (final) ===== */
:root{
  --cx-lens: 260px;   /* 手机 */
}

@media (min-width: 640px){
  :root{
    --cx-lens: 360px; /* 平板 */
  }
}

@media (min-width: 1024px){
  :root{
    --cx-lens: 500px; /* 网页 */
  }
}
