# Phase 3: Levels 11-20 Implementation

**Priority**: MEDIUM-HIGH - Advanced features and complexity  
**Estimated Effort**: 18-24 hours  
**Status**: Not Started  
**Dependencies**: Phase 2 (Levels 1-10)

---

## 🎯 Phase Goals

Implement levels 11-20, covering the **Mind & Body Arc** (L11-15) and **Advanced Training Arc** (L16-20). These levels introduce hypno overlays, captions, interruptions, popups, and complex multi-feature coordination.

---

## 📋 What This Phase Delivers

### Arcs Implemented:
1. **Mind & Body Arc (L11-15)**: Hypno overlays, captions, TTS+spiral combos, sensory overload
2. **Advanced Training Arc (L16-20)**: Interruptions, denial training, popup images, 90-minute marathon

### Level-by-Level:
- **L11**: Mind Sync (75min) - Hypno + captions
- **L12**: Caption Conditioning (80min) - Dynamic captions based on preferences
- **L13**: Voice in the Spiral (85min) - TTS + hypno synchronized
- **L14**: Sensory Overload (90min) - Quad + hypno + TTS + captions
- **L15**: Mind & Body Checkpoint (100min) - Preference update + arc recap
- **L16**: Controlled Chaos (110min) - Interruptions unlock
- **L17**: The Denial Dance (120min) - Forced denial training
- **L18**: Popup Distraction (130min) - Random popup images
- **L19**: Total Immersion (140min) - All features combined
- **L20**: Ultimate Checkpoint (150min) - All features unlocked, preference update

**End Result**: Full feature suite unlocked, players mastering complex multi-feature sessions.

---

## 🏗️ Implementation Tasks

### Task 1: Advanced Action Handlers (7-9 hours)

**File to Update**: `src/features/tasks/interactiveTaskManager.js`

Add handlers for L11-20 actions:

#### New Action Types:

**Hypno + Caption Combos (L11-14)**:
```javascript
{
  type: 'hypno-caption-combo',
  params: {
    hypnoDuration: 180,
    captions: [
      { text: 'You are a good gooner', delay: 10 },
      { text: 'Edging is pleasure', delay: 30 }
    ]
  }
}

{
  type: 'dynamic-captions',
  params: {
    duration: 300,
    captionSource: 'preference-based', // generates based on user preferences
    frequency: 15 // new caption every 15 seconds
  }
}

{
  type: 'tts-hypno-sync',
  params: {
    spiralDuration: 120,
    ttsCommands: [
      { text: 'Watch the spiral...', delay: 10 },
      { text: 'Deeper...', delay: 60 }
    ]
  }
}

{
  type: 'sensory-overload',
  params: {
    features: ['quad-video', 'hypno', 'tts', 'captions'],
    duration: 300
  }
}
```

**Interruption System (L16)**:
```javascript
{
  type: 'enable-interruptions',
  params: {
    types: ['edge', 'pose', 'mantra'],
    frequency: 'medium', // low/medium/high
    randomize: true
  }
}

{
  type: 'interruption',
  params: {
    interruptionType: 'edge', // 'edge', 'pose', 'mantra', 'stop-stroking'
    duration: 30,
    instruction: 'STOP! Edge right now!'
  }
}
```

**Denial Training (L17)**:
```javascript
{
  type: 'denial-training',
  params: {
    denialPeriods: [
      { duration: 120, instruction: 'No touching for 2 minutes' },
      { allowStroking: 60 },
      { duration: 180, instruction: 'Hands off again' }
    ]
  }
}

{
  type: 'stop-stroking',
  params: {
    duration: 120,
    showTimer: true
  }
}
```

**Popup System (L18)**:
```javascript
{
  type: 'enable-popups',
  params: {
    frequency: 'medium',
    sources: ['tasks', 'consequences'], // image folders
    duration: 10, // seconds per popup
    randomize: true
  }
}

{
  type: 'popup-image',
  params: {
    imagePath: '/images/tasks/edge.png',
    duration: 10,
    position: 'center' // or random
  }
}
```

