/* ============================================================================
   QUEST KS2 TUTORING APPLICATION - MAIN STYLESHEET
   Anxiety-aware design for young learners on iPad/Safari
   ============================================================================ */

/* ============================================================================
   1. ROOT & VARIABLES
   ============================================================================ */

:root {
  /* Colour palette - warm and calming */
  --color-primary: #5b9dd9;
  --color-primary-light: #a8d5ff;
  --color-primary-dark: #2c5aa0;

  --color-accent: #f0ad4e;
  --color-accent-light: #ffd89f;

  --color-success: #6bbf59;
  --color-success-light: #a8e6a1;

  --color-warning: #f59e0b;
  --color-warning-light: #fcd34d;

  --color-calm: #7dd3c0;
  --color-calm-light: #b8ebe3;

  /* Neutral palette */
  --color-bg: #ffffff;
  --color-surface: #f8fbfe;
  --color-border: #e0e9f3;
  --color-text: #2c3e50;
  --color-text-light: #5a6c7d;
  --color-text-muted: #8b9aaf;

  /* Mood-specific colours */
  --mood-anxious: #d4a5d4;
  --mood-calm: #a8e6e6;
  --mood-engaged: #ffd89f;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;
  --font-size-4xl: 32px;

  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Border radius - soft and friendly */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows - gentle */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.12);

  /* Animation */
  --transition-fast: 150ms ease-out;
  --transition-base: 250ms ease-out;
  --transition-slow: 400ms ease-out;

  /* Safe area insets for iPad notch/home indicator */
  --safe-area-inset-top: env(safe-area-inset-top, 0);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
  --safe-area-inset-left: env(safe-area-inset-left, 0);
  --safe-area-inset-right: env(safe-area-inset-right, 0);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1f2e;
    --color-surface: #232d3f;
    --color-border: #3a4556;
    --color-text: #f0f4f8;
    --color-text-light: #b8c5d6;
    --color-text-muted: #7a8598;

    --color-primary-light: #7ab3e8;
  }
}

/* ============================================================================
   2. MOOD STATE VARIANTS
   ============================================================================ */

body.mood-anxious {
  --color-accent: #c9b3d4;
  --color-accent-light: #e8d5f0;
  --color-primary-light: #9fb8d9;
}

body.mood-neutral {
  /* Use default variables */
}

body.mood-engaged {
  --color-accent: #ffd89f;
  --color-primary-light: #b3d9ff;
}

/* Anxious mood - larger text, more muted */
body.mood-anxious {
  --font-size-base: 17px;
  --font-size-lg: 19px;
  --font-size-xl: 22px;
}

/* ============================================================================
   3. RESET & GLOBAL STYLES
   ============================================================================ */

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

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  overflow: hidden;
}

/* ============================================================================
   4. APP LAYOUT
   ============================================================================ */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(var(--safe-area-inset-top), var(--space-lg)) var(--space-lg) var(--space-md);
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-calm-light) 100%);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: -0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.xp-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--font-size-lg);
}

.xp-icon {
  font-size: 1.2em;
}

.xp-value {
  color: var(--color-primary-dark);
  min-width: 30px;
}

.mood-button {
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: rgba(255, 255, 255, 0.8);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  font-size: 1.5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.mood-button:active {
  background-color: rgba(255, 255, 255, 0.95);
  transform: scale(0.95);
}

/* ============================================================================
   5. MAIN CONTENT AREA
   ============================================================================ */

.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  position: relative;
}

.view-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  overflow: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view-container.active {
  opacity: 1;
  pointer-events: auto;
  position: relative;
}

/* ============================================================================
   6. WELCOME/SETUP VIEW
   ============================================================================ */

.welcome-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100%;
  padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
  text-align: center;
  background: linear-gradient(180deg, var(--color-primary-light) 0%, var(--color-calm-light) 100%);
}

.welcome-header {
  margin-bottom: var(--space-3xl);
}

.welcome-header h2 {
  font-size: var(--font-size-4xl);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-md);
  font-weight: 700;
}

.welcome-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
}

.welcome-form {
  width: 100%;
  max-width: 400px;
}

/* ============================================================================
   7. FORM ELEMENTS
   ============================================================================ */

.form-group {
  margin-bottom: var(--space-xl);
  text-align: left;
}

