/* ═══════════════════════════════════════════════
   Chinese Medicine Formula Quiz — Plugin Styles
   All rules scoped to .cmq-wrap to avoid
   conflicts with the active WordPress theme.
   Dynamically-injected overlays use .cmq- prefix.
   ═══════════════════════════════════════════════ */

/* ── Wrapper ── */
.cmq-wrap {

  color: #3d2b1f;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  box-sizing: border-box;
  direction: ltr;          /* formula names are LTR */
}

.cmq-wrap *, .cmq-wrap *::before, .cmq-wrap *::after {
  box-sizing: border-box;
}

/* ── Title ── */
.cmq-wrap .cmq-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #11221C;
  text-align: center;
  margin: 0 0 12px;
  padding: 0;
  border: none;
  background: none;
  line-height: 1.4;
}

/* ── Progress bar ── */
.cmq-wrap .cmq-progress-track {
  width: 100%;
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
  height: 8px;
  margin-bottom: 4px;
  overflow: hidden;
}
.cmq-wrap .cmq-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c0392b, #d4a017);
  border-radius: 10px;
  transition: width 0.5s ease;
}
.cmq-wrap .cmq-progress-label {
  font-size: 0.82rem;
  color: #999;
  text-align: center;
  margin: 0 0 18px;
  padding: 0;
}

/* ── Formula card ── */
.cmq-wrap .cmq-formula-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px 28px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1);
  margin-bottom: 22px;
  border-top: 4px solid #11221C;
  position: relative;
  overflow: hidden;
}
.cmq-wrap .cmq-formula-card::before {
  content: '方';
  position: absolute;
  top: -8px; right: 12px;
  font-size: 5rem;
  color: rgba(192,57,43,0.06);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.cmq-wrap .cmq-formula-name {
  font-size: 1.7rem;
  font-weight: 700;
  color: #11221C;
  margin-bottom: 4px;
  line-height: 1.2;
}
.cmq-wrap .cmq-formula-chinese {
  font-size: 1.3rem;
  color: #11221C;
  margin-bottom: 10px;
  letter-spacing: 3px;
}
.cmq-wrap .cmq-formula-indication {
  font-size: 0.9rem;
  color: #2e7d32;
  background: #f1f8f1;
  padding: 5px 14px;
  border-radius: 20px;
  display: inline-block;
  direction: rtl;
}

/* ── Slots ── */
.cmq-wrap .cmq-slots-section {
  margin-bottom: 18px;
}
.cmq-wrap .cmq-section-label {
  font-size: 0.82rem;
  color: #aaa;
  text-align: center;
  margin: 0 0 10px;
  padding: 0;
  direction: rtl;
}
.cmq-wrap .cmq-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.cmq-wrap .cmq-slot {
  width: 138px;
  height: 52px;
  border: 2px dashed #027E7F;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  color: #ccc;
  cursor: default;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: center;
  padding: 4px 6px;
  line-height: 1.25;
  margin: 0;
}
.cmq-wrap .cmq-slot.cmq-drag-over {
  border-color: #c0392b;
  background: rgba(192,57,43,0.06);
  transform: scale(1.04);
}
.cmq-wrap .cmq-slot.cmq-filled {
  border: 2px solid #27ae60;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  color: #1b5e20;
  font-weight: 600;
  animation: cmqPopIn 0.3s ease;
}
.cmq-wrap .cmq-slot.cmq-revealed {
  border: 2px solid #027E7F;
  background: linear-gradient(135deg, #BFD9CF, #BFD9CF);
  color: #11221C;
  font-weight: 600;
}
.cmq-wrap .cmq-slot.cmq-wrong-flash,
.cmq-wrap .cmq-herb-btn.cmq-wrong-flash {
  border-color: #027E7F !important;
  background: rgba(231,76,60,0.08) !important;
  animation: cmqShake 0.4s ease !important;
}

/* ── Controls ── */
.cmq-wrap .cmq-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.cmq-wrap .cmq-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  direction: rtl;
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
  box-shadow: none;
}
.cmq-wrap .cmq-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(0,0,0,0.18);
}
.cmq-wrap .cmq-btn:active:not(:disabled) { transform: translateY(0); }
.cmq-wrap .cmq-btn:disabled              { opacity: 0.45; cursor: not-allowed; }

