/*
 * MB Lottery (盲盒抽奖九宫格) - Frontend UI
 * Version: 1.2.0
 *
 * 视觉规范（按你的要求重构）：
 * - 主线条框：#0099FF
 * - 抽奖流动高亮框：#D4237A + 轻微发光（阴影实现）
 * - 清新蓝白、卡片式，但不做三四层“卡片套卡片”
 *
 * 技术策略：
 * - 全部样式严格作用域在 .mbl-lottery 下，降低与主题冲突。
 * - 对 WP / 主题常覆盖的 .button/.button-primary 使用更高优先级 + 少量 !important。
 */

/* =========================
   Root
   ========================= */
.mbl-lottery.mbl-lottery{
  --mbl-max-width: 420px;

  --mbl-line: #0099FF;
  --mbl-active: #D4237A;

  --mbl-text: #0b1b2b;
  --mbl-muted: rgba(11, 27, 43, 0.68);
  --mbl-muted-2: rgba(11, 27, 43, 0.52);

  --mbl-bg: #ffffff;

  --mbl-radius: 18px;
  --mbl-radius-sm: 14px;

  --mbl-shadow: 0 12px 30px rgba(0, 153, 255, 0.12);
  --mbl-shadow-sm: 0 6px 16px rgba(0, 153, 255, 0.10);
  --mbl-focus-ring: 0 0 0 4px rgba(0, 153, 255, 0.22);

  max-width: var(--mbl-max-width);
  margin: 22px auto;
  padding: 14px 14px 12px;

  border-radius: var(--mbl-radius);
  border: 1.5px solid var(--mbl-line);
  background: var(--mbl-bg);
  box-shadow: var(--mbl-shadow);

  color: var(--mbl-text);
  -webkit-text-size-adjust: 100%;
  isolation: isolate;
}

.mbl-lottery.mbl-lottery,
.mbl-lottery.mbl-lottery *{
  box-sizing: border-box;
}

.mbl-lottery.mbl-lottery img{
  max-width: 100%;
  height: auto;
}

.mbl-lottery.mbl-lottery [hidden]{
  display: none !important;
}

/* =========================
   Messages
   ========================= */
.mbl-lottery.mbl-lottery .mbl-msg{
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 12px;

  border-radius: var(--mbl-radius-sm);
  border: 1px solid var(--mbl-line);
  background: #fff;

  color: var(--mbl-text);
  font-size: 13px;
  line-height: 1.65;
}

.mbl-lottery.mbl-lottery .mbl-msg-notice{
  color: var(--mbl-text);
}

.mbl-lottery.mbl-lottery .mbl-msg-error{
  color: var(--mbl-active);
  font-weight: 700;
}

/* =========================
   Grid (no extra "card" wrapper)
   ========================= */
.mbl-lottery.mbl-lottery .mbl-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
}

/* =========================
   Cell
   ========================= */
.mbl-lottery.mbl-lottery .mbl-cell{
  position: relative;

  border-radius: var(--mbl-radius-sm);
  border: 1px solid var(--mbl-line);
  background: #fff;

  padding: 10px 8px 11px;
  min-height: 92px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  text-align: center;
  user-select: none;
  cursor: default;
  outline: none;

  box-shadow: var(--mbl-shadow-sm);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.mbl-lottery.mbl-lottery .mbl-cell:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 153, 255, 0.14);
}

.mbl-lottery.mbl-lottery .mbl-cell:focus-visible{
  outline: none;
  box-shadow: var(--mbl-focus-ring), 0 10px 22px rgba(0, 153, 255, 0.14);
}

.mbl-lottery.mbl-lottery .mbl-cell-empty{
  opacity: 0.56;
  filter: saturate(0.9);
}

.mbl-lottery.mbl-lottery .mbl-cell-empty:hover{
  transform: none;
  box-shadow: var(--mbl-shadow-sm);
}

/* Active highlight (spinning / selected)
   按你的要求：#D4237A 高亮框 + 阴影发光 */
.mbl-lottery.mbl-lottery .mbl-cell.mbl-active{
  border-color: var(--mbl-active) !important;
  transform: translateY(-1px);
  box-shadow:
    0 0 0 2px rgba(212, 35, 122, 0.22),
    0 0 18px rgba(212, 35, 122, 0.34),
    0 10px 22px rgba(0, 153, 255, 0.12);
}

.mbl-lottery.mbl-lottery .mbl-cell.mbl-active::after{
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 22px rgba(212, 35, 122, 0.30);
  opacity: 0.85;
  animation: mblGlow 0.95s ease-in-out infinite;
}