.form-group label {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.text-input {
  width: 100%;
  padding: var(--space-lg);
  font-size: var(--font-size-lg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: all var(--transition-base);
  -webkit-appearance: none;
  appearance: none;
}

.text-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(91, 157, 217, 0.1);
  background-color: var(--color-surface);
}

.form-hint {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
}

/* ============================================================================
   8. BUTTONS
   ============================================================================ */

button {
  font-family: var(--font-family);
  cursor: pointer;
}

.btn-primary {
  padding: var(--space-lg) var(--space-2xl);
  background-color: var(--color-primary);
  color: white;
  font-size: var(--font-size-lg);
  font-weight: 600;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

.btn-large {
  width: 100%;
  padding: var(--space-xl) var(--space-2xl);
  font-size: var(--font-size-xl);
  min-height: 56px;
}

.btn-secondary {
  padding: var(--space-md) var(--space-xl);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: 600;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.btn-secondary:active {
  background-color: var(--color-border);
  transform: scale(0.98);
}

.btn-hint {
  padding: var(--space-md) var(--space-lg);
  background-color: rgba(240, 173, 78, 0.15);
  color: var(--color-warning);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  border: 1px solid rgba(240, 173, 78, 0.3);
}

.btn-hint:active {
  background-color: rgba(240, 173, 78, 0.25);
}

.option-btn {
  width: 100%;
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-lg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  transition: all var(--transition-base);
  min-height: 56px;
  display: flex;
  align-items: center;
}

.option-btn:active {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  transform: scale(0.98);
}

.option-btn.selected {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(91, 157, 217, 0.2);
}

/* Answer input group (text-input and numeric questions) */
.answer-input-group {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.answer-input {
  flex: 1;
  padding: 14px 18px;
  font-size: 18px;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  background: white;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: 'Inter', system-ui, sans-serif;
}

.answer-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.answer-submit {
  padding: 14px 24px;
  font-size: 16px;
  min-width: 60px;
}

/* ============================================================================
   9. ASSESSMENT VIEW
   ============================================================================ */

.assessment-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
}

.assessment-progress {
  margin-bottom: var(--space-xl);
  height: 4px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
  transition: width var(--transition-slow);
  border-radius: var(--radius-full);
}

.assessment-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-xl) 0;
}

.assessment-step h3 {
  font-size: var(--font-size-2xl);
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

.assessment-step p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  margin-bottom: var(--space-xl);
  line-height: var(--line-height-relaxed);
}

.assessment-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: space-between;
}

.assessment-actions button {
  flex: 1;
}

/* ============================================================================
   10. LEARNING VIEW & CHAT INTERFACE
   ============================================================================ */

.learning-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
  background-color: var(--color-bg);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  padding-right: var(--space-sm);
}

.chat-bubble {
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  max-width: 85%;
  word-wrap: break-word;
  animation: fadeIn var(--transition-base);
  line-height: var(--line-height-relaxed);
}

.chat-bubble.quinn, .chat-bubble.tigger {
  align-self: flex-start;
  background-color: var(--color-primary-light);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: var(--color-accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.learning-input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
}

#question-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.question-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  animation: slideUp var(--transition-base);
}

.question-card h4 {
  font-size: var(--font-size-xl);
  color: var(--color-text);
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.question-card p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  margin-bottom: var(--space-lg);
  line-height: var(--line-height-relaxed);
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.hint-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
  font-style: italic;
  padding: var(--space-md);
  background-color: var(--color-bg);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
}

/* ============================================================================
   11. MOOD PICKER
   ============================================================================ */

.mood-picker,
.energy-picker {
  display: flex;
  justify-content: space-around;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.mood-option,
.energy-option {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: var(--radius-full);
  font-size: 32px;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
}

.mood-option:active,
.energy-option:active {
  transform: scale(0.95);
}

.mood-option.selected,
.energy-option.selected {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(91, 157, 217, 0.2);
}

/* ============================================================================
   12. BREAK VIEW
   ============================================================================ */

.break-container {
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.break-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.break-header h2 {
  font-size: var(--font-size-3xl);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.break-header p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
}

.break-activities {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr;
}

.break-card {
  padding: var(--space-xl);
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-calm-light) 100%);
  border-radius: var(--radius-xl);
  border: 2px solid transparent;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
}

