@charset "UTF-8";
/* ==========================================================================
   7. 直式挑戰測驗模組樣式 (VERTICAL MATH QUIZ & CHALLENGE)
   ========================================================================== */

.calc-quiz-section{
  margin-top: 10px;
}

/* 難度與題型選擇列 */
.cq-diff-bar{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.cq-diff-label{
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}
.cq-diff-chips{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cq-diff-chip{
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.cq-diff-chip:hover{
  background: var(--surface-dim);
  transform: translateY(-1px);
}
.cq-diff-chip.active{
  background: var(--ink);
  color: var(--bg);
}

/* 題目標題與提示 */
.cq-prompt-row{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cq-badge{
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--surface-dim);
  color: var(--ink);
}
.cq-hint-text{
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* 直式作答筆記簿 (Vertical Math Quiz Notebook) */
.cq-board-container{
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 20px;
}
.cq-notebook{
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  padding: 22px 28px;
  box-shadow: 5px 5px 0 var(--shadow-ink);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  user-select: none;
}

.cq-table{
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: fit-content;
}

/* 行容器 */
.cq-row{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 48px;
}
.cq-row-header{
  height: 30px;
  margin-bottom: 2px;
}
.cq-row-mark{
  height: 32px;
}
.cq-row-ans{
  height: 60px;
  margin-top: 4px;
}

/* 單元格 (固定寬度確保垂直對齊) */
.cq-cell{
  width: 64px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: 38px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  flex-shrink: 0;
}
.cq-cell.cq-cell-op{
  width: 44px;
  font-size: 30px;
  font-weight: 900;
  color: var(--ink);
  flex-shrink: 0;
}

/* 運算分隔粗線 */
.cq-divider-line{
  width: 100%;
  height: 3.5px;
  background: var(--ink);
  border-radius: 999px;
  margin: 4px 0;
}

/* 進退位註記小格 (Marking Helpers) */
.cq-mark-slot{
  min-width: 32px;
  width: auto;
  max-width: 48px;
  height: 28px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1.5px dashed var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.cq-mark-slot:hover{
  border-color: var(--ink);
  background: var(--surface-dim);
}
.cq-mark-slot.active-mark{
  border-style: solid;
  border-color: #f39c12;
  background: #f39c12;
  color: #fff;
  box-shadow: 0 2px 6px rgba(243,156,18,.35);
}
.cq-mark-slot.borrow-mark{
  border-style: solid;
  border-color: var(--h-color-dark);
  background: var(--h-soft);
  color: var(--h-color-dark);
  box-shadow: 0 2px 5px rgba(184,91,53,.2);
}
.cq-mark-slot.rem-mark{
  border-style: solid;
  border-color: #f59e0b;
  background: #fef3c7;
  color: #b45309;
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.25);
  font-weight: 900;
}

/* 數字劃斜線與點擊借位 (Slash Borrowing) */
.cq-num-box{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  transition: all .2s ease;
  user-select: none;
}
.cq-num-box.can-borrow{
  cursor: pointer;
}
.cq-num-box.can-borrow:hover{
  background: rgba(0, 0, 0, 0.05);
}
.cq-num-box.is-slashed{
  color: #94a3b8 !important;
  transition: color .2s ease;
}
.cq-num-box.is-slashed::after{
  content: '';
  position: absolute;
  width: 115%;
  height: 3.5px;
  background: #ef4444;
  border-radius: 999px;
  top: 50%;
  left: -7%;
  transform: rotate(-35deg);
  transform-origin: center;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.45);
  pointer-events: none;
  animation: cqSlashIn .22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cqSlashIn{
  from{
    opacity: 0;
    transform: scaleX(0.1) rotate(-35deg);
  }
  to{
    opacity: 1;
    transform: scaleX(1) rotate(-35deg);
  }
}

.cq-input{
  width: 56px;
  height: 54px;
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
  -moz-appearance: textfield;
}
.cq-input::-webkit-outer-spin-button,
.cq-input::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
.cq-input:focus-visible{
  outline: 3px solid #2b6ef2;
  outline-offset: 1px;
}
.cq-input.is-active{
  border-color: #2b6ef2 !important;
  box-shadow: 0 0 0 4px rgba(43,110,242,.25), 3px 3px 0 var(--shadow-ink);
  transform: scale(1.08);
  background: #fff;
}
/* 分位專屬柔和底色 */
.cq-input.input-h{
  border-color: var(--h-color);
  background: var(--h-soft);
  color: var(--h-color-dark);
}
.cq-input.input-t{
  border-color: var(--t-color);
  background: var(--t-soft);
  color: var(--t-color-dark);
}
.cq-input.input-o{
  border-color: var(--o-color);
  background: var(--o-soft);
  color: var(--o-color-dark);
}
.cq-input.correct-field{
  background: #d4edda !important;
  border-color: #28a745 !important;
  color: #155724 !important;
}
.cq-input.error-field{
  background: #f8d7da !important;
  border-color: #dc3545 !important;
  color: #721c24 !important;
  animation: shakeX .35s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}

/* 劃線被借位效果 (Slashed) */
.cq-slashed{
  position: relative;
  display: inline-block;
  color: var(--ink-soft);
}
.cq-slashed::after{
  content: '';
  position: absolute;
  left: 10%;
  bottom: 12%;
  width: 80%;
  height: 3px;
  background: #e74c3c;
  transform: rotate(-35deg);
  border-radius: 999px;
}
.cq-sub-rem{
  position: absolute;
  top: -16px;
  right: -6px;
  font-size: 16px;
  font-weight: 900;
  color: #e74c3c;
}

/* 積木小幫手抽屜 (Visual Blocks Helper) */
.cq-helper-wrap{
  margin: 14px auto 0;
  max-width: 760px;
  width: 100%;
  text-align: center;
}
.cq-helper-drawer{
  background: var(--surface-dim);
  border: 2px dashed var(--ink);
  border-radius: 20px;
  padding: 18px 16px;
  margin-top: 12px;
  animation: panelFadeIn .25s ease-out;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.cq-helper-drawer.open{
  display: block;
}
.cq-helper-title{
  font-size: 15.5px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 14px;
}
.cq-helper-blocks{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.cq-helper-stage-row{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}
.cq-helper-num-card{
  flex: 1 1 260px;
  max-width: 340px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 3px 3px 0 var(--shadow-ink);
  text-align: center;
}
.cq-helper-num-title{
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.cq-helper-num-val{
  font-size: 16px;
  font-weight: 900;
  color: #2b6ef2;
}
.cq-helper-num-cols{
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.cq-helper-col-group{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 65px;
}
.cq-helper-col-tag{
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}
.cq-helper-col-tag.h-tag{
  background: var(--h-soft, #fef3c7);
  color: var(--h-color-dark, #b45309);
}
.cq-helper-col-tag.t-tag{
  background: var(--t-soft, #fed7aa);
  color: var(--t-color-dark, #c2410c);
}
.cq-helper-col-tag.o-tag{
  background: var(--o-soft, #e2e8f0);
  color: var(--o-color-dark, #334155);
}
.cq-helper-col-blocks{
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface-dim);
  border-radius: 8px;
  padding: 6px;
  width: 100%;
}
.cq-helper-empty{
  font-size: 12px;
  color: var(--ink-soft);
}
.cq-helper-op-badge{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 2px 2px 0 var(--shadow-ink);
  flex-shrink: 0;
}
.cq-helper-action-card{
  width: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(240,249,255,0.95) 100%);
  border: 2px solid #2b6ef2;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(43,110,242,0.1);
}
.cq-helper-action-header{
  font-size: 14px;
  font-weight: 900;
  color: #2b6ef2;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cq-helper-action-body{
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.6;
}
.cq-helper-action-visual{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.8);
  border-radius: 10px;
  border: 1px dashed rgba(43,110,242,0.4);
}
.cq-helper-transform-arrow{
  font-size: 13px;
  font-weight: 800;
  color: #2b6ef2;
  background: rgba(43,110,242,0.1);
  padding: 2px 8px;
  border-radius: 20px;
}

/* 詳解提示文字方塊 */
.cq-explanation-box{
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border-left: 4px solid #2b6ef2;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
}

/* 響應式微調 */
@media (max-width: 480px) {
  .cq-notebook{
    padding: 16px 12px;
  }
  .cq-cell{
    width: 48px;
    font-size: 30px;
  }
  .cq-cell.cq-cell-op{
    width: 34px;
    font-size: 24px;
  }
  .cq-mark-slot{
    min-width: 28px;
    height: 25px;
    font-size: 11.5px;
    padding: 0 3px;
  }
  .cq-input{
    width: 44px;
    height: 46px;
    font-size: 26px;
  }
  .cq-diff-chips{
    justify-content: center;
  }
}
