/* ============================================================
 * 全站广告位 / 小程序浮窗组件
 *
 * 包含 4 个位置(由后端 Advertisement 表 position 字段决定):
 *   - list_aside            列表页侧栏
 *   - score_sidebar         详情页侧栏
 *   - global_float_pc       PC 全站浮窗
 *   - global_float_mobile   手机端底部条幅
 *
 * 通用规则:
 *   - 数据来源: GET /api/advertisements?position=xxx
 *   - 关闭按钮(浮窗/条幅): localStorage 存 7 天,过期复活
 *   - 3 种 ad_type:
 *       image     → 渲染 <img>, link_url 有则 <a> 包裹
 *       mp_qrcode → 渲染 <img> + 长按识别提示
 *       link      → 渲染 <a>
 * ============================================================ */

/* ====== 侧栏通用 panel(复用 ys-aside-panel 风格) ====== */
.ys-ad-slot-panel {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.ys-ad-slot-panel .ys-ad-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ys-ad-slot-panel .ys-ad-title .ys-ad-tag {
  font-size: 10px;
  color: #999;
  background: #f5f5f5;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 400;
  margin-left: auto;
}
.ys-ad-slot-panel .ys-ad-body {
  font-size: 12px;
  color: #666;
  line-height: 1.6;
}

/* 图片广告 (侧栏) */
.ys-ad-image-wrap {
  display: block;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
  cursor: pointer;
}
.ys-ad-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: cover;
}
.ys-ad-image-wrap .ys-ad-subtitle {
  padding: 8px 10px;
  font-size: 12px;
  color: #555;
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
}

/* 小程序码 (侧栏) */
.ys-ad-qrcode-wrap {
  text-align: center;
  padding: 4px;
}
.ys-ad-qrcode-wrap img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
}
.ys-ad-qrcode-wrap .ys-ad-hint {
  margin-top: 8px;
  font-size: 11px;
  color: #999;
}

/* link (侧栏) */
.ys-ad-link-wrap {
  display: block;
  padding: 12px;
  background: linear-gradient(135deg, #1e9fff 0%, #2eb3ff 100%);
  color: #fff;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.15s;
}
.ys-ad-link-wrap:hover { transform: translateY(-1px); }
.ys-ad-link-wrap .ys-ad-link-text { font-weight: 600; }

/* ====== PC 浮窗 (2026-07-12 改:常驻展开二维码面板,不再 hover 弹窗) ====== */
.ys-mp-float-pc {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 999;
  display: none;
  /* 让 .ys-mp-close 用 absolute 定位时参考此容器 */
}
.ys-mp-float-pc .ys-mp-panel {
  position: relative;
  width: 200px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 16px 14px 14px;
  text-align: center;
  animation: ys-mp-fade-in 0.4s ease-out;
}
@keyframes ys-mp-fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ys-mp-float-pc .ys-mp-qrcode-wrap {
  width: 180px;
  height: 180px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.ys-mp-float-pc .ys-mp-qrcode-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ys-mp-float-pc .ys-mp-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}
.ys-mp-float-pc .ys-mp-panel-sub {
  font-size: 11px;
  color: #999;
  line-height: 1.5;
  padding: 0 4px;
  margin-bottom: 10px;
}
.ys-mp-float-pc .ys-mp-wx-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #07c160;
  color: #fff;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(7, 193, 96, 0.3);
}
.ys-mp-float-pc .ys-mp-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  color: #999;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: color 0.15s, background 0.15s, transform 0.15s;
}
.ys-mp-float-pc .ys-mp-close:hover {
  color: #fff;
  background: #ff4d4f;
  transform: scale(1.1);
}
.ys-mp-float-pc .ys-mp-close svg {
  display: block;
}

/* ====== 手机端中央悬浮卡片 (2026-07-12 改:跟 PC 一样常驻展开,放屏幕中央) ====== */
.ys-mp-float-mobile {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  display: none;
  /* 跟 .ys-mp-float-pc 一样, 让 .ys-mp-close absolute 定位参考此容器 */
}
.ys-mp-float-mobile .ys-mp-panel {
  position: relative;
  width: 300px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  padding: 18px 16px 16px;
  text-align: center;
  animation: ys-mp-fade-in 0.4s ease-out;
}
.ys-mp-float-mobile .ys-mp-qrcode-wrap {
  width: 240px;
  height: 240px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.ys-mp-float-mobile .ys-mp-qrcode-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ys-mp-float-mobile .ys-mp-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}
.ys-mp-float-mobile .ys-mp-panel-sub {
  font-size: 12px;
  color: #999;
  line-height: 1.5;
  padding: 0 4px;
  margin-bottom: 12px;
}
.ys-mp-float-mobile .ys-mp-wx-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #07c160;
  color: #fff;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(7, 193, 96, 0.3);
}
.ys-mp-float-mobile .ys-mp-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  color: #999;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: color 0.15s, background 0.15s, transform 0.15s;
}
.ys-mp-float-mobile .ys-mp-close:hover {
  color: #fff;
  background: #ff4d4f;
  transform: scale(1.1);
}
.ys-mp-float-mobile .ys-mp-close svg {
  display: block;
}

/* ====== 2026-07-12 新增: 点击二维码 → 弹引导 modal ====== */
.ys-mp-qr-guide {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ys-mp-fade-in 0.25s ease-out;
}
.ys-mp-qr-guide-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px 20px;
  width: 320px;
  max-width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: ys-mp-zoom-in 0.25s ease-out;
}
@keyframes ys-mp-zoom-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.ys-mp-qr-guide-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: #999;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: color 0.15s, background 0.15s, transform 0.15s;
}
.ys-mp-qr-guide-close:hover {
  color: #fff;
  background: #ff4d4f;
  transform: scale(1.1);
}
.ys-mp-qr-guide-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 16px;
}
.ys-mp-qr-guide-img {
  width: 260px;
  height: 260px;
  margin: 0 auto 16px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ys-mp-qr-guide-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* 提示用户可以长按 */
  -webkit-user-drag: auto;
  -webkit-touch-callout: default;
}
.ys-mp-qr-guide-hint {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
  padding: 0 8px;
  margin-bottom: 16px;
}
.ys-mp-qr-guide-hint b {
  color: #1e9fff;
  font-weight: 600;
}
.ys-mp-qr-guide-btn {
  background: #1e9fff;
  color: #fff;
  border: none;
  font-size: 14px;
  padding: 10px 32px;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.15s;
}
.ys-mp-qr-guide-btn:hover {
  background: #1789e6;
}

/* 触发器: 太阳码包 <a> 后, 让鼠标变手型 */
.ys-mp-qr-trigger {
  display: block;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

/* ====== 响应式:PC 显示右下角小卡片, 手机显示屏幕中央卡片 ====== */
@media (min-width: 768px) {
  .ys-mp-float-pc.is-visible    { display: block; }
  .ys-mp-float-mobile.is-visible { display: none;  }
}
@media (max-width: 767px) {
  .ys-mp-float-pc.is-visible    { display: none;  }
  .ys-mp-float-mobile.is-visible { display: block; }
}