.break-card:active {
  transform: scale(0.98);
  border-color: var(--color-primary);
}

.break-card-icon {
  font-size: 48px;
}

.break-card-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-primary-dark);
}

.break-card-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.breathing-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--color-primary-light), var(--color-primary));
  margin: var(--space-3xl) auto;
  box-shadow: var(--shadow-lg);
  animation: breathing 8s ease-in-out infinite;
}

@keyframes breathing {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.breathing-text {
  text-align: center;
  font-size: var(--font-size-xl);
  color: var(--color-text-light);
  margin-bottom: var(--space-lg);
  min-height: 40px;
}

.puzzle-container {
  padding: var(--space-xl) 0;
}

.puzzle-item {
  padding: var(--space-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  text-align: center;
}

/* ============================================================================
   13. JOURNEY MAP VIEW
   ============================================================================ */

.journey-container {
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.journey-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.journey-header h2 {
  font-size: var(--font-size-3xl);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.journey-header p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
}

.journey-map {
  display: grid;
  gap: var(--space-xl);
}

.journey-region {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-calm-light) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
}

.journey-region.completed {
  background: linear-gradient(135deg, var(--color-success-light) 0%, var(--color-calm-light) 100%);
}

.journey-region.locked {
  opacity: 0.6;
}

.region-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.region-icon {
  font-size: 40px;
}

.region-info h3 {
  font-size: var(--font-size-xl);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-xs);
}

.region-info p {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.settlements {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.journey-settlement {
  padding: var(--space-lg);
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  border: 2px solid transparent;
}

.journey-settlement:active {
  transform: scale(0.95);
  border-color: var(--color-primary);
}

.journey-settlement.locked {
  opacity: 0.5;
}

.settlement-icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
}

.settlement-name {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
}

.settlement-progress {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* ============================================================================
   14. PARENT DASHBOARD
   ============================================================================ */

.parent-container {
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + var(--safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.parent-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 2px solid var(--color-border);
}

.parent-header h2 {
  font-size: var(--font-size-3xl);
  color: var(--color-text);
}

.parent-content {
  display: grid;
  gap: var(--space-xl);
}

.parent-card {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-calm-light) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
}

.parent-card h3 {
  font-size: var(--font-size-xl);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-md);
}

.parent-card p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-md);
}

.chart-container {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  min-height: 200px;
}

.badge-card {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
}

.badge-icon {
  font-size: 48px;
  flex-shrink: 0;
}

.badge-info h4 {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.badge-info p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ============================================================================
   15. XP BAR & PROGRESS
   ============================================================================ */

.xp-bar {
  width: 100%;
  height: 24px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-lg) 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--space-sm);
}

/* ============================================================================
   16. MODALS & OVERLAYS
   ============================================================================ */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
  animation: fadeIn var(--transition-base);
}

.modal-content {
  width: 100%;
  background-color: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-xl);
  padding-bottom: calc(var(--space-xl) + var(--safe-area-inset-bottom));
  animation: slideUp var(--transition-base);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: var(--font-size-2xl);
  color: var(--color-text);
  margin: 0;
}

.modal-close {
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: var(--color-surface);
  border: none;
  border-radius: var(--radius-full);
  font-size: 24px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-close:active {
  background-color: var(--color-border);
  transform: scale(0.95);
}

.check-label {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  font-weight: 600;
}

.mood-check-section,
.energy-check-section {
  margin-bottom: var(--space-2xl);
}

/* ============================================================================
   17. NOTIFICATIONS & TOASTS
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: calc(80px + var(--safe-area-inset-bottom));
  left: var(--space-lg);
  right: var(--space-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  pointer-events: none;
}

.toast {
  background-color: var(--color-success);
  color: white;
  padding: var(--space-lg) var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-lg);
  font-weight: 600;
  animation: slideUp var(--transition-base), fadeOut 300ms ease-out 3.7s forwards;
  text-align: center;
  pointer-events: auto;
}

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

/* ============================================================================
   18. BOTTOM NAVIGATION
   ============================================================================ */

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding-bottom: max(0px, var(--safe-area-inset-bottom));
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  z-index: 100;
}

