/**
 * Standard Lesson Layout for iPad Split-Screen
 *
 * All interactive lessons must import this file to ensure consistent
 * layout in the 40% split-screen panel (~410px width).
 *
 * Usage: Add to lesson <head>:
 *   <link rel="stylesheet" href="lesson-standard.css">
 *
 * Required HTML structure:
 *   <body>
 *     <div class="lesson-container">
 *       <div class="lesson-card">
 *         <!-- Lesson content -->
 *       </div>
 *     </div>
 *   </body>
 */

/* ============================================
   BASE RESET & LAYOUT
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  padding: 8px;
  /* Default gradient - can be overridden per lesson */
  background: linear-gradient(180deg, #EBF5FF 0%, #F5F3FF 100%);
}

/* Main container - enforces max width */
.lesson-container,
.container {
  max-width: 380px;
  margin: 0 auto;
  width: 100%;
}

/* Card styling */
.lesson-card,
.card {
  background: white;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* Step cards (for multi-step lessons) */
.step {
  background: white;
  padding: 16px;
  border-radius: 20px;
  margin-bottom: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  display: none;
  opacity: 0;
  transform: translateY(20px);
}

.step.active {
  display: block;
  animation: slideIn 0.5s ease forwards;
}

@keyframes slideIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   TYPOGRAPHY - Compact sizes for split-screen
   ============================================ */

h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 10px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

p, .intro-text, .description {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.small-text, .hint, .step-label {
  font-size: 12px;
}

/* ============================================
   ANIMATION / VISUAL AREA
   Max height to ensure it fits
   ============================================ */

.animation-area,
.visual-area,
.diagram-area,
.problem-container {
  position: relative;
  max-height: 180px;
  margin: 12px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* For lessons that need more height, scale down */
.animation-area.large,
.visual-area.large {
  transform: scale(0.8);
  transform-origin: top center;
  max-height: 220px;
}

/* ============================================
   NUMBER BLOCKS & MATH ELEMENTS
   ============================================ */

.num-block {
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-width: 2px;
  border-style: solid;
}

.base-num, .result-num {
  font-size: 28px;
  padding: 8px 12px;
}

.ones-digit, .add-num, .ten-block {
  font-size: 24px;
  padding: 6px 10px;
}

.operator {
  font-size: 20px;
  font-weight: 600;
  margin: 0 8px;
}

.info-text, .explanation {
  font-size: 14px;
  text-align: center;
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 10px;
}

/* ============================================
   ANSWER SECTION & BUTTONS
   ============================================ */

.answer-section {
  margin-top: 16px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 12px;
}

.answer-prompt, .question-text {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
}

.answer-options, .options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.answer-btn, .option-btn {
  min-width: 50px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid #d1d5db;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.answer-btn:hover, .option-btn:hover {
  border-color: #9333ea;
  background: #faf5ff;
}

.answer-btn.selected, .option-btn.selected {
  border-color: #9333ea;
  background: #9333ea;
  color: white;
}

.answer-btn.correct, .option-btn.correct {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

.answer-btn.incorrect, .option-btn.incorrect {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

/* Primary action button */
.btn, .next-btn, .continue-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #9333ea, #7c3aed);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover, .next-btn:hover, .continue-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   CELEBRATION / SUCCESS STATE
   ============================================ */

.celebration, .success {
  text-align: center;
  padding: 20px 16px;
}

.celebration h2, .success h2 {
  font-size: 20px;
  color: #166534;
  margin-bottom: 8px;
}

.celebration .emoji, .success .emoji {
  font-size: 40px;
  margin: 12px 0;
}

.celebration p, .success p {
  font-size: 15px;
  color: #374151;
}

/* ============================================
   PROGRESS INDICATORS
   ============================================ */

.score, .progress {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.step-label {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ============================================
   SVG & SHAPES (for fraction lessons etc)
   ============================================ */

svg {
  max-width: 100%;
  height: auto;
}

.shape-container, .shapes-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  max-height: 120px;
}

/* ============================================
   SOUND TOGGLE (compact)
   ============================================ */

.sound-toggle {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: 2px solid #9333ea;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 1000;
}

.sound-toggle svg {
  width: 18px;
  height: 18px;
  fill: #9333ea;
}

.sound-toggle.muted svg {
  fill: #9ca3af;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }

/* ============================================
   COLOR THEMES (override body background)
   ============================================ */

body.theme-blue {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

body.theme-green {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 50%, #A5D6A7 100%);
}

body.theme-purple {
  background: linear-gradient(180deg, #f3e8ff 0%, #e9d5ff 100%);
}

body.theme-orange {
  background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
}

body.theme-pink {
  background: linear-gradient(180deg, #fce7f3 0%, #fbcfe8 100%);
}

/* ============================================
   ABSTRACT PANEL LINE-BY-LINE REVEAL
   ============================================ */

@keyframes absRevealAnim {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.abs-reveal {
  animation: absRevealAnim 0.4s ease both;
}

/* ============================================
   OVERFLOW SAFETY
   Prevent SVGs, images, tables, canvases from
   overflowing their containers
   ============================================ */

svg, img, table, canvas {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   Scale up for larger containers (modals, tabs)
   ============================================ */

/* Medium — AnswerVideoScreen modal, LecturesVideoScreen tab */
@media (min-width: 500px) {
  .lesson-container,
  .container {
    max-width: 560px;
  }

  body {
    font-size: 16px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 21px;
  }

  .lesson-card,
  .card {
    padding: 20px;
  }

  .animation-area,
  .visual-area,
  .diagram-area,
  .problem-container {
    max-height: 240px;
  }
}

/* Large — full-screen modal
   iPad 11" landscape viewport: ~1194 x 834
   Usable height after paddingTop(80) + body padding: ~700px
   Target: single step fits without scrolling */
@media (min-width: 768px) {
  .lesson-container,
  .container {
    max-width: 760px;
  }

  body {
    font-size: 17px;
    padding: 8px 16px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 24px;
    margin-bottom: 8px;
  }

  h3 {
    font-size: 20px;
  }

  .step {
    padding: 14px;
    margin-bottom: 12px;
  }

  .lesson-card,
  .card {
    padding: 14px;
  }

  .animation-area,
  .visual-area,
  .diagram-area,
  .problem-container {
    max-height: 300px;
    margin: 8px 0;
  }

  .animation-area.large,
  .visual-area.large {
    transform: scale(1.0);
    max-height: 340px;
  }
}
