/* Font chữ thân thiện, dễ đọc cho học sinh lớp 1 */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap');

:root {
  --primary: #3b82f6;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg-pattern: radial-gradient(#e0f2fe 1.5px, transparent 1.5px);
}

body {
  font-family: 'Nunito', 'Segoe UI', Roboto, sans-serif;
  background-color: #f0f9ff;
  background-image: var(--bg-pattern);
  background-size: 24px 24px;
  color: #1e293b;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

/* Tối ưu cho iPhone/iPad: không bị tự động phóng to khi bấm vào ô nhập liệu */
input, select, button {
  touch-action: manipulation;
}
input[type="text"], select {
  font-size: 16px;
}

/* Kích thước nút tối thiểu chuẩn cảm ứng Apple HIG (44px) */
button, .option-card, .match-item {
  min-height: 44px;
}

/* Hiệu ứng nổi bật cho thẻ bài tập */
.card-shadow {
  box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.12), 0 8px 10px -6px rgba(59, 130, 246, 0.08);
}

/* Nút bấm 3D thân thiện với bé */
.btn-3d {
  transition: all 0.15s ease;
  border-bottom-width: 4px;
}
.btn-3d:active:not(:disabled) {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

/* Thẻ đáp án trắc nghiệm */
.option-card {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid #e2e8f0;
  border-bottom-width: 4px;
}
.option-card:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: #60a5fa;
  background-color: #eff6ff;
}
.option-card.selected {
  border-color: #3b82f6;
  background-color: #dbeafe;
  color: #1d4ed8;
}
.option-card.correct {
  border-color: #10b981 !important;
  background-color: #d1fae5 !important;
  color: #065f46 !important;
}
.option-card.wrong {
  border-color: #ef4444 !important;
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  animation: shake 0.4s ease-in-out;
}

/* Thẻ ghép đôi (Match) */
.match-item {
  transition: all 0.15s ease;
  cursor: pointer;
}
.match-item.active {
  border-color: #f59e0b;
  background-color: #fef3c7;
  transform: scale(1.02);
}
.match-item.matched {
  border-color: #10b981;
  background-color: #d1fae5;
  color: #065f46;
  opacity: 0.85;
}

/* Thẻ sắp xếp từ/số (Order) */
.order-chip {
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
}
.order-chip:hover {
  transform: translateY(-2px);
}

/* Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.92) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.animate-pop {
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* Custom scrollbar cho danh sách tuần */
.custom-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 99px;
}
.custom-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Tooltip Hướng dẫn làm bài (Hover trên PC + Chạm trên iPhone/iPad) */
.guide-wrapper {
  position: relative;
  display: inline-block;
}
.guide-tooltip {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 290px;
  max-width: 82vw;
  z-index: 40;
}
.guide-wrapper:hover .guide-tooltip,
.guide-wrapper.open .guide-tooltip {
  display: block;
  animation: popIn 0.2s ease forwards;
}

/* CHẾ ĐỘ IN PHIẾU BÀI TẬP (PRINT WORKSHEET) */
@media print {
  body {
    background: #ffffff !important;
    background-image: none !important;
    color: #000000 !important;
  }
  .no-print {
    display: none !important;
  }
  .print-only {
    display: block !important;
  }
  .print-page {
    padding: 0;
    margin: 0;
    box-shadow: none !important;
  }
  .print-question {
    page-break-inside: avoid;
    border: 1px solid #cbd5e1;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
  }
}
.print-only {
  display: none;
}

/* TỐI ƯU HIỂN THỊ FULL MÀN HÌNH KHI LÀM BÀI (ĐẶC BIỆT TRÊN IPAD) */
body.quiz-focus-mode #app-main {
  max-width: 100%;
  padding-top: 0.75rem;
  padding-bottom: 1.5rem;
}

body.device-ipad #quiz-screen {
  max-width: 100%;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

body.device-ipad .option-btn {
  min-height: 52px;
  font-size: 1.05rem;
}

body.device-ipad .numpad-btn {
  min-height: 50px;
  font-size: 1.15rem;
}