.nav-item {
  flex: 1;
  height: 64px;
  padding: var(--space-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all var(--transition-base);
}

.nav-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-icon {
  font-size: 28px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* ============================================================================
   19. ANIMATIONS
   ============================================================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.fade-in {
  animation: fadeIn var(--transition-base);
}

.slide-up {
  animation: slideUp var(--transition-base);
}

/* ============================================================================
   20. SLIDE-BASED LEARNING LAYOUT
   ============================================================================ */

/* The viewport container: scroll-snap for iPad-native slide feel */
#slide-viewport {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overflow-y: auto;
  /* Ensure the container has a real height for scroll-snap to work */
  min-height: 0;
}

/* Each slide fills the entire viewport height */
.slide {
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  position: relative;
  opacity: 0;
  animation: slideReveal 0.5s ease-out forwards;
}

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

/* Slide inner content: centred, max-width for readability */
.slide-inner {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 8px;
}

/* ── Question Slide ─────────────────────────────────────── */
.slide-question {
  background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 50%, #e8f0fe 100%);
}

.slide-question .slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.slide-question .slide-question-text {
  font-size: 20px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.75;
  font-family: 'Nunito', system-ui, sans-serif;
}

.slide-question .slide-passage {
  background: rgba(255,255,255,0.7);
  border: 1px solid #e0e9f3;
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 15px;
  color: #5a6c7d;
  line-height: 1.75;
}

.slide-question .slide-passage-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b9aaf;
  margin-bottom: 4px;
}

.slide-question .slide-input-area {
  margin-top: 12px;
}

/* Style the answer input field to be large and friendly */
.slide-question .slide-input-area input[type="text"],
.slide-question .slide-input-area input[type="number"] {
  width: 100%;
  padding: 14px 18px;
  font-size: 18px;
  border: 2px solid #e0e9f3;
  border-radius: 14px;
  background: white;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: 'Inter', system-ui, sans-serif;
}

.slide-question .slide-input-area input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Multiple choice options */
.slide-question .slide-input-area .option-btn,
.slide-question .slide-input-area button[data-option] {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  border: 2px solid #e0e9f3;
  border-radius: 14px;
  background: white;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 8px;
  font-family: 'Nunito', system-ui, sans-serif;
}

.slide-question .slide-input-area .option-btn:hover,
.slide-question .slide-input-area button[data-option]:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.slide-question .slide-input-area .option-btn:active,
.slide-question .slide-input-area button[data-option]:active {
  transform: scale(0.98);
}

.slide-question .slide-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* Hint display within the slide */
.slide-question .hint-display,
.hint-display {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.hint-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  color: #92400e;
}

/* ── Result Slide ───────────────────────────────────────── */
.slide-result {
  text-align: center;
}