.cmq-wrap .cmq-btn-lifeline { background: linear-gradient(135deg,#027E7F,#027E7F); color: #fff; }
.cmq-wrap .cmq-btn-giveup   { background: linear-gradient(135deg,#7f8c8d,#95a5a6); color: #fff; }
.cmq-wrap .cmq-btn-next     {
  background: linear-gradient(135deg,#27ae60,#2ecc71); color: #fff;
  animation: cmqFadeIn 0.4s ease;
}

/* ── Herb bank ── */
.cmq-wrap .cmq-bank-wrap { width: 100%; }
.cmq-wrap .cmq-herb-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
  padding: 18px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  min-height: 72px;
  align-items: center;
}
.cmq-wrap .cmq-herb-btn {
  padding: 8px 16px;
  border: 2px solid #027E7F;
  border-radius: 25px;
  background: #fff;
  color: #11221C;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.18s, color 0.18s, transform 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.4;
  margin: 0;
}
.cmq-wrap .cmq-herb-btn:hover {
  background: #BFD9CF;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgb(2, 126, 127,0.3);
}
.cmq-wrap .cmq-herb-btn:active { transform: translateY(0); }
.cmq-wrap .cmq-herb-btn.cmq-hint {
  border-color: #027E7F;
  background: #BFD9CF;
  color: #027E7F;
  animation: cmqGlow 1.4s ease-in-out infinite;
}

/* ── Keyframes ── */
@keyframes cmqPopIn {
  0%  { transform: scale(0.55); opacity: 0; }
  70% { transform: scale(1.08); }
  100%{ transform: scale(1);    opacity: 1; }
}
@keyframes cmqShake {
  0%,100%{ transform: translateX(0);  }
  20%    { transform: translateX(-7px); }
  40%    { transform: translateX(7px);  }
  60%    { transform: translateX(-4px); }
  80%    { transform: translateX(4px);  }
}
@keyframes cmqFadeIn {
  from { opacity:0; transform: scale(0.85); }
  to   { opacity:1; transform: scale(1);    }
}
@keyframes cmqGlow {
  0%,100%{ box-shadow: 0 0 0 3px rgba(243,156,18,0.35); }
  50%    { box-shadow: 0 0 0 7px rgba(243,156,18,0.08); }
}
@keyframes cmqFlashAnim {
  0%  { transform: translate(-50%,-50%) scale(0);   opacity: 0; }
  15% { transform: translate(-50%,-50%) scale(1.05);opacity: 1; }
  30% { transform: translate(-50%,-50%) scale(1);   }
  70% { transform: translate(-50%,-50%) scale(1);   opacity: 1; }
  100%{ transform: translate(-50%,-58%) scale(0.9); opacity: 0; }
}

/* ── Formula-complete flash (appended to body) ── */
.cmq-complete-flash {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0);
  color: #fff;
  padding: 18px 36px;
  border-radius: 50px;
  font-size: 1.3rem;
  font-weight: 700;
  z-index: 99999;
  pointer-events: none;
  animation: cmqFlashAnim 2s ease forwards;
  direction: rtl;
  text-align: center;
  box-shadow: 0 8px 30px rgba(39,174,96,0.5);
  font-family: 'Segoe UI', Tahoma, sans-serif;
}

/* ── End-game overlay (appended to body) ── */
.cmq-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}
.cmq-end-card {
  background: #fff;
  border-radius: 20px;
  padding: 38px 36px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  direction: rtl;
  color: #11221C;
}
.cmq-end-emoji  { font-size: 3.2rem; margin-bottom: 12px; }
.cmq-end-title  { font-size: 1.7rem; font-weight: 700; color: #11221C; margin-bottom: 8px; }
.cmq-end-sub    { color: #888; margin-bottom: 18px; font-size: 0.95rem; }
.cmq-end-hr     { border: none; border-top: 1px solid #eee; margin: 14px 0; }
.cmq-score-row  {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 9px 0;
}
.cmq-score-lbl  { color: #777; font-size: 0.92rem; }
.cmq-score-val  { font-weight: 700; font-size: 1.05rem; }
.cmq-end-card .cmq-btn-restart {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg,#027E7F,#027E7F);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.cmq-end-card .cmq-btn-restart:hover {
  opacity: 0.9;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .cmq-wrap .cmq-formula-name    { font-size: 1.2rem;  }
  .cmq-wrap .cmq-formula-chinese { font-size: 1rem;    }
  .cmq-wrap .cmq-slot            { width: 112px; height: 46px; font-size: 0.72rem; }
  .cmq-wrap .cmq-herb-btn        { font-size: 0.78rem; padding: 6px 11px; }
  .cmq-wrap .cmq-btn             { font-size: 0.84rem; padding: 9px 15px; }
}