@keyframes mblGlow{
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* =========================
   Icon (no background / no border)
   ========================= */
.mbl-lottery.mbl-lottery .mbl-icon-wrap{
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.mbl-lottery.mbl-lottery .mbl-icon{
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.mbl-lottery.mbl-lottery .mbl-icon-fallback{
  font-size: 28px;
  line-height: 1;
}

/* =========================
   Prize name
   ========================= */
.mbl-lottery.mbl-lottery .mbl-prize-name{
  width: 100%;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12px;
  color: var(--mbl-text);
  opacity: 0.94;
  word-break: break-word;
  min-height: 32px;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.mbl-lottery.mbl-lottery .mbl-cell-empty .mbl-prize-name{
  color: var(--mbl-muted);
  font-weight: 650;
}

/* =========================
   Actions (no extra card, use a simple divider line)
   ========================= */
.mbl-lottery.mbl-lottery .mbl-actions{
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--mbl-line);

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

  text-align: center;
}

.mbl-lottery.mbl-lottery .mbl-banner{
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--mbl-radius-sm);
  border: 1px solid var(--mbl-line);
  background: #fff;

  color: var(--mbl-text);
  font-size: 13px;
  line-height: 1.55;
}

/* 轻提示（不再使用渐变/多重背景） */
.mbl-lottery.mbl-lottery .mbl-banner-info{
  color: var(--mbl-text);
}

.mbl-lottery.mbl-lottery .mbl-banner-warn{
  color: var(--mbl-active);
  font-weight: 700;
}

.mbl-lottery.mbl-lottery .mbl-status{
  min-height: 18px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--mbl-muted);
}

.mbl-lottery.mbl-lottery .mbl-status.mbl-status-error{
  color: var(--mbl-active);
  font-weight: 750;
}

.mbl-lottery.mbl-lottery .mbl-status.mbl-status-ok{
  color: var(--mbl-line);
  font-weight: 750;
}

/* =========================
   Buttons (raise priority + minimal !important)
   ========================= */
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start,
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open{
  appearance: none;
  -webkit-appearance: none;

  font: inherit !important;
  font-size: 13.5px !important;
  font-weight: 800 !important;
  letter-spacing: 0.2px;
  line-height: 1 !important;
  text-decoration: none !important;

  border-radius: 999px !important;
  padding: 10px 16px !important;
  min-width: 148px;

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

  cursor: pointer;
  user-select: none;

  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

/* Primary */
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open{
  background: var(--mbl-line) !important;
  border: 1px solid var(--mbl-line) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 22px rgba(0, 153, 255, 0.20) !important;
}

/* Secondary (outline) */
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct{
  background: #ffffff !important;
  border: 1.5px solid var(--mbl-line) !important;
  color: var(--mbl-line) !important;
  box-shadow: 0 8px 18px rgba(0, 153, 255, 0.12) !important;
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start:hover,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open:hover{
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 14px 28px rgba(0, 153, 255, 0.24) !important;
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct:hover{
  transform: translateY(-1px);
  filter: brightness(1.01);
  box-shadow: 0 12px 24px rgba(0, 153, 255, 0.18) !important;
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start:active,
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct:active,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open:active{
  transform: translateY(0);
  filter: brightness(0.99);
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start:focus-visible,
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct:focus-visible,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open:focus-visible{
  outline: none;
  box-shadow: var(--mbl-focus-ring), 0 14px 28px rgba(0, 153, 255, 0.18) !important;
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start:disabled,
.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct:disabled,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open:disabled{
  opacity: 0.56 !important;
  cursor: not-allowed !important;
  transform: none !important;
  filter: none !important;
  box-shadow: none !important;
}

/* Busy spinners */
.mbl-lottery.mbl-lottery.mbl-busy .mbl-actions .button.mbl-start::after,
.mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open[aria-busy="true"]::after{
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: rgba(255, 255, 255, 0.98);
  animation: mblSpin 0.9s linear infinite;
}

.mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct[aria-busy="true"]::after{
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(0, 153, 255, 0.25);
  border-top-color: rgba(0, 153, 255, 0.98);
  animation: mblSpin 0.9s linear infinite;
}

@keyframes mblSpin{
  to { transform: rotate(360deg); }
}

/* =========================
   Modal (fix: center in viewport)
   ========================= */
.mbl-lottery.mbl-lottery .mbl-modal{
  position: fixed;
  inset: 0;
  z-index: 999999;

  display: flex;
  align-items: center; /* ✅ 居中 */
  justify-content: center;
  padding: 16px;

  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.mbl-lottery.mbl-lottery .mbl-modal.is-open{
  opacity: 1;
  pointer-events: auto;
}

.mbl-lottery.mbl-lottery .mbl-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(11, 27, 43, 0.55);
  opacity: 0;
  transition: opacity 180ms ease;
}

.mbl-lottery.mbl-lottery .mbl-modal.is-open .mbl-modal-backdrop{
  opacity: 1;
}

.mbl-lottery.mbl-lottery .mbl-modal-panel{
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;

  border-radius: var(--mbl-radius);
  border: 1.5px solid var(--mbl-line);
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);

  padding: 18px 16px 16px;

  transform: translateY(12px) scale(0.985);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 220ms ease;
}

.mbl-lottery.mbl-lottery .mbl-modal.is-open .mbl-modal-panel{
  transform: translateY(0) scale(1);
  opacity: 1;
}

.mbl-lottery.mbl-lottery .mbl-modal-close{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 999px;

  border: 1px solid var(--mbl-line);
  background: #ffffff;

  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--mbl-text);
}

.mbl-lottery.mbl-lottery .mbl-modal-close:hover{
  filter: brightness(0.98);
}

.mbl-lottery.mbl-lottery .mbl-modal-close:focus-visible{
  outline: none;
  box-shadow: var(--mbl-focus-ring);
}

.mbl-lottery.mbl-lottery .mbl-modal-title{
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0.2px;
  margin: 0 0 12px;
}

.mbl-lottery.mbl-lottery .mbl-modal-prize-wrap{
  padding: 12px 12px;
  border-radius: var(--mbl-radius-sm);
  border: 1px solid var(--mbl-line);
  background: #ffffff;
}

.mbl-lottery.mbl-lottery .mbl-modal-prize-label{
  font-size: 13px;
  color: var(--mbl-muted);
  margin-bottom: 6px;
}

.mbl-lottery.mbl-lottery .mbl-modal-prize{
  font-size: 18px;
  font-weight: 900;
  color: var(--mbl-text);
  word-break: break-word;
}

.mbl-lottery.mbl-lottery .mbl-modal-actions{
  margin-top: 12px;
}

.mbl-lottery.mbl-lottery .mbl-modal-content{
  margin-top: 12px;
  padding: 12px;

  border-radius: var(--mbl-radius-sm);
  border: 1px solid var(--mbl-line);
  background: #ffffff;

  line-height: 1.75;
  color: var(--mbl-text);
  word-break: break-word;
}

/* Content typography (safe HTML) */
.mbl-lottery.mbl-lottery .mbl-modal-content > :first-child{ margin-top: 0; }
.mbl-lottery.mbl-lottery .mbl-modal-content > :last-child{ margin-bottom: 0; }

.mbl-lottery.mbl-lottery .mbl-modal-content p{ margin: 0.6em 0; }

.mbl-lottery.mbl-lottery .mbl-modal-content ul,
.mbl-lottery.mbl-lottery .mbl-modal-content ol{
  margin: 0.6em 0 0.6em 1.2em;
}

.mbl-lottery.mbl-lottery .mbl-modal-content li{ margin: 0.25em 0; }

.mbl-lottery.mbl-lottery .mbl-modal-content a{
  color: var(--mbl-line);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mbl-lottery.mbl-lottery .mbl-modal-content a:hover{ filter: brightness(0.98); }

.mbl-lottery.mbl-lottery .mbl-modal-content code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  padding: 0.12em 0.35em;
  border-radius: 10px;
  border: 1px solid var(--mbl-line);
  background: #ffffff;
}

.mbl-lottery.mbl-lottery .mbl-modal-content pre{
  overflow: auto;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--mbl-line);
  background: #ffffff;
}

.mbl-lottery.mbl-lottery .mbl-modal-content pre code{
  border: 0;
  padding: 0;
  background: transparent;
}

/* =========================
   Small screens
   ========================= */
@media (max-width: 380px){
  .mbl-lottery.mbl-lottery{
    padding: 12px;
    --mbl-max-width: 100%;
  }

  .mbl-lottery.mbl-lottery .mbl-grid{
    gap: 7px;
  }

  .mbl-lottery.mbl-lottery .mbl-cell{
    min-height: 88px;
    padding: 9px 7px 10px;
  }

  .mbl-lottery.mbl-lottery .mbl-actions .button.mbl-start,
  .mbl-lottery.mbl-lottery .mbl-actions .button.mbl-open-direct,
  .mbl-lottery.mbl-lottery .mbl-modal-actions .button.mbl-open{
    min-width: 132px;
  }
}
