/* ==========================================================================
   mystery-box.css — the hidden-puzzle Mystery Box game (storefront).
   Loaded with /src/js/mystery-box.js; every node is created by that script,
   so a page with the game switched off renders exactly as before.
   ========================================================================== */

/* ---------- floating entry button ---------------------------------------- */
#smbBtn {
  position: fixed;
  left: 18px;
  bottom: 20px;
  z-index: 1150;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #4f46e5 0%, #9333ea 55%, #db2777 100%);
  color: #fff;
  box-shadow: 0 12px 30px rgba(79, 70, 229, .4), 0 3px 10px rgba(0, 0, 0, .2);
  animation: smbFloat 3s ease-in-out infinite;
  transition: transform .18s ease, box-shadow .18s ease;
}
#smbBtn:hover { transform: translateY(-3px) scale(1.05); }
#smbBtn .smb-lock { animation: smbWiggle 2.6s ease-in-out infinite; }
#smbBtn .smb-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f59e0b;
  color: #422006;
  font-size: 10.5px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
#smbBtn.smb-pos-bottom-right { left: auto; right: 18px; }
#smbBtn.smb-done { background: linear-gradient(150deg, #059669, #10b981); }

@keyframes smbFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes smbWiggle {
  0%, 80%, 100% { transform: rotate(0); }
  85% { transform: rotate(-14deg); }
  90% { transform: rotate(12deg); }
  95% { transform: rotate(-6deg); }
}

/* ---------- modal -------------------------------------------------------- */
#smbModal {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, .66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#smbModal.smb-open { display: flex; animation: smbFade .22s ease both; }
@keyframes smbFade { from { opacity: 0; } to { opacity: 1; } }

