/**
 * Lesson Base Styles
 * Common styles shared across all interactive lessons
 */

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

/* Base body styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* Theme variables */
:root {
  /* Primary colors */
  --color-primary: #764ba2;
  --color-primary-light: #9575cd;
  --color-primary-dark: #5e35b1;

  /* Accent colors */
  --color-success: #4ecdc4;
  --color-success-dark: #44a08d;
  --color-error: #ff6b6b;
  --color-warning: #ffa502;

  /* Place value colors */
  --color-tens: #ff9800;
  --color-tens-light: #ffecb3;
  --color-tens-dark: #e65100;
  --color-ones: #4caf50;
  --color-ones-light: #c8e6c9;
  --color-ones-dark: #2e7d32;

  /* Neutral colors */
  --color-text: #333;
  --color-text-light: #666;
  --color-bg: #f8f9fa;
  --color-white: #fff;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.3);
}

/* ===== LAYOUT ===== */

/* Full-page lesson container */
.lesson-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Card-style container */
.lesson-card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 800px;
  width: 100%;
  margin: 20px auto;
  box-shadow: var(--shadow-xl);
}

/* Canvas/work area */
.canvas-area {
  flex: 1;
  position: relative;
  padding: 20px;
}

/* ===== TYPOGRAPHY ===== */

.title {
  text-align: center;
  color: var(--color-text);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 10px;
}

.subtitle {
  text-align: center;
  color: var(--color-text-light);
  font-size: 18px;
  margin-bottom: 30px;
}

/* ===== PROBLEM BAR ===== */

.problem-bar {
  padding: 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  margin: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.problem-text {
  font-size: 36px;
  font-weight: 700;
  color: var(--color-primary);
}

/* ===== WORK LABEL / INSTRUCTION ===== */

.work-label {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  padding: 12px 32px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 10;
}

.work-label.visible {
  opacity: 1;
}

.instruction {
  text-align: center;
  font-size: 20px;
  color: var(--color-text-light);
  margin-bottom: 20px;
  min-height: 30px;
}

/* ===== HIGHLIGHT BOXES ===== */

.highlight-box {
  display: inline-block;
  padding: 5px 15px;
  border-radius: var(--radius-sm);
  font-weight: bold;
}

.highlight-box.tens,
.tens-highlight {
  background: var(--color-tens-light);
  color: var(--color-tens-dark);
  border: 3px solid var(--color-tens);
}

.highlight-box.ones,
.ones-highlight {
  background: var(--color-ones-light);
  color: var(--color-ones-dark);
  border: 3px solid var(--color-ones);
}

/* ===== STEP INDICATOR ===== */

.step-indicator {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ddd;
  transition: all 0.3s ease;
}

.step-dot.active {
  background: var(--color-primary);
  transform: scale(1.3);
}

.step-dot.completed {
  background: var(--color-success);
}

/* ===== PROGRESS BAR ===== */

.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-success));
  transition: width 0.3s ease;
}

/* ===== EQUATION DISPLAY ===== */

.equation-area {
  text-align: center;
  margin: 30px 0;
}

.equation-step {
  font-size: 32px;
  font-weight: bold;
  color: var(--color-text);
  margin: 15px 0;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s ease;
}

.equation-step.visible {
  opacity: 1;
  transform: translateY(0);
}

.equation-box {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  padding: 16px 28px;
  border-radius: var(--radius-md);
  font-size: 28px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-weight: 600;
  color: var(--color-primary);
  opacity: 0;
  transition: opacity 0.5s ease;
  box-shadow: var(--shadow-md);
}

.equation-box.visible {
  opacity: 1;
}

/* Equation number colors */
.tens-num {
  color: var(--color-tens-dark);
}

.ones-num {
  color: var(--color-ones-dark);
}

.result {
  color: var(--color-primary);
  background: #e8eaf6;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
}

/* ===== INPUT SECTION ===== */

.input-section {
  text-align: center;
  margin-top: 30px;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.input-section.visible {
  opacity: 1;
}

.input-label {
  font-size: 22px;
  color: var(--color-text);
  margin-bottom: 15px;
}

/* ===== ANSWER SECTION ===== */

.answer-section {
  position: absolute;
  bottom: 35px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 20;
}

.answer-section.visible {
  opacity: 1;
}

.answer-prompt {
  font-size: 22px;
  color: white;
  font-weight: 500;
}

.answer-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.answer-input {
  width: 120px;
  height: 60px;
  font-size: 36px;
  text-align: center;
  border: 4px solid #9fa8da;
  border-radius: var(--radius-md);
  background: white;
  font-family: 'SF Mono', monospace;
  font-weight: 700;
  outline: none;
}

.answer-input:focus {
  border-color: #ffeb3b;
  box-shadow: 0 0 0 4px rgba(255, 235, 59, 0.4);
}

.answer-submit {
  padding: 0 28px;
  height: 60px;
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.2s;
}

.answer-submit:hover {
  transform: scale(1.05);
}

/* ===== DIGIT BOX ===== */

.digit-box {
  width: 60px;
  height: 70px;
  border: 3px solid #ddd;
  border-radius: var(--radius-md);
  font-size: 36px;
  font-weight: bold;
  text-align: center;
  background: white;
  color: var(--color-text);
  transition: all 0.3s ease;
}

.digit-box:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(118, 75, 162, 0.2);
}

.digit-box.correct {
  border-color: var(--color-success);
  background: #e8f8f5;
}

.digit-box.incorrect {
  border-color: var(--color-error);
  background: #ffe8e8;
  animation: shake 0.5s ease;
}

/* ===== NUMBER PAD ===== */

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 350px;
  margin: 0 auto;
}

.num-btn {
  padding: 15px;
  font-size: 24px;
  font-weight: bold;
  border: none;
  border-radius: var(--radius-md);
  background: #f0f0f0;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.num-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.05);
}

.num-btn:active {
  transform: scale(0.95);
}

.num-btn.clear {
  background: var(--color-error);
  color: white;
}

/* ===== FEEDBACK ===== */

.feedback {
  text-align: center;
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-top: 20px;
  font-size: 24px;
  font-weight: bold;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease;
}

.feedback.visible {
  opacity: 1;
  transform: scale(1);
}

.feedback.success {
  background: linear-gradient(135deg, var(--color-success), var(--color-success-dark));
  color: white;
}

.feedback.error {
  background: var(--color-error);
  color: white;
}

.answer-feedback {
  font-size: 26px;
  font-weight: 700;
  min-height: 32px;
}

.answer-feedback.correct {
  color: #69f0ae;
}

.answer-feedback.incorrect {
  color: #ff5252;
}

/* ===== ANIMATIONS ===== */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

/* ===== CONFETTI ===== */

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  animation: confetti-fall 3s ease-out forwards;
}

/* ===== START OVERLAY ===== */

.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.start-btn {
  font-size: 32px;
  padding: 20px 60px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  color: white;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s;
}

.start-btn:hover {
  transform: scale(1.05);
}

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

.visible {
  opacity: 1 !important;
}

.hidden {
  opacity: 0 !important;
}

.text-center {
  text-align: center;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