#### Handler Implementation:

```javascript
class InteractiveTaskManager {
  // ... existing handlers ...
  
  async handleHypnoCaptionCombo(action) {
    // Start hypno spiral
    // Schedule captions at specified delays
    // Run both simultaneously
  }
  
  async handleDynamicCaptions(action) {
    // Get user preferences
    // Generate captions based on themes
    // Display new caption every N seconds
    // Track caption history
  }
  
  async handleTTSHypnoSync(action) {
    // Start spiral
    // Schedule TTS commands
    // Synchronize timing
  }
  
  async handleSensoryOverload(action) {
    // Activate all specified features
    // Quad video + hypno + TTS + captions
    // Coordinate timing
  }
  
  async handleEnableInterruptions(action) {
    // Set up random interruption scheduler
    // Based on frequency, schedule random interruptions
    // Store interruption state
  }
  
  async handleInterruption(action) {
    // Pause current activities
    // Show interruption overlay (STOP! EDGE!)
    // Wait for user to complete
    // Resume activities
  }
  
  async handleDenialTraining(action) {
    // Loop through denial periods
    // Enforce "hands off" periods with timer
    // Allow stroking periods
  }
  
  async handleStopStroking(action) {
    // Display "HANDS OFF" timer
    // Count down duration
    // Detect if user fails (optional)
  }
  
  async handleEnablePopups(action) {
    // Set up random popup scheduler
    // Based on frequency, show random images
  }
  
  async handlePopupImage(action) {
    // Display image overlay
    // Auto-hide after duration
  }
}
```

**Testing Checklist**:
- [ ] Hypno + captions work simultaneously
- [ ] Dynamic captions generate from preferences
- [ ] TTS + hypno synchronize correctly
- [ ] Sensory overload coordinates all features
- [ ] Interruptions trigger randomly
- [ ] Denial periods enforce "hands off"
- [ ] Popups display at correct frequency
- [ ] All advanced handlers work without conflicts

---

### Task 2: Caption System (4-5 hours)

**File to Create**: `src/features/captions/captionManager.js`

**Responsibilities**:
- Generate captions based on preferences
- Display captions with timing
- Track caption history
- Support manual and automatic captions

**Data Structure**:
```javascript
const captionTemplates = {
  edging: [
    "You are a good gooner",
    "Edge for me",
    "Stroke faster",
    "Slower now..."
  ],
  sissy: [
    "You're such a sissy",
    "Good girl",
    "Embrace your feminine side"
  ],
  humiliation: [
    "You're addicted",
    "You can't stop",
    "This is what you are"
  ],
  worship: [
    "Worship this body",
    "You live to serve",
    "Obey"
  ]
  // ... more themes
};
```

**Methods**:
```javascript
class CaptionManager {
  generateCaption(themes) {
    // Pick random template from enabled themes
  }
  
  displayCaption(text, duration = 5) {
    // Show caption overlay
    // Auto-hide after duration
  }
  
  startAutoCaptions(frequency, themes) {
    // Generate and display captions every N seconds
  }
  
  stopAutoCaptions() {
    // Stop auto-caption loop
  }
}
```

**UI Component**:
```html
<div id="caption-overlay" class="hidden">
  <p id="caption-text"></p>
</div>
```

**Testing Checklist**:
- [ ] Captions generate from templates
- [ ] Captions respect preferences
- [ ] Auto-captions cycle correctly
- [ ] Manual captions display properly
- [ ] Caption overlay styled correctly

---

### Task 3: Interruption System (3-4 hours)

**File to Create**: `src/features/interruptions/interruptionManager.js`

**Responsibilities**:
- Schedule random interruptions
- Display interruption overlays
- Pause/resume current activities
- Track interruption compliance

**Interruption Types**:
- **Edge**: "STOP! Edge right now!"
- **Pose**: "Hold this pose for 30 seconds"
- **Mantra**: "Repeat: I am a good gooner"
- **Stop Stroking**: "Hands off for 2 minutes"