.smb-card {
  position: relative;
  width: min(520px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 24px 20px 20px;
  border-radius: 22px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 34px 90px rgba(2, 6, 23, .5);
  animation: smbPop .4s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes smbPop {
  0% { transform: scale(.86) translateY(16px); opacity: 0; }
  70% { transform: scale(1.015) translateY(-2px); opacity: 1; }
  100% { transform: none; }
}
html[data-sd-theme="on"] .smb-card {
  background: var(--sd-surface, #fff);
  color: var(--sd-text, #0f172a);
}

.smb-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(15, 23, 42, .08);
  color: #334155;
  font-size: 16px;
}
.smb-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding-right: 34px; }
.smb-art {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ede9fe, #fce7f3);
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, .14);
  animation: smbWiggle 3s ease-in-out infinite;
}
.smb-title { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: -.2px; }
.smb-sub { margin: 2px 0 0; font-size: 12px; color: #64748b; }
html[data-sd-theme="on"] .smb-sub { color: color-mix(in srgb, var(--sd-text, #0f172a) 62%, transparent); }

.smb-progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .3);
  overflow: hidden;
  margin: 12px 0 4px;
}
.smb-progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
  transition: width .5s cubic-bezier(.22, 1, .36, 1);
}
.smb-progress-label { font-size: 11px; color: #64748b; margin: 0 0 12px; }

/* ---------- puzzle list -------------------------------------------------- */
.smb-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.smb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 13px;
  background: rgba(148, 163, 184, .07);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.smb-item:hover { border-color: #a855f7; background: rgba(168, 85, 247, .08); transform: translateX(2px); }
.smb-item.smb-solved { border-color: rgba(16, 185, 129, .5); background: rgba(16, 185, 129, .09); }
.smb-item.smb-current { border-color: #6366f1; background: rgba(99, 102, 241, .1); }
.smb-num {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900;
  background: #e2e8f0; color: #334155;
}
.smb-item.smb-solved .smb-num { background: #10b981; color: #fff; }
.smb-item-main { flex: 1; min-width: 0; }
.smb-item-title { font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smb-item-meta { font-size: 10.5px; color: #64748b; margin-top: 2px; }
.smb-style {
  font-size: 9.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .4px;
  padding: 3px 7px; border-radius: 999px;
  background: rgba(99, 102, 241, .14); color: #4338ca;
}
.smb-item.smb-solved .smb-style { background: rgba(16, 185, 129, .16); color: #047857; }

/* ---------- single puzzle view ------------------------------------------- */
.smb-question {
  margin: 6px 0 12px;
  font-size: 14.5px;
  line-height: 1.6;
  font-weight: 700;
}
.smb-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.smb-opt {
  padding: 11px 13px;
  border: 1.5px solid rgba(148, 163, 184, .45);
  border-radius: 12px;
  background: rgba(255, 255, 255, .7);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: inherit;
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.smb-opt:hover { border-color: #a855f7; }
.smb-opt.smb-picked { border-color: #6366f1; background: rgba(99, 102, 241, .12); }
html[data-sd-theme="on"] .smb-opt { background: color-mix(in srgb, var(--sd-surface, #fff) 88%, var(--sd-text, #0f172a)); }

.smb-input {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid rgba(148, 163, 184, .45);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: inherit;
  background: rgba(255, 255, 255, .85);
  margin-bottom: 12px;
}
.smb-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
html[data-sd-theme="on"] .smb-input { background: color-mix(in srgb, var(--sd-surface, #fff) 92%, var(--sd-text, #0f172a)); }

.smb-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.smb-go {
  flex: 1;
  min-width: 150px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  /* brand-aware: themed palettes get the admin's primary + measured ink,
     unthemed pages keep the original indigo gradient */
  color: var(--sd-on-primary, #fff);
  background: var(--sd-primary, linear-gradient(135deg, #6366f1, #a855f7));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--sd-primary, #6366f1) 32%, transparent);
}
.smb-go:disabled { opacity: .6; cursor: wait; }
.smb-ghost {
  padding: 12px 16px;
  border: 1.5px solid rgba(148, 163, 184, .5);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #475569;
  background: transparent;
}
.smb-ghost:hover { border-color: #f59e0b; color: #b45309; }

.smb-hint {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .4);
  font-size: 12.5px;
  line-height: 1.55;
  color: #92400e;
  animation: smbFade .25s ease both;
}
html[data-sd-theme="on"] .smb-hint { color: #b45309; }
.smb-hint b { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }

.smb-feedback {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  animation: smbFade .2s ease both;
}
.smb-feedback.smb-bad { background: rgba(239, 68, 68, .12); color: #b91c1c; border: 1px solid rgba(239, 68, 68, .35); }
.smb-feedback.smb-good { background: rgba(16, 185, 129, .13); color: #047857; border: 1px solid rgba(16, 185, 129, .4); }

/* ---------- family help + entry screen ----------------------------------- */
.smb-help {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  text-decoration: none;
  color: #116b43;
  background: rgba(37, 211, 102, .16);
  border: 1px solid rgba(37, 211, 102, .5);
}
.smb-help:hover { background: rgba(37, 211, 102, .28); }
.smb-note { margin-top: 12px; font-size: 10.5px; color: #94a3b8; line-height: 1.5; text-align: center; }
.smb-login {
  display: inline-flex;
  padding: 11px 20px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 900;
  text-decoration: none;
  color: #fff;
  background: #2563eb;
}
.smb-center { text-align: center; padding: 8px 0 4px; }
.smb-center p { font-size: 13px; line-height: 1.6; color: #475569; }
html[data-sd-theme="on"] .smb-center p { color: color-mix(in srgb, var(--sd-text, #0f172a) 72%, transparent); }

/* ---------- family co-op banner + share panel ---------------------------- */
.smb-family-bar {
  margin: 8px 0 10px;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  font-weight: 600;
  color: #14532d;
  background: rgba(37, 211, 102, .12);
  border: 1px solid rgba(37, 211, 102, .45);
  animation: smbFade .3s ease both;
}
html[data-sd-theme="on"] .smb-family-bar { color: #166534; }
.smb-share {
  margin-top: 10px;
  padding: 12px 13px;
  border-radius: 13px;
  background: rgba(99, 102, 241, .07);
  border: 1px solid rgba(99, 102, 241, .3);
  animation: smbFade .25s ease both;
}
.smb-share-lead { margin: 0 0 9px; font-size: 12.5px; line-height: 1.5; color: #475569; text-align: left; }
html[data-sd-theme="on"] .smb-share-lead { color: color-mix(in srgb, var(--sd-text, #0f172a) 72%, transparent); }
.smb-share-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.smb-share-url {
  flex: 1;
  min-width: 170px;
  padding: 10px 12px;
  border: 1.5px solid rgba(148, 163, 184, .45);
  border-radius: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  background: rgba(255, 255, 255, .85);
}
.smb-share-url:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
.smb-share .smb-ghost { padding: 10px 14px; }

/* ---------- win screen --------------------------------------------------- */
.smb-win { text-align: center; animation: smbFade .3s ease both; }
.smb-win-art {
  width: 108px; height: 108px;
  margin: 4px auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fef3c7, #fde68a 60%, #fbbf24);
  box-shadow: 0 18px 40px rgba(245, 158, 11, .45);
  animation: smbWinBounce .8s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes smbWinBounce {
  0% { transform: scale(.3) rotate(-25deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.smb-win h3 { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.smb-win p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: #475569; }
.smb-coin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 900;
  color: #92400e;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .5);
  margin-bottom: 12px;
}
.smb-solved-msg {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(16, 185, 129, .16);
  color: #047857;
  font-size: 12.5px;
  font-weight: 900;
  margin-bottom: 12px;
  animation: smbPop .5s cubic-bezier(.22, 1, .36, 1) both;
}

/* ---------- cross-page hint chip ----------------------------------------- */
#smbHintChip {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 1140;
  max-width: min(430px, 92vw);
  display: none;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, .5);
  background: rgba(255, 251, 235, .96);
  color: #92400e;
  box-shadow: 0 14px 34px rgba(245, 158, 11, .3);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  line-height: 1.45;
  animation: smbChipIn .45s cubic-bezier(.22, 1, .36, 1) both;
}
#smbHintChip.smb-show { display: flex; }
#smbHintChip .smb-bulb { font-size: 17px; flex-shrink: 0; }
#smbHintChip .smb-x {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: rgba(146, 64, 14, .15);
  color: #92400e;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
@keyframes smbChipIn { from { opacity: 0; transform: translate(-50%, 22px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- win particles ------------------------------------------------ */
#smbParticles { position: fixed; inset: 0; z-index: 3300; pointer-events: none; overflow: hidden; }
.smb-particle {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 15px;
  border-radius: 2px;
  animation: smbFall linear forwards;
}
@keyframes smbFall {
  0% { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--smb-x, 40px), 108vh, 0) rotate(760deg); opacity: .1; }
}

/* ---------- theme contrast (Round 32) --------------------------------------
   When the admin publishes a DARK or tinted surface, the fixed slate greys
   below stop passing AA — every muted label follows the measured --sd-muted
   and neutral chrome follows the corrected text colour instead. State rules
   (solved/current/hover) keep their own specificity above these. */
html[data-sd-theme="on"] .smb-progress-label,
html[data-sd-theme="on"] .smb-item-meta { color: var(--sd-muted); }
html[data-sd-theme="on"] .smb-ghost {
  color: color-mix(in srgb, var(--sd-text, #0f172a) 74%, transparent);
  border-color: color-mix(in srgb, var(--sd-text, #0f172a) 34%, transparent);
}
html[data-sd-theme="on"] .smb-ghost:hover { color: var(--sd-text); border-color: var(--sd-accent); }
html[data-sd-theme="on"] .smb-num { background: var(--sd-soft); color: var(--sd-text); }
html[data-sd-theme="on"] .smb-item { border-color: color-mix(in srgb, var(--sd-text, #0f172a) 24%, transparent); }
html[data-sd-theme="on"] .smb-input,
html[data-sd-theme="on"] .smb-share-url { background: var(--sd-surface); color: var(--sd-text); }

/* ---------- small screens ------------------------------------------------ */
@media (max-width: 640px) {
  #smbBtn { left: 12px; bottom: 74px; width: 48px; height: 48px; font-size: 21px; }
  #smbBtn.smb-pos-bottom-right { right: 12px; left: auto; }
  .smb-card { padding: 20px 15px 16px; border-radius: 18px; }
  #smbHintChip { bottom: 74px; font-size: 12px; padding: 9px 13px; }
  .smb-actions { flex-direction: column; align-items: stretch; }
  .smb-go, .smb-ghost { width: 100%; }
  .smb-share-row { flex-direction: column; align-items: stretch; }
  .smb-share-url { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #smbBtn, #smbBtn .smb-lock, .smb-art, .smb-card, .smb-win-art, #smbHintChip { animation: none !important; }
}