.slide-result.correct {
  background: linear-gradient(160deg, #f0fdf4 0%, #ecfdf5 50%, #d1fae5 100%);
}

.slide-result.incorrect {
  background: linear-gradient(160deg, #eff6ff 0%, #f0f9ff 50%, #dbeafe 100%);
}

.slide-result .result-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: var(--space-md);
  animation: resultPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultPop {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

.slide-result .result-title {
  font-size: 28px;
  font-weight: 800;
  font-family: 'Nunito', system-ui, sans-serif;
}

.slide-result.correct .result-title { color: #059669; }
.slide-result.incorrect .result-title { color: #3b82f6; }

.slide-result .result-correct-answer {
  font-size: 18px;
  color: #1e293b;
  margin-top: 8px;
}

.slide-result .result-correct-answer strong {
  color: #059669;
}

.slide-result .result-quinn {
  font-size: 16px;
  color: #5a6c7d;
  line-height: 1.75;
  margin-top: 12px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.6);
  border-radius: 16px;
}

.slide-result .xp-award {
  display: inline-block;
  font-size: 22px;
  font-weight: 800;
  color: #f0ad4e;
  margin-top: 12px;
  animation: xpFloat 0.8s ease-out;
}

@keyframes xpFloat {
  0%   { opacity: 0; transform: translateY(20px) scale(0.8); }
  60%  { transform: translateY(-5px) scale(1.1); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Worked Solution Slide ──────────────────────────────── */
.slide-solution {
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 50%, #fde68a 100%);
}

.slide-solution .solution-title {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Nunito', system-ui, sans-serif;
  color: #92400e;
  text-align: center;
}

.slide-solution .solution-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-solution .solution-step {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: rgba(255,255,255,0.65);
  border-radius: 16px;
  border-left: 4px solid #f59e0b;
  opacity: 0;
  animation: stepReveal 0.4s ease-out forwards;
}

/* Staggered step animation */
.solution-step:nth-child(1) { animation-delay: 0.1s; }
.solution-step:nth-child(2) { animation-delay: 0.25s; }
.solution-step:nth-child(3) { animation-delay: 0.4s; }
.solution-step:nth-child(4) { animation-delay: 0.55s; }
.solution-step:nth-child(5) { animation-delay: 0.7s; }

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

.solution-step .step-num {
  font-size: 22px;
  font-weight: 800;
  color: #f59e0b;
  min-width: 28px;
  flex-shrink: 0;
}

.solution-step .step-text {
  font-size: 16px;
  color: #1e293b;
  line-height: 1.75;
}

.slide-solution .solution-diagram,
.slide-question .solution-diagram {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: rgba(255,255,255,0.5);
  border-radius: 16px;
  overflow: hidden;
}

.slide-solution .solution-diagram svg {
  max-width: 100%;
  height: auto;
}

.slide-solution .solution-explanation {
  font-size: 14px;
  color: #78350f;
  text-align: center;
  line-height: 1.75;
  padding-top: 12px;
  border-top: 1px solid rgba(245, 158, 11, 0.3);
}

/* ── Break Suggestion Slide ─────────────────────────────── */
.slide-break {
  background: linear-gradient(160deg, #f3e8ff 0%, #ede9fe 50%, #ddd6fe 100%);
  text-align: center;
}

.slide-break .break-emoji {
  font-size: 56px;
  line-height: 1;
  margin-bottom: var(--space-md);
}

.slide-break .break-title {
  font-size: 28px;
  font-weight: 800;
  font-family: 'Nunito', system-ui, sans-serif;
  color: #6d28d9;
}

.slide-break .break-reason {
  font-size: 16px;
  color: #5a6c7d;
  line-height: 1.75;
  margin: 12px 0;
}

.slide-break .break-stats {
  font-size: 14px;
  color: #8b9aaf;
  padding: 8px 12px;
  background: rgba(255,255,255,0.4);
  border-radius: 12px;
  margin-bottom: 16px;
}

.slide-break .break-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-break .break-buttons button {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease-out;
  font-family: 'Nunito', system-ui, sans-serif;
}

.slide-break .break-buttons button:active {
  transform: scale(0.97);
}

/* ── Progress Dots ──────────────────────────────────────── */
#slide-progress .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all 0.3s ease;
}

#slide-progress .dot.active {
  background: #3b82f6;
  transform: scale(1.4);
}

#slide-progress .dot.question { background: #93c5fd; }
#slide-progress .dot.result   { background: #86efac; }
#slide-progress .dot.solution { background: #fcd34d; }
#slide-progress .dot.break    { background: #c4b5fd; }
#slide-progress .dot.welcome  { background: #fcd34d; }
#slide-progress .dot.active   { background: #3b82f6; }

/* ============================================================================
   21. ACCESSIBILITY & RESPONSIVE
   ============================================================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* iPad Pro 12.9 specific adjustments */
@media (min-width: 1024px) {
  .learning-container {
    max-width: 900px;
    margin: 0 auto;
  }

  .settlements {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Landscape mode adjustments */
@media (orientation: landscape) {
  .app-header {
    padding: var(--space-md) var(--space-lg);
  }

  .main-content {
    margin-bottom: 0;
  }

  .nav-bar {
    height: 56px;
  }

  .nav-item {
    height: 56px;
  }

  .nav-icon {
    font-size: 24px;
  }

  .nav-label {
    display: none;
  }

  .welcome-content {
    padding: var(--space-2xl) var(--space-lg);
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

button:focus-visible {
  outline-offset: -2px;
}

/* ============================================================================
   21. PRINT STYLES
   ============================================================================ */

@media print {
  .nav-bar,
  .app-header {
    display: none;
  }

  .view-container {
    position: static;
    opacity: 1;
    page-break-inside: avoid;
  }
}
