/* Modern Kid-Friendly Educational Theme for Grade 6 */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800&family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg-soft: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-family: 'Kanit', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background-color: #f1f5f9;
}

body {
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Print Only & Screen Only Logic */
.print-only {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Glassmorphism Navigation */
.nav-blur {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

/* Section Cards */
.learning-card {
  background: var(--card-bg);
  border-radius: 1.5rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.learning-card:hover {
  box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.08);
}

/* Factor Tree Branching Lines */
.tree-node-wrapper::after {
  content: '';
  position: absolute;
  bottom: -24px;
  width: 2px;
  height: 24px;
  background: #cbd5e1;
  display: none;
}

.tree-node-wrapper.has-children::after {
  display: block;
}

/* Game Canvas container */
.game-viewport {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 20px 30px -10px rgba(15, 23, 42, 0.3);
  background: #0f172a;
}

canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Math Division Table */
.division-bracket-table {
  display: inline-block;
  font-family: 'Courier New', Courier, monospace;
}

/* Badges & Pulsing */
.pulse-badge {
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
  }
}

/* Floating Action Button */
.floating-audio-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* ==========================================================
   PRINT / PDF EXPORT STYLES (A4 Official Document Layout)
   ========================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 14pt;
    line-height: 1.4;
  }

  /* Hide entire interactive web UI */
  header, nav, footer, .screen-only, .floating-audio-btn, #cert-modal,
  #game, #lab, #thinking, #pretest, #posttest, #summary-section, .hero-section {
    display: none !important;
  }

  /* Show only print content */
  .print-only {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-page {
    page-break-after: always;
    padding: 1.5cm 1.5cm;
    background: #ffffff;
  }

  .print-page:last-child {
    page-break-after: avoid;
  }

  .print-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    margin-bottom: 15px;
  }

  .print-title {
    font-size: 18pt;
    font-weight: bold;
    margin-bottom: 4px;
  }

  .print-sub {
    font-size: 14pt;
  }

  .student-box {
    border: 1px solid #333;
    padding: 8px 12px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 13pt;
  }

  .print-section-title {
    font-size: 15pt;
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 8px;
    background: #eee;
    padding: 4px 8px;
    border-left: 4px solid #000;
  }

  .print-item {
    margin-bottom: 12px;
    font-size: 13pt;
  }

  .print-ans-line {
    font-weight: bold;
    color: #000080;
    text-decoration: underline;
  }

  .score-eval-box {
    border: 2px solid #000;
    padding: 10px;
    margin-top: 20px;
    text-align: center;
    width: 250px;
    float: right;
  }
}