**Methods**:
```javascript
class InterruptionManager {
  enable(frequency = 'medium') {
    // Schedule random interruptions
    // frequency: low (5-10min), medium (3-5min), high (1-3min)
  }
  
  disable() {
    // Stop interruption scheduler
  }
  
  triggerInterruption(type, params) {
    // Pause current activities
    // Show interruption overlay
    // Execute interruption
    // Resume activities
  }
  
  scheduleNext() {
    // Schedule next random interruption
  }
}
```

**UI Component**:
```html
<div id="interruption-overlay" class="modal hidden">
  <h2>INTERRUPTION!</h2>
  <p id="interruption-instruction"></p>
  <div id="interruption-timer"></div>
  <button id="interruption-complete">Done</button>
</div>
```

**Testing Checklist**:
- [ ] Interruptions trigger at correct frequency
- [ ] Interruption overlay displays
- [ ] Current activities pause
- [ ] Activities resume after interruption
- [ ] All interruption types work

---

### Task 4: Popup Image System (2-3 hours)

**File to Update**: `src/features/images/popupImageManager.js`

**Enhancements**:
- Random scheduling based on frequency
- Tag-based image selection
- Auto-hide after duration

**Methods**:
```javascript
class PopupImageManager {
  enableAutoPopups(frequency, tags) {
    // Schedule random popups
    // Filter images by tags
  }
  
  disableAutoPopups() {
    // Stop popup scheduler
  }
  
  showPopup(imagePath, duration = 10) {
    // Display popup
    // Auto-hide after duration
  }
}
```

**Testing Checklist**:
- [ ] Popups trigger at correct frequency
- [ ] Images filtered by tags
- [ ] Popups auto-hide
- [ ] Multiple popups don't overlap

---

### Task 5: Level Data for L11-20 (3-4 hours)

**File to Update**: `src/data/modes/academyLevelData.js`

Add levels 11-20:

```javascript
const academyLevels = {
  // ... L1-10 ...
  
  11: {
    name: "Mind Sync",
    arc: "Mind & Body",
    duration: 4500, // 75 minutes
    requirements: {
      minLevel: 11,
      completedLevels: [10],
      featuresUnlocked: ['hypno']
    },
    unlocks: {
      level: 12,
      features: ['captions']
    },
    sessionStructure: {
      main: [
        { type: 'hypno-caption-combo', params: { 
          hypnoDuration: 180,
          captions: [
            { text: 'You are a good gooner', delay: 10 },
            { text: 'Edging is your purpose', delay: 60 }
          ]
        }},
        { type: 'quad-video' },
        { type: 'edge', params: { count: 75 } }
      ]
    }
  },
  
  12: {
    name: "Caption Conditioning",
    arc: "Mind & Body",
    duration: 4800, // 80 minutes
    requirements: {
      minLevel: 12,
      completedLevels: [11],
      featuresUnlocked: ['captions']
    },
    unlocks: {
      level: 13
    },
    sessionStructure: {
      main: [
        { type: 'dynamic-captions', params: { 
          duration: 4800,
          captionSource: 'preference-based',
          frequency: 20
        }},
        { type: 'video-start' },
        { type: 'edge', params: { count: 80 } }
      ]
    }
  },
  
  13: {
    name: "Voice in the Spiral",
    arc: "Mind & Body",
    duration: 5100, // 85 minutes
    requirements: {
      minLevel: 13,
      completedLevels: [12]
    },
    unlocks: {
      level: 14
    },
    sessionStructure: {
      main: [
        { type: 'tts-hypno-sync', params: {
          spiralDuration: 300,
          ttsCommands: [
            { text: 'Watch the spiral...', delay: 10 },
            { text: 'Deeper and deeper...', delay: 120 },
            { text: 'You are under my control...', delay: 240 }
          ]
        }},
        { type: 'edge', params: { count: 85 } }
      ]
    }
  },
  
  14: {
    name: "Sensory Overload",
    arc: "Mind & Body",
    duration: 5400, // 90 minutes
    requirements: {
      minLevel: 14,
      completedLevels: [13]
    },
    unlocks: {
      level: 15
    },
    sessionStructure: {
      main: [
        { type: 'sensory-overload', params: {
          features: ['quad-video', 'hypno', 'tts', 'captions'],
          duration: 5400
        }},
        { type: 'edge', params: { count: 90 } }
      ]
    }
  },
  
  15: {
    name: "Mind & Body Checkpoint",
    arc: "Mind & Body",
    duration: 6000, // 100 minutes
    isCheckpoint: true,
    requirements: {
      minLevel: 15,
      completedLevels: [14]
    },
    unlocks: {
      level: 16,
      features: [],
      arcsCompleted: ['Mind & Body']
    },
    sessionStructure: {
      warmup: [
        { type: 'show-preferences', reason: 'checkpoint' }
      ],
      main: [
        { type: 'sensory-overload', params: { features: ['quad-video', 'hypno', 'tts', 'captions'], duration: 5400 } },
        { type: 'edge', params: { count: 100 } }
      ],
      cooldown: [
        { type: 'show-arc-complete', arc: 'Mind & Body' }
      ]
    }
  },
  
  16: {
    name: "Controlled Chaos",
    arc: "Advanced Training",
    duration: 6600, // 110 minutes
    requirements: {
      minLevel: 16,
      completedLevels: [15]
    },
    unlocks: {
      level: 17,
      features: ['interruptions']
    },
    sessionStructure: {
      main: [
        { type: 'enable-interruptions', params: { types: ['edge', 'pose'], frequency: 'medium' } },
        { type: 'quad-video' },
        { type: 'edge', params: { count: 110 } }
      ]
    },
    failureConditions: {
      cumming: true,
      abandoningSession: true,
      closingFeatures: ['quad-video'],
      ignoringInterruptions: true
    }
  },
  
  17: {
    name: "The Denial Dance",
    arc: "Advanced Training",
    duration: 7200, // 120 minutes
    requirements: {
      minLevel: 17,
      completedLevels: [16],
      featuresUnlocked: ['interruptions']
    },
    unlocks: {
      level: 18
    },
    sessionStructure: {
      main: [
        { type: 'denial-training', params: {
          denialPeriods: [
            { duration: 300, instruction: 'Hands off for 5 minutes' },
            { allowStroking: 120 },
            { duration: 600, instruction: 'Hands off for 10 minutes' }
          ]
        }},
        { type: 'edge', params: { count: 120 } }
      ]
    }
  },
  
  18: {
    name: "Popup Distraction",
    arc: "Advanced Training",
    duration: 7800, // 130 minutes
    requirements: {
      minLevel: 18,
      completedLevels: [17]
    },
    unlocks: {
      level: 19,
      features: ['popups']
    },
    sessionStructure: {
      main: [
        { type: 'enable-popups', params: { frequency: 'medium', sources: ['tasks', 'consequences'] } },
        { type: 'quad-video' },
        { type: 'edge', params: { count: 130 } }
      ]
    }
  },
  
  19: {
    name: "Total Immersion",
    arc: "Advanced Training",
    duration: 8400, // 140 minutes
    requirements: {
      minLevel: 19,
      completedLevels: [18],
      featuresUnlocked: ['popups']
    },
    unlocks: {
      level: 20
    },
    sessionStructure: {
      main: [
        { type: 'enable-interruptions', params: { frequency: 'high' } },
        { type: 'enable-popups', params: { frequency: 'high' } },
        { type: 'sensory-overload', params: { features: ['quad-video', 'hypno', 'tts', 'captions'] } },
        { type: 'edge', params: { count: 140 } }
      ]
    }
  },
  
  20: {
    name: "Ultimate Checkpoint",
    arc: "Advanced Training",
    duration: 9000, // 150 minutes
    isCheckpoint: true,
    requirements: {
      minLevel: 20,
      completedLevels: [19]
    },
    unlocks: {
      level: 21,
      features: [], // All features now unlocked
      arcsCompleted: ['Advanced Training'],
      durationTiers: ['Quick', 'Standard', 'Extended'] // Marathon at L25
    },
    sessionStructure: {
      warmup: [
        { type: 'show-preferences', reason: 'checkpoint' }
      ],
      main: [
        { type: 'enable-interruptions', params: { frequency: 'high' } },
        { type: 'enable-popups', params: { frequency: 'high' } },
        { type: 'sensory-overload', params: { features: ['quad-video', 'hypno', 'tts', 'captions'] } },
        { type: 'edge', params: { count: 150 } }
      ],
      cooldown: [
        { type: 'show-arc-complete', arc: 'Advanced Training' },
        { type: 'show-message', text: 'All features unlocked! Duration tiers available.' }
      ]
    }
  }
};
```

**Testing Checklist**:
- [ ] All L11-20 defined
- [ ] Requirements check correctly
- [ ] Feature unlocks work
- [ ] Checkpoints at L15 and L20 trigger

---

## 📏 Measurable Test Criteria

After Phase 3, ALL of these must pass:

### Level 11:
- [ ] Hypno spiral displays
- [ ] Captions appear with spiral
- [ ] Quad video plays
- [ ] Completing L11 unlocks L12

### Level 12:
- [ ] Dynamic captions generate
- [ ] Captions respect preferences
- [ ] Captions cycle every 20 seconds
- [ ] Completing L12 unlocks L13

### Level 13:
- [ ] TTS + hypno synchronize
- [ ] Voice commands match spiral timing
- [ ] Completing L13 unlocks L14

### Level 14:
- [ ] All features activate (quad + hypno + TTS + captions)
- [ ] No feature conflicts
- [ ] Completing L14 unlocks L15

### Level 15 (Checkpoint):
- [ ] Preference form appears
- [ ] Library stats display
- [ ] Mind & Body Arc completes
- [ ] Completing L15 unlocks L16

### Level 16:
- [ ] Interruptions enable
- [ ] Interruptions trigger randomly
- [ ] Interruption overlay displays
- [ ] Activities pause/resume
- [ ] Completing L16 unlocks L17

### Level 17:
- [ ] Denial periods enforce "hands off"
- [ ] Timer displays for denial periods
- [ ] Completing L17 unlocks L18

### Level 18:
- [ ] Popups enable
- [ ] Popups display randomly
- [ ] Images filtered correctly
- [ ] Completing L18 unlocks L19

### Level 19:
- [ ] All features coordinate (interruptions + popups + sensory overload)
- [ ] High frequency works without conflicts
- [ ] Completing L19 unlocks L20

### Level 20 (Checkpoint):
- [ ] Preference form appears
- [ ] Advanced Training Arc completes
- [ ] Duration tiers unlock message displays
- [ ] All features confirmed unlocked
- [ ] Completing L20 unlocks L21

### Overall:
- [ ] All levels L11-20 playable
- [ ] No console errors
- [ ] Progress saves after each level
- [ ] Feature unlocks persist
- [ ] Can play L11 → L20 sequentially

---

## 🎯 Success Criteria

**Phase 3 Complete When:**
1. Levels 11-20 fully functional
2. Mind & Body + Advanced Training arcs complete
3. All measurable tests pass
4. Caption system working
5. Interruption system working
6. Popup system working
7. All features coordinate without conflicts
8. Checkpoints at L15 and L20 work

---

## 📂 Files Created/Modified

### New Files:
- `src/features/captions/captionManager.js`
- `src/features/interruptions/interruptionManager.js`

### Modified Files:
- `src/features/tasks/interactiveTaskManager.js`
- `src/features/images/popupImageManager.js`
- `src/data/modes/academyLevelData.js`
- `training-academy.html`

---

## 🚀 Next Phase

After Phase 3: **Phase 4: Levels 21-25 Path Specialization**
