/**
 * Academy Level Data Configuration
 * Defines detailed configurations for all 30 training levels
 * Phase 2: Level Data & Content Configuration
 */

class AcademyLevelData {
    constructor() {
        this.levels = this.initializeLevelConfigs();
    }

    /**
     * Get configuration for a specific level
     * @param {number} levelNumber - Level number (1-30)
     * @returns {Object} Level configuration
     */
    getLevelConfig(levelNumber) {
        return this.levels[levelNumber] || null;
    }

    /**
     * Get all levels for a specific arc
     * @param {number} arcNumber - Arc number (1-6)
     * @returns {Array} Array of level configs
     */
    getArcLevels(arcNumber) {
        return Object.values(this.levels).filter(level => level.arc === arcNumber);
    }

    /**
     * Initialize all 30 level configurations
     * @returns {Object} Map of level numbers to configurations
     */
    initializeLevelConfigs() {
        const manualLevels = {
            // ARC 1: AWAKENING (Levels 1-5)
            1: {
                levelNumber: 1,
                arc: 1,
                arcName: "Awakening",
                title: "Introduction",
                subtitle: "Your Journey Begins",
                description: "Welcome to The Academy. Begin your training with simple focus exercises and learn the fundamentals of edging and control.",
                
                // Session configuration
                session: {
                    duration: { min: 10, target: 15, max: 20 }, // minutes
                    tasks: {
                        total: 3,
                        types: ['edge', 'focus', 'obey'],
                        difficulty: 'beginner'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 5, // every 5 minutes
                        duration: 30 // seconds
                    }
                },

                // Media requirements
                media: {
                    videos: {
                        required: 2,
                        categories: ['solo', 'soft', 'pov'],
                        duration: { min: 5, max: 15 },
                        preferenceWeight: 0.3 // 30% user preference, 70% level requirements
                    },
                    images: {
                        required: 3,
                        categories: ['soft', 'artistic'],
                        timing: 'task-completion'
                    }
                },

                // Task definitions
                tasks: [
                    {
                        type: 'edge',
                        count: 3,
                        duration: 120, // seconds per edge
                        intensity: 'gentle',
                        instructions: "Edge slowly and steadily. Focus on the sensations. Stop before the point of no return.",
                        successCriteria: {
                            edges: 3,
                            cooldown: 30 // seconds between edges
                        }
                    },
                    {
                        type: 'focus',
                        duration: 180,
                        target: 'video',
                        instructions: "Watch and focus. Let the content guide your arousal. No touching yet.",
                        distractions: 'minimal'
                    },
                    {
                        type: 'obey',
                        commands: ['stroke', 'stop', 'slow'],
                        timing: 'audio-cue',
                        instructions: "Follow the commands exactly as given. Build your obedience."
                    }
                ],

                // Objectives and rewards
                objectives: [
                    "Complete 3 edges without going over",
                    "Maintain focus for the full session",
                    "Follow all commands without hesitation"
                ],
                
                rewards: {
                    xp: 100,
                    unlocks: ['Level 2'],
                    achievements: ['First Steps']
                },

                // Story/narrative elements
                story: {
                    intro: "Welcome, trainee. Today marks the beginning of your transformation. We'll start simple - learning control, building focus, understanding your limits.",
                    checkpoint: null,
                    outro: "Well done. You've completed your first session. This is just the beginning of your journey."
                },

                // Completion criteria
                completion: {
                    required: {
                        tasksCompleted: 3,
                        edgesAchieved: 3,
                        timeSpent: 10 // minimum minutes
                    },
                    optional: {
                        perfectEdges: 3, // bonus for all edges being perfect
                        noMistakes: true
                    }
                }
            },

            2: {
                levelNumber: 2,
                arc: 1,
                arcName: "Awakening",
                title: "First Steps",
                subtitle: "Building the Foundation",
                description: "Now that you understand the basics, we'll increase the intensity slightly. More edges, longer focus periods.",

                session: {
                    duration: { min: 15, target: 20, max: 25 },
                    tasks: {
                        total: 4,
                        types: ['edge', 'focus', 'endurance', 'obey'],
                        difficulty: 'beginner'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 7,
                        duration: 30
                    }
                },

                media: {
                    videos: {
                        required: 3,
                        categories: ['solo', 'couples', 'soft', 'moderate'],
                        duration: { min: 5, max: 20 },
                        preferenceWeight: 0.4
                    },
                    images: {
                        required: 5,
                        categories: ['soft', 'moderate'],
                        timing: 'between-tasks'
                    }
                },

                tasks: [
                    {
                        type: 'edge',
                        count: 5,
                        duration: 120,
                        intensity: 'moderate',
                        instructions: "Five edges today. Take your time. Feel the build-up each time.",
                        successCriteria: {
                            edges: 5,
                            cooldown: 45
                        }
                    },
                    {
                        type: 'focus',
                        duration: 240,
                        target: 'video',
                        instructions: "Extended focus session. Watch without touching. Build anticipation.",
                        distractions: 'low'
                    },
                    {
                        type: 'endurance',
                        duration: 180,
                        stroking: {
                            pace: 'slow',
                            pattern: 'steady',
                            breaks: 'as-needed'
                        },
                        instructions: "Stroke slowly for 3 minutes. Maintain arousal but stay in control."
                    },
                    {
                        type: 'obey',
                        commands: ['stroke', 'stop', 'slow', 'fast', 'edge'],
                        timing: 'visual-audio-cue',
                        instructions: "More varied commands today. Stay responsive and obedient."
                    }
                ],

                objectives: [
                    "Complete 5 edges with control",
                    "Endure the full focus period",
                    "Respond to all commands immediately"
                ],

                rewards: {
                    xp: 150,
                    unlocks: ['Level 3'],
                    achievements: []
                },

                story: {
                    intro: "You're progressing well. Today we build on yesterday's foundation. More edges, longer sessions, better control.",
                    checkpoint: null,
                    outro: "Excellent work. You're learning to control your arousal. This discipline will serve you well."
                },

                completion: {
                    required: {
                        tasksCompleted: 4,
                        edgesAchieved: 5,
                        timeSpent: 15
                    },
                    optional: {
                        perfectEdges: 5,
                        noBreaks: true
                    }
                }
            },

            3: {
                levelNumber: 3,
                arc: 1,
                arcName: "Awakening",
                title: "Building Endurance",
                subtitle: "Longer, Stronger",
                description: "Test your stamina with extended edging sessions and longer stroke periods. Your endurance must grow.",

                session: {
                    duration: { min: 20, target: 25, max: 30 },
                    tasks: {
                        total: 5,
                        types: ['edge', 'endurance', 'focus', 'pattern', 'obey'],
                        difficulty: 'beginner-intermediate'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 8,
                        duration: 30
                    }
                },

                media: {
                    videos: {
                        required: 4,
                        categories: ['solo', 'couples', 'moderate', 'pov'],
                        duration: { min: 10, max: 25 },
                        preferenceWeight: 0.5
                    },
                    images: {
                        required: 6,
                        categories: ['moderate', 'artistic'],
                        timing: 'task-transition'
                    }
                },

                tasks: [
                    {
                        type: 'edge',
                        count: 7,
                        duration: 150,
                        intensity: 'moderate',
                        instructions: "Seven edges. Longer build-up. Really feel each one approaching.",
                        successCriteria: {
                            edges: 7,
                            cooldown: 60
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 300,
                        stroking: {
                            pace: 'moderate',
                            pattern: 'steady',
                            breaks: 'minimal'
                        },
                        instructions: "Five minutes of steady stroking. Build your stamina. Control your arousal."
                    },
                    {
                        type: 'focus',
                        duration: 180,
                        target: 'multiple-videos',
                        instructions: "Watch multiple videos. Switch between them. Maintain arousal.",
                        distractions: 'moderate'
                    },
                    {
                        type: 'pattern',
                        duration: 240,
                        pattern: {
                            sequence: [10, 20, 10, 30, 10, 20],
                            unit: 'strokes',
                            rest: 10
                        },
                        instructions: "Follow the stroke pattern: 10 fast, 20 slow, 10 fast, 30 slow, repeat."
                    },
                    {
                        type: 'obey',
                        commands: ['stroke', 'stop', 'slow', 'fast', 'edge', 'hold'],
                        timing: 'random-intervals',
                        instructions: "Commands will come at random. Stay alert and ready to obey."
                    }
                ],

                objectives: [
                    "Complete 7 edges maintaining control",
                    "Endure 5+ minutes of continuous stroking",
                    "Follow complex stroke patterns accurately"
                ],

                rewards: {
                    xp: 200,
                    unlocks: ['Level 4'],
                    achievements: ['Endurance Builder']
                },

                story: {
                    intro: "Your control is improving. Now we test your endurance. Longer sessions, more edges, complex patterns.",
                    checkpoint: null,
                    outro: "Impressive stamina. You're learning to sustain arousal over longer periods without losing control."
                },

                completion: {
                    required: {
                        tasksCompleted: 5,
                        edgesAchieved: 7,
                        timeSpent: 20
                    },
                    optional: {
                        perfectEdges: 7,
                        patternAccuracy: 0.9
                    }
                }
            },

            4: {
                levelNumber: 4,
                arc: 1,
                arcName: "Awakening",
                title: "Deeper Focus",
                subtitle: "Mind Over Matter",
                description: "Mental discipline is as important as physical control. Extended focus exercises while maintaining arousal.",

                session: {
                    duration: { min: 25, target: 30, max: 35 },
                    tasks: {
                        total: 5,
                        types: ['focus', 'edge', 'denial', 'pattern', 'obey'],
                        difficulty: 'intermediate'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 10,
                        duration: 45
                    }
                },

                media: {
                    videos: {
                        required: 5,
                        categories: ['moderate', 'intense', 'pov', 'compilation'],
                        duration: { min: 10, max: 30 },
                        preferenceWeight: 0.6
                    },
                    images: {
                        required: 8,
                        categories: ['moderate', 'intense', 'artistic'],
                        timing: 'focus-periods'
                    }
                },

                tasks: [
                    {
                        type: 'focus',
                        duration: 360,
                        target: 'intense-content',
                        instructions: "Six minutes of pure focus. Intense content. No touching. Only watching.",
                        distractions: 'high',
                        arousal: 'maintain-high'
                    },
                    {
                        type: 'edge',
                        count: 8,
                        duration: 180,
                        intensity: 'intense',
                        instructions: "Eight edges today. Quick succession. Test your control limits.",
                        successCriteria: {
                            edges: 8,
                            cooldown: 45
                        }
                    },
                    {
                        type: 'denial',
                        duration: 180,
                        stroking: 'allowed',
                        edging: 'forbidden',
                        instructions: "Stroke but don't edge. Stay below that threshold. Practice restraint."
                    },
                    {
                        type: 'pattern',
                        duration: 300,
                        pattern: {
                            sequence: [30, 10, 20, 10, 40, 10],
                            unit: 'seconds',
                            strokeType: ['slow', 'fast', 'medium', 'fast', 'slow', 'fast'],
                            rest: 15
                        },
                        instructions: "Complex timed pattern. Different speeds. Maintain rhythm."
                    },
                    {
                        type: 'obey',
                        commands: ['stroke', 'stop', 'edge', 'deny', 'focus', 'breathe'],
                        timing: 'audio-visual-sync',
                        instructions: "Commands synchronized with media. Perfect timing required."
                    }
                ],

                objectives: [
                    "Maintain focus for 6+ minutes without touching",
                    "Complete 8 edges in quick succession",
                    "Practice denial - stroke without edging"
                ],

                rewards: {
                    xp: 250,
                    unlocks: ['Level 5'],
                    achievements: ['Mind Master']
                },

                story: {
                    intro: "Mental discipline separates the novice from the dedicated. Today we train your mind as much as your body.",
                    checkpoint: null,
                    outro: "Your focus is sharpening. Mind and body are learning to work together in harmony."
                },

                completion: {
                    required: {
                        tasksCompleted: 5,
                        edgesAchieved: 8,
                        focusTime: 6,
                        timeSpent: 25
                    },
                    optional: {
                        perfectFocus: true,
                        denialSuccess: true
                    }
                }
            },

            5: {
                levelNumber: 5,
                arc: 1,
                arcName: "Awakening",
                title: "Checkpoint: First Assessment",
                subtitle: "Prove Your Progress",
                description: "Your first major checkpoint. A comprehensive test of everything learned so far. Update your preferences and review your progress.",

                session: {
                    duration: { min: 30, target: 40, max: 50 },
                    tasks: {
                        total: 7,
                        types: ['edge', 'endurance', 'focus', 'pattern', 'denial', 'obey', 'challenge'],
                        difficulty: 'intermediate'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 12,
                        duration: 60
                    }
                },

                media: {
                    videos: {
                        required: 6,
                        categories: 'user-preferences', // Fully respect user preferences at checkpoints
                        duration: { min: 10, max: 40 },
                        preferenceWeight: 1.0 // 100% user preference
                    },
                    images: {
                        required: 10,
                        categories: 'user-preferences',
                        timing: 'throughout'
                    }
                },

                tasks: [
                    {
                        type: 'edge',
                        count: 10,
                        duration: 180,
                        intensity: 'varied',
                        instructions: "Ten edges. Your control will be tested. Vary the intensity.",
                        successCriteria: {
                            edges: 10,
                            cooldown: 60,
                            varietyRequired: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 420,
                        stroking: {
                            pace: 'varied',
                            pattern: 'complex',
                            breaks: 'strategic'
                        },
                        instructions: "Seven minutes continuous. Vary your pace. Manage your arousal strategically."
                    },
                    {
                        type: 'focus',
                        duration: 300,
                        target: 'preferred-content',
                        instructions: "Pure focus on your favorite content. No touching. High arousal maintenance.",
                        distractions: 'high',
                        arousal: 'critical'
                    },
                    {
                        type: 'pattern',
                        duration: 360,
                        pattern: {
                            sequence: 'adaptive', // Adjusts to performance
                            complexity: 'high'
                        },
                        instructions: "Advanced patterns that adapt to your performance. Stay focused."
                    },
                    {
                        type: 'denial',
                        duration: 240,
                        stroking: 'required',
                        edging: 'forbidden',
                        challenge: 'intense-content',
                        instructions: "Ultimate denial test. Intense content. Stroke but never edge. Show your discipline."
                    },
                    {
                        type: 'obey',
                        commands: 'full-set',
                        timing: 'complex',
                        instructions: "All command types. Complex timing. Perfect obedience expected."
                    },
                    {
                        type: 'challenge',
                        description: 'checkpoint-assessment',
                        requirements: {
                            combinedEdges: 10,
                            combinedFocus: 5,
                            combinedEndurance: 7,
                            perfectObedience: true
                        },
                        instructions: "Final challenge: Combine everything you've learned. Edge, focus, endure, obey."
                    }
                ],

                objectives: [
                    "Complete all 7 task types successfully",
                    "Achieve 10 perfect edges",
                    "Demonstrate mastery of Arc 1 skills"
                ],

                rewards: {
                    xp: 500,
                    unlocks: ['Level 6', 'Arc 2: Exploration'],
                    achievements: ['Arc 1 Complete', 'Foundation Master'],
                    bonuses: {
                        preferenceUpdate: true,
                        libraryAccess: 'expanded'
                    }
                },

                story: {
                    intro: "This is your first checkpoint. A comprehensive assessment of your progress through Arc 1. Show me everything you've learned.",
                    checkpoint: {
                        preferenceModal: true,
                        progressSummary: true,
                        statsDisplay: true
                    },
                    outro: "Outstanding. You've completed Arc 1: Awakening. You've built the foundation - control, endurance, focus, obedience. Arc 2 awaits."
                },

                completion: {
                    required: {
                        tasksCompleted: 7,
                        edgesAchieved: 10,
                        focusTime: 5,
                        enduranceTime: 7,
                        timeSpent: 30
                    },
                    optional: {
                        perfectScore: true,
                        allBonusesEarned: true
                    }
                }
            },

            // ARC 2: EXPLORATION (Levels 6-10)
            6: {
                levelNumber: 6,
                arc: 2,
                arcName: "Exploration",
                title: "New Sensations",
                subtitle: "Expanding Your Horizons",
                description: "Arc 2 begins. Explore new types of content, new stroking techniques, new ways to build arousal.",

                session: {
                    duration: { min: 30, target: 35, max: 40 },
                    tasks: {
                        total: 6,
                        types: ['edge', 'explore', 'pattern', 'focus', 'endurance', 'obey'],
                        difficulty: 'intermediate'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 10,
                        duration: 45
                    }
                },

                media: {
                    videos: {
                        required: 6,
                        categories: ['varied', 'exploration', 'new-experiences'],
                        duration: { min: 10, max: 30 },
                        preferenceWeight: 0.5
                    },
                    images: {
                        required: 10,
                        categories: ['varied', 'artistic', 'intense'],
                        timing: 'exploration-phase'
                    }
                },

                tasks: [
                    {
                        type: 'explore',
                        duration: 300,
                        content: 'outside-comfort-zone',
                        instructions: "Try content you don't usually watch. Explore new categories. Open your mind.",
                        categories: 'suggested-expansion'
                    },
                    {
                        type: 'edge',
                        count: 10,
                        duration: 150,
                        intensity: 'moderate-intense',
                        instructions: "Ten edges with new content. See how different stimuli affect you.",
                        successCriteria: {
                            edges: 10,
                            cooldown: 50
                        }
                    },
                    {
                        type: 'pattern',
                        duration: 300,
                        pattern: {
                            sequence: 'exploratory',
                            variation: 'high',
                            technique: ['grip-variation', 'speed-changes', 'pressure-control']
                        },
                        instructions: "Try different techniques. Vary grip, speed, pressure. Find what works."
                    },
                    {
                        type: 'focus',
                        duration: 240,
                        target: 'diverse-content',
                        instructions: "Rapid content switching. See what captures your attention most.",
                        distractions: 'moderate'
                    },
                    {
                        type: 'endurance',
                        duration: 360,
                        stroking: {
                            pace: 'experimental',
                            pattern: 'varied',
                            breaks: 'minimal'
                        },
                        instructions: "Six minutes exploring different stroking styles. Find your preferences."
                    },
                    {
                        type: 'obey',
                        commands: ['explore', 'switch', 'try-new', 'experiment'],
                        timing: 'guidance',
                        instructions: "Commands will guide your exploration. Be open to new experiences."
                    }
                ],

                objectives: [
                    "Try at least 3 new content categories",
                    "Experiment with different stroking techniques",
                    "Complete 10 edges with varied content"
                ],

                rewards: {
                    xp: 300,
                    unlocks: ['Level 7'],
                    achievements: ['Explorer']
                },

                story: {
                    intro: "Welcome to Arc 2: Exploration. Now that you have the foundation, it's time to expand. Try new things. Find what truly excites you.",
                    checkpoint: null,
                    outro: "Good exploration. You're learning what works for you. This self-knowledge is crucial."
                },

                completion: {
                    required: {
                        tasksCompleted: 6,
                        edgesAchieved: 10,
                        categoriesExplored: 3,
                        timeSpent: 30
                    },
                    optional: {
                        techniquesDiscovered: 5,
                        perfectAdaptation: true
                    }
                }
            },

            7: {
                levelNumber: 7,
                arc: 2,
                arcName: "Exploration",
                title: "Variety Training",
                subtitle: "Master Multiple Modes",
                description: "Learn to switch between different arousal modes. Fast and slow, intense and gentle, visual and mental.",

                session: {
                    duration: { min: 35, target: 40, max: 45 },
                    tasks: {
                        total: 6,
                        types: ['edge', 'variety', 'switching', 'focus', 'pattern', 'obey'],
                        difficulty: 'intermediate'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 12,
                        duration: 60
                    }
                },

                media: {
                    videos: {
                        required: 8,
                        categories: ['high-variety', 'contrast-content'],
                        duration: { min: 5, max: 35 },
                        preferenceWeight: 0.6
                    },
                    images: {
                        required: 12,
                        categories: ['varied', 'contrasting'],
                        timing: 'mode-switches'
                    }
                },

                tasks: [
                    {
                        type: 'variety',
                        duration: 420,
                        modes: ['intense', 'gentle', 'fast', 'slow', 'visual', 'mental'],
                        switchInterval: 60,
                        instructions: "Switch between modes every minute. Intense then gentle. Fast then slow. Adapt quickly."
                    },
                    {
                        type: 'edge',
                        count: 12,
                        duration: 120,
                        intensity: 'varied',
                        variety: 'required',
                        instructions: "Twelve edges. Each one different. Vary speed, grip, content, technique.",
                        successCriteria: {
                            edges: 12,
                            cooldown: 40,
                            varietyRequired: true
                        }
                    },
                    {
                        type: 'switching',
                        duration: 300,
                        between: ['content-types', 'techniques', 'intensities'],
                        instructions: "Rapid switching drill. Change content, technique, intensity. Stay aroused through transitions."
                    },
                    {
                        type: 'focus',
                        duration: 240,
                        target: 'contrasting-content',
                        instructions: "Focus on contrasting content types. Maintain arousal despite variety.",
                        distractions: 'high'
                    },
                    {
                        type: 'pattern',
                        duration: 360,
                        pattern: {
                            sequence: 'complex-variety',
                            modes: ['fast-intense', 'slow-gentle', 'medium-steady'],
                            transitions: 'smooth'
                        },
                        instructions: "Complex pattern with smooth transitions between different modes."
                    },
                    {
                        type: 'obey',
                        commands: ['switch-mode', 'change-speed', 'new-content', 'adapt'],
                        timing: 'frequent',
                        instructions: "Frequent mode-switching commands. Adapt quickly and smoothly."
                    }
                ],

                objectives: [
                    "Switch between 6 different arousal modes",
                    "Complete 12 edges with variety",
                    "Maintain arousal through all transitions"
                ],

                rewards: {
                    xp: 350,
                    unlocks: ['Level 8'],
                    achievements: ['Versatile Student']
                },

                story: {
                    intro: "Versatility is strength. Today you learn to adapt - switching modes, varying techniques, maintaining arousal through change.",
                    checkpoint: null,
                    outro: "Excellent adaptability. You're no longer limited to one mode. This flexibility will serve you well."
                },

                completion: {
                    required: {
                        tasksCompleted: 6,
                        edgesAchieved: 12,
                        modesSwitched: 6,
                        timeSpent: 35
                    },
                    optional: {
                        smoothTransitions: true,
                        noArousalDrop: true
                    }
                }
            },

            8: {
                levelNumber: 8,
                arc: 2,
                arcName: "Exploration",
                title: "Extended Sessions",
                subtitle: "Building Stamina",
                description: "Longer sessions to test your growing stamina. Maintain focus and arousal for extended periods.",

                session: {
                    duration: { min: 40, target: 50, max: 60 },
                    tasks: {
                        total: 7,
                        types: ['endurance', 'edge', 'marathon', 'focus', 'pattern', 'denial', 'obey'],
                        difficulty: 'intermediate-advanced'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 15,
                        duration: 90
                    }
                },

                media: {
                    videos: {
                        required: 10,
                        categories: 'user-preferences',
                        duration: { min: 15, max: 45 },
                        preferenceWeight: 0.7
                    },
                    images: {
                        required: 15,
                        categories: 'user-preferences',
                        timing: 'throughout'
                    }
                },

                tasks: [
                    {
                        type: 'marathon',
                        duration: 600,
                        phase: 'warm-up',
                        stroking: {
                            pace: 'gradual-build',
                            pattern: 'sustainable',
                            breaks: 'strategic'
                        },
                        instructions: "Ten minute marathon warm-up. Pace yourself. Build arousal gradually."
                    },
                    {
                        type: 'endurance',
                        duration: 480,
                        stroking: {
                            pace: 'steady-moderate',
                            pattern: 'consistent',
                            breaks: 'minimal'
                        },
                        instructions: "Eight minutes steady stroking. Find your rhythm. Maintain it."
                    },
                    {
                        type: 'edge',
                        count: 15,
                        duration: 180,
                        intensity: 'sustained',
                        instructions: "Fifteen edges over the session. Pace them out. Control is key.",
                        successCriteria: {
                            edges: 15,
                            cooldown: 90,
                            distribution: 'even'
                        }
                    },
                    {
                        type: 'focus',
                        duration: 360,
                        target: 'extended-content',
                        instructions: "Six minutes pure focus. Watch longer videos. Let them draw you in.",
                        distractions: 'low',
                        arousal: 'sustained-high'
                    },
                    {
                        type: 'pattern',
                        duration: 420,
                        pattern: {
                            sequence: 'marathon-sustainable',
                            complexity: 'moderate',
                            stamina: 'required'
                        },
                        instructions: "Sustainable pattern for seven minutes. Conserve energy but stay aroused."
                    },
                    {
                        type: 'denial',
                        duration: 300,
                        stroking: 'continuous',
                        edging: 'forbidden',
                        challenge: 'extended-stamina',
                        instructions: "Five minutes of denial. Stroke continuously but don't edge. Test your limits."
                    },
                    {
                        type: 'obey',
                        commands: ['pace', 'sustain', 'breathe', 'hydrate'],
                        timing: 'stamina-support',
                        instructions: "Commands to help you maintain stamina. Follow them for best results."
                    }
                ],

                objectives: [
                    "Complete 50+ minute session",
                    "Achieve 15 edges evenly distributed",
                    "Demonstrate sustained arousal control"
                ],

                rewards: {
                    xp: 400,
                    unlocks: ['Level 9'],
                    achievements: ['Endurance Champion']
                },

                story: {
                    intro: "Extended sessions separate the committed from the casual. Today we build real stamina.",
                    checkpoint: null,
                    outro: "Impressive endurance. You're learning to sustain arousal for extended periods. This is true progress."
                },

                completion: {
                    required: {
                        tasksCompleted: 7,
                        edgesAchieved: 15,
                        marathonTime: 10,
                        timeSpent: 40
                    },
                    optional: {
                        fullDuration: 50,
                        perfectPacing: true
                    }
                }
            },

            9: {
                levelNumber: 9,
                arc: 2,
                arcName: "Exploration",
                title: "Advanced Techniques",
                subtitle: "Mastering the Craft",
                description: "Learn advanced edging techniques, complex patterns, and sophisticated arousal control methods.",

                session: {
                    duration: { min: 40, target: 45, max: 55 },
                    tasks: {
                        total: 7,
                        types: ['technique', 'edge', 'pattern', 'focus', 'multi-task', 'challenge', 'obey'],
                        difficulty: 'advanced'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 12,
                        duration: 60
                    }
                },

                media: {
                    videos: {
                        required: 10,
                        categories: 'advanced-content',
                        duration: { min: 15, max: 40 },
                        preferenceWeight: 0.7
                    },
                    images: {
                        required: 15,
                        categories: 'advanced',
                        timing: 'technique-practice'
                    }
                },

                tasks: [
                    {
                        type: 'technique',
                        duration: 420,
                        techniques: ['stop-start', 'squeeze', 'breathing', 'mental-control', 'grip-variation'],
                        instructions: "Learn and practice five advanced techniques. Master each one.",
                        practice: 'deliberate'
                    },
                    {
                        type: 'edge',
                        count: 15,
                        duration: 240,
                        intensity: 'advanced',
                        techniques: 'apply-learned',
                        instructions: "Fifteen edges using advanced techniques. Show your mastery.",
                        successCriteria: {
                            edges: 15,
                            cooldown: 60,
                            techniqueVariety: 5
                        }
                    },
                    {
                        type: 'pattern',
                        duration: 360,
                        pattern: {
                            sequence: 'advanced-complex',
                            techniques: 'integrated',
                            precision: 'high'
                        },
                        instructions: "Advanced pattern integrating multiple techniques. Precision required."
                    },
                    {
                        type: 'focus',
                        duration: 300,
                        target: 'technique-application',
                        instructions: "Focus on applying techniques while watching. Mental and physical coordination.",
                        distractions: 'high',
                        coordination: 'required'
                    },
                    {
                        type: 'multi-task',
                        duration: 360,
                        tasks: ['edge', 'focus', 'pattern'],
                        simultaneity: 'required',
                        instructions: "Multi-task challenge. Edge while maintaining focus and following pattern."
                    },
                    {
                        type: 'challenge',
                        description: 'technique-mastery',
                        requirements: {
                            techniquesApplied: 5,
                            edgesWithTechnique: 10,
                            patternPrecision: 0.9
                        },
                        instructions: "Demonstrate mastery of all five techniques in combination."
                    },
                    {
                        type: 'obey',
                        commands: ['apply-technique', 'switch-technique', 'combine', 'perfect'],
                        timing: 'technique-guidance',
                        instructions: "Commands will guide technique application. Execute perfectly."
                    }
                ],

                objectives: [
                    "Master 5 advanced edging techniques",
                    "Apply techniques in 15 edges",
                    "Demonstrate multi-tasking ability"
                ],

                rewards: {
                    xp: 450,
                    unlocks: ['Level 10'],
                    achievements: ['Technique Master', 'Advanced Practitioner']
                },

                story: {
                    intro: "You've learned the basics. Now we refine. Advanced techniques that separate the skilled from the masterful.",
                    checkpoint: null,
                    outro: "Exceptional technique work. You're no longer just edging - you're mastering the art of control."
                },

                completion: {
                    required: {
                        tasksCompleted: 7,
                        edgesAchieved: 15,
                        techniquesLearned: 5,
                        timeSpent: 40
                    },
                    optional: {
                        perfectTechniqueExecution: true,
                        allChallengesCompleted: true
                    }
                }
            },

            10: {
                levelNumber: 10,
                arc: 2,
                arcName: "Exploration",
                title: "Checkpoint: Major Milestone",
                subtitle: "Prove Your Exploration",
                description: "Arc 2 checkpoint. Demonstrate everything learned through exploration. Show your versatility, stamina, and technique mastery.",

                session: {
                    duration: { min: 50, target: 60, max: 75 },
                    tasks: {
                        total: 9,
                        types: ['edge', 'endurance', 'technique', 'variety', 'focus', 'pattern', 'multi-task', 'challenge', 'obey'],
                        difficulty: 'advanced'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 15,
                        duration: 90
                    }
                },

                media: {
                    videos: {
                        required: 12,
                        categories: 'user-preferences',
                        duration: { min: 10, max: 60 },
                        preferenceWeight: 1.0
                    },
                    images: {
                        required: 20,
                        categories: 'user-preferences',
                        timing: 'throughout'
                    }
                },

                tasks: [
                    {
                        type: 'edge',
                        count: 20,
                        duration: 300,
                        intensity: 'comprehensive',
                        variety: 'all-techniques',
                        instructions: "Twenty edges. Use all techniques learned. Show complete mastery.",
                        successCriteria: {
                            edges: 20,
                            cooldown: 60,
                            techniqueVariety: 5,
                            varietyRequired: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 600,
                        stroking: {
                            pace: 'varied-advanced',
                            pattern: 'complex',
                            breaks: 'strategic-minimal'
                        },
                        instructions: "Ten minute endurance test. Demonstrate stamina and control."
                    },
                    {
                        type: 'technique',
                        duration: 480,
                        techniques: 'all-advanced',
                        application: 'masterful',
                        instructions: "Eight minutes of technique demonstration. Show perfect execution."
                    },
                    {
                        type: 'variety',
                        duration: 420,
                        modes: 'all-learned',
                        switching: 'fluid',
                        instructions: "Demonstrate versatility. Switch between all modes learned. Fluid transitions."
                    },
                    {
                        type: 'focus',
                        duration: 420,
                        target: 'comprehensive-content',
                        instructions: "Seven minutes of intense focus. Varied content. Sustained arousal.",
                        distractions: 'extreme',
                        arousal: 'critical-sustained'
                    },
                    {
                        type: 'pattern',
                        duration: 480,
                        pattern: {
                            sequence: 'checkpoint-complex',
                            techniques: 'all',
                            precision: 'maximum'
                        },
                        instructions: "Most complex pattern yet. Integrate everything. Perfect execution."
                    },
                    {
                        type: 'multi-task',
                        duration: 420,
                        tasks: 'all-types',
                        complexity: 'maximum',
                        instructions: "Ultimate multi-tasking. Edge, focus, pattern, obey - all simultaneously."
                    },
                    {
                        type: 'challenge',
                        description: 'arc2-comprehensive',
                        requirements: {
                            edges: 20,
                            endurance: 10,
                            techniques: 5,
                            modes: 6,
                            multitasking: true,
                            perfectExecution: true
                        },
                        instructions: "Final Arc 2 challenge. Everything you've learned. Perfect execution required."
                    },
                    {
                        type: 'obey',
                        commands: 'comprehensive-all',
                        timing: 'complex-adaptive',
                        instructions: "All command types. Complex timing. Adaptive difficulty. Perfect obedience."
                    }
                ],

                objectives: [
                    "Complete 20 edges with all techniques",
                    "Demonstrate 10+ minutes endurance",
                    "Show mastery of all Arc 2 skills",
                    "Perfect multi-tasking performance"
                ],

                rewards: {
                    xp: 750,
                    unlocks: ['Level 11', 'Arc 3: Dedication'],
                    achievements: ['Arc 2 Complete', 'Exploration Master', 'Major Milestone'],
                    bonuses: {
                        preferenceUpdate: true,
                        libraryAccess: 'full',
                        techniqueUnlocks: 'advanced-set'
                    }
                },

                story: {
                    intro: "Checkpoint 2. You've explored, experimented, and expanded your capabilities. Now prove your mastery of Arc 2.",
                    checkpoint: {
                        preferenceModal: true,
                        progressSummary: true,
                        statsDisplay: true,
                        achievementShowcase: true
                    },
                    outro: "Outstanding performance. Arc 2: Exploration is complete. You've become versatile, skilled, and enduring. Arc 3: Dedication awaits - where true commitment is forged."
                },

                completion: {
                    required: {
                        tasksCompleted: 9,
                        edgesAchieved: 20,
                        enduranceTime: 10,
                        techniquesApplied: 5,
                        timeSpent: 50
                    },
                    optional: {
                        perfectScore: true,
                        allBonusesEarned: true,
                        recordBreaking: true
                    }
                }
            },

            // ARC 3: DEDICATION (Levels 11-15)
            11: {
                levelNumber: 11,
                arc: 3,
                arcName: "Dedication",
                title: "Commitment",
                subtitle: "True Dedication Begins",
                description: "Arc 3: Dedication. This is where casual participants fall away. Only the truly committed continue. Prove your dedication.",

                session: {
                    duration: { min: 50, target: 60, max: 70 },
                    tasks: {
                        total: 8,
                        types: ['commitment', 'edge', 'endurance', 'discipline', 'focus', 'sacrifice', 'obey', 'challenge'],
                        difficulty: 'advanced'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 15,
                        duration: 60
                    }
                },

                media: {
                    videos: {
                        required: 12,
                        categories: ['intense', 'demanding', 'commitment-focused'],
                        duration: { min: 15, max: 50 },
                        preferenceWeight: 0.7
                    },
                    images: {
                        required: 20,
                        categories: ['intense', 'demanding'],
                        timing: 'throughout'
                    }
                },

                tasks: [
                    {
                        type: 'commitment',
                        duration: 720,
                        phase: 'dedication-test',
                        requirements: {
                            consistentArousal: true,
                            noBackingDown: true,
                            fullAttention: true
                        },
                        instructions: "Twelve minutes of pure commitment. No breaks. No hesitation. Full dedication."
                    },
                    {
                        type: 'edge',
                        count: 20,
                        duration: 240,
                        intensity: 'demanding',
                        commitment: 'required',
                        instructions: "Twenty edges. Prove your commitment to the training. No shortcuts.",
                        successCriteria: {
                            edges: 20,
                            cooldown: 60,
                            perfectControl: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 720,
                        stroking: {
                            pace: 'challenging',
                            pattern: 'sustained-difficult',
                            breaks: 'none'
                        },
                        instructions: "Twelve minutes continuous. No breaks. This is where dedication shows."
                    },
                    {
                        type: 'discipline',
                        duration: 360,
                        rules: ['no-stopping', 'maintain-pace', 'follow-commands', 'no-edge'],
                        instructions: "Discipline test. Stroke continuously. Follow all rules. Never edge."
                    },
                    {
                        type: 'focus',
                        duration: 480,
                        target: 'challenging-content',
                        instructions: "Eight minutes intense focus. Challenging content. Maintain arousal. No breaks.",
                        distractions: 'extreme',
                        arousal: 'critical-sustained'
                    },
                    {
                        type: 'sacrifice',
                        duration: 300,
                        give: 'comfort',
                        gain: 'progress',
                        instructions: "Sacrifice comfort for progress. Challenging positions, difficult pace. Dedication requires sacrifice."
                    },
                    {
                        type: 'challenge',
                        description: 'dedication-proof',
                        requirements: {
                            commitmentTime: 12,
                            edges: 20,
                            endurance: 12,
                            disciplineScore: 0.95
                        },
                        instructions: "Prove your dedication. Complete all requirements without wavering."
                    },
                    {
                        type: 'obey',
                        commands: ['commit', 'endure', 'sacrifice', 'persist'],
                        timing: 'demanding',
                        instructions: "Commands will push you. Obey without hesitation. Show your dedication."
                    }
                ],

                objectives: [
                    "Complete 12+ minute commitment session",
                    "Achieve 20 perfect edges",
                    "Demonstrate unwavering discipline",
                    "Make meaningful sacrifices for progress"
                ],

                rewards: {
                    xp: 500,
                    unlocks: ['Level 12'],
                    achievements: ['Dedicated Student']
                },

                story: {
                    intro: "Welcome to Arc 3: Dedication. This is where we separate those who play from those who commit. Are you truly dedicated?",
                    checkpoint: null,
                    outro: "You've proven your dedication. This level of commitment will carry you through the challenges ahead."
                },

                completion: {
                    required: {
                        tasksCompleted: 8,
                        edgesAchieved: 20,
                        commitmentTime: 12,
                        enduranceTime: 12,
                        disciplineScore: 0.9,
                        timeSpent: 50
                    },
                    optional: {
                        perfectDedication: true,
                        noBackingDown: true
                    }
                }
            },

            12: {
                levelNumber: 12,
                arc: 3,
                arcName: "Dedication",
                title: "Deeper Commitment",
                subtitle: "Beyond Your Limits",
                description: "Push beyond what you thought possible. True dedication means going further than you've ever gone.",

                session: {
                    duration: { min: 55, target: 65, max: 75 },
                    tasks: {
                        total: 8,
                        types: ['push-limits', 'edge', 'endurance', 'mental-strength', 'focus', 'perseverance', 'challenge', 'obey'],
                        difficulty: 'advanced'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 18,
                        duration: 90
                    }
                },

                media: {
                    videos: {
                        required: 14,
                        categories: ['extreme', 'pushing-boundaries'],
                        duration: { min: 20, max: 60 },
                        preferenceWeight: 0.7
                    },
                    images: {
                        required: 22,
                        categories: ['extreme', 'intense'],
                        timing: 'limit-pushing'
                    }
                },

                tasks: [
                    {
                        type: 'push-limits',
                        duration: 900,
                        beyond: 'comfort-zone',
                        requirements: {
                            longerThanBefore: true,
                            harderThanBefore: true,
                            deeperThanBefore: true
                        },
                        instructions: "Fifteen minutes pushing your limits. Go beyond. This is growth."
                    },
                    {
                        type: 'edge',
                        count: 25,
                        duration: 300,
                        intensity: 'extreme',
                        limitPushing: 'required',
                        instructions: "Twenty-five edges. More than ever before. Push your control limits.",
                        successCriteria: {
                            edges: 25,
                            cooldown: 50,
                            newPersonalBest: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 900,
                        stroking: {
                            pace: 'extreme',
                            pattern: 'relentless',
                            breaks: 'none'
                        },
                        instructions: "Fifteen minutes continuous. Your longest yet. Endure."
                    },
                    {
                        type: 'mental-strength',
                        duration: 420,
                        challenges: ['pain', 'exhaustion', 'doubt', 'temptation'],
                        overcome: 'all',
                        instructions: "Mental strength test. Overcome pain, exhaustion, doubt. Your mind is stronger than you think."
                    },
                    {
                        type: 'focus',
                        duration: 540,
                        target: 'extreme-content',
                        instructions: "Nine minutes extreme focus. Beyond your previous limits.",
                        distractions: 'maximum',
                        arousal: 'beyond-critical'
                    },
                    {
                        type: 'perseverance',
                        duration: 600,
                        difficulty: 'increasing',
                        quitAllowed: 'no',
                        instructions: "Ten minutes of increasing difficulty. Quitting is not an option. Persevere."
                    },
                    {
                        type: 'challenge',
                        description: 'limit-breaking',
                        requirements: {
                            personalBests: 3,
                            edges: 25,
                            endurance: 15,
                            mentalStrength: 0.95
                        },
                        instructions: "Break your personal limits. Set new records. This is dedication."
                    },
                    {
                        type: 'obey',
                        commands: ['push', 'endure', 'overcome', 'persist'],
                        timing: 'relentless',
                        instructions: "Commands will push you to your limits. Obey. Do not break."
                    }
                ],

                objectives: [
                    "Push beyond previous limits in 3+ areas",
                    "Achieve 25 edges - new personal best",
                    "Complete 15 minute endurance",
                    "Demonstrate unbreakable mental strength"
                ],

                rewards: {
                    xp: 550,
                    unlocks: ['Level 13'],
                    achievements: ['Limit Breaker']
                },

                story: {
                    intro: "Dedication means pushing limits. Today you go further than ever before. Find strength you didn't know you had.",
                    checkpoint: null,
                    outro: "You've broken through barriers. What once seemed impossible is now achieved. This is real growth."
                },

                completion: {
                    required: {
                        tasksCompleted: 8,
                        edgesAchieved: 25,
                        enduranceTime: 15,
                        personalBests: 3,
                        timeSpent: 55
                    },
                    optional: {
                        unbroken: true,
                        recordBreaking: true
                    }
                }
            },

            13: {
                levelNumber: 13,
                arc: 3,
                arcName: "Dedication",
                title: "Sustained Excellence",
                subtitle: "Consistency is Key",
                description: "Excellence isn't a one-time achievement. Maintain peak performance throughout an extended session.",

                session: {
                    duration: { min: 60, target: 70, max: 85 },
                    tasks: {
                        total: 9,
                        types: ['sustained', 'edge', 'endurance', 'consistency', 'focus', 'performance', 'marathon', 'challenge', 'obey'],
                        difficulty: 'advanced-expert'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 20,
                        duration: 120
                    }
                },

                media: {
                    videos: {
                        required: 15,
                        categories: 'user-preferences',
                        duration: { min: 20, max: 70 },
                        preferenceWeight: 0.8
                    },
                    images: {
                        required: 25,
                        categories: 'user-preferences',
                        timing: 'sustained'
                    }
                },

                tasks: [
                    {
                        type: 'sustained',
                        duration: 1200,
                        performance: 'peak',
                        consistency: 'required',
                        instructions: "Twenty minutes of sustained peak performance. No drops in quality. Consistent excellence."
                    },
                    {
                        type: 'edge',
                        count: 30,
                        duration: 600,
                        intensity: 'sustained-high',
                        distribution: 'even',
                        instructions: "Thirty edges over ten minutes. Evenly paced. Perfect consistency.",
                        successCriteria: {
                            edges: 30,
                            cooldown: 15,
                            evenDistribution: true,
                            qualityConsistent: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 1200,
                        stroking: {
                            pace: 'consistent-high',
                            pattern: 'marathon',
                            breaks: 'strategic-minimal'
                        },
                        instructions: "Twenty minutes marathon endurance. Pace yourself. Maintain quality."
                    },
                    {
                        type: 'consistency',
                        duration: 720,
                        metrics: ['arousal', 'pace', 'focus', 'quality'],
                        variance: 'minimal',
                        instructions: "Twelve minutes of perfect consistency. No peaks and valleys. Steady excellence."
                    },
                    {
                        type: 'focus',
                        duration: 600,
                        target: 'extended-content',
                        instructions: "Ten minutes sustained focus. Long content. Maintained attention.",
                        distractions: 'high',
                        arousal: 'sustained-critical'
                    },
                    {
                        type: 'performance',
                        duration: 480,
                        standard: 'peak',
                        sustained: 'required',
                        instructions: "Eight minutes peak performance. Every second counts. No drops."
                    },
                    {
                        type: 'marathon',
                        duration: 1500,
                        phase: 'middle-arc',
                        pacing: 'expert',
                        instructions: "Twenty-five minute marathon. Expert pacing required. This is Arc 3."
                    },
                    {
                        type: 'challenge',
                        description: 'sustained-excellence',
                        requirements: {
                            sessionDuration: 60,
                            edges: 30,
                            endurance: 20,
                            consistencyScore: 0.95,
                            noPerformanceDrops: true
                        },
                        instructions: "Maintain excellence for the full session. No drops. No breaks in quality."
                    },
                    {
                        type: 'obey',
                        commands: ['sustain', 'maintain', 'consistent', 'steady'],
                        timing: 'consistency-support',
                        instructions: "Commands to help maintain consistency. Follow precisely."
                    }
                ],

                objectives: [
                    "Maintain peak performance for 60+ minutes",
                    "Complete 30 evenly-paced edges",
                    "Achieve 95%+ consistency score",
                    "Complete marathon session without quality drops"
                ],

                rewards: {
                    xp: 600,
                    unlocks: ['Level 14'],
                    achievements: ['Consistency Champion', 'Marathon Runner']
                },

                story: {
                    intro: "Anyone can excel once. True dedication is sustained excellence. Today you prove you can maintain peak performance.",
                    checkpoint: null,
                    outro: "Impressive consistency. You've shown that your dedication isn't fleeting - it's sustained and reliable."
                },

                completion: {
                    required: {
                        tasksCompleted: 9,
                        edgesAchieved: 30,
                        enduranceTime: 20,
                        marathonTime: 25,
                        consistencyScore: 0.9,
                        timeSpent: 60
                    },
                    optional: {
                        perfectConsistency: true,
                        recordMarathon: true
                    }
                }
            },

            14: {
                levelNumber: 14,
                arc: 3,
                arcName: "Dedication",
                title: "Total Immersion",
                subtitle: "Complete Dedication",
                description: "Total immersion in your training. Mind, body, and will completely dedicated to the session.",

                session: {
                    duration: { min: 65, target: 75, max: 90 },
                    tasks: {
                        total: 9,
                        types: ['immersion', 'edge', 'trance', 'dedication', 'focus', 'surrender', 'transformation', 'challenge', 'obey'],
                        difficulty: 'expert'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 20,
                        duration: 90
                    }
                },

                media: {
                    videos: {
                        required: 16,
                        categories: ['immersive', 'hypnotic', 'transformative'],
                        duration: { min: 20, max: 75 },
                        preferenceWeight: 0.8
                    },
                    images: {
                        required: 28,
                        categories: ['immersive', 'hypnotic'],
                        timing: 'trance-induction'
                    }
                },

                tasks: [
                    {
                        type: 'immersion',
                        duration: 1800,
                        depth: 'total',
                        aspects: ['visual', 'mental', 'physical', 'emotional'],
                        instructions: "Thirty minutes total immersion. Let the training consume you completely."
                    },
                    {
                        type: 'edge',
                        count: 35,
                        duration: 720,
                        intensity: 'immersive',
                        mindState: 'trance',
                        instructions: "Thirty-five edges in a state of deep immersion. Let go. Let the training guide you.",
                        successCriteria: {
                            edges: 35,
                            cooldown: 10,
                            tranceState: true
                        }
                    },
                    {
                        type: 'trance',
                        duration: 900,
                        depth: 'deep',
                        maintenance: 'sustained',
                        instructions: "Fifteen minutes in trance. Let your mind sink. Stay in this state."
                    },
                    {
                        type: 'dedication',
                        duration: 600,
                        level: 'total',
                        aspects: 'all',
                        instructions: "Ten minutes of total dedication. Nothing else exists. Only the training."
                    },
                    {
                        type: 'focus',
                        duration: 720,
                        target: 'immersive-content',
                        instructions: "Twelve minutes immersed in content. Let it fill your awareness completely.",
                        distractions: 'none-internal',
                        arousal: 'trance-maintained'
                    },
                    {
                        type: 'surrender',
                        duration: 480,
                        to: 'training',
                        resistance: 'none',
                        instructions: "Surrender to the training. Stop fighting. Let it guide you completely."
                    },
                    {
                        type: 'transformation',
                        duration: 600,
                        from: 'resistant',
                        to: 'devoted',
                        instructions: "Feel yourself transforming. Resistance melts. Devotion grows. This is your path."
                    },
                    {
                        type: 'challenge',
                        description: 'total-immersion',
                        requirements: {
                            immersionTime: 30,
                            edges: 35,
                            tranceDepth: 0.9,
                            surrenderComplete: true
                        },
                        instructions: "Achieve total immersion. Complete surrender. Deep transformation."
                    },
                    {
                        type: 'obey',
                        commands: ['immerse', 'surrender', 'transform', 'become'],
                        timing: 'trance-deepening',
                        instructions: "Commands to deepen your immersion. Obey without thought. Let go."
                    }
                ],

                objectives: [
                    "Achieve 30 minutes total immersion",
                    "Complete 35 edges in trance state",
                    "Demonstrate complete surrender",
                    "Show transformation in dedication"
                ],

                rewards: {
                    xp: 650,
                    unlocks: ['Level 15'],
                    achievements: ['Fully Immersed', 'Devoted Student']
                },

                story: {
                    intro: "True dedication requires total immersion. Today you stop holding back. You surrender to the training completely.",
                    checkpoint: null,
                    outro: "You've experienced total immersion. This level of dedication transforms you. You're no longer the same person who started."
                },

                completion: {
                    required: {
                        tasksCompleted: 9,
                        edgesAchieved: 35,
                        immersionTime: 30,
                        tranceTime: 15,
                        surrenderComplete: true,
                        timeSpent: 65
                    },
                    optional: {
                        deepestTrance: true,
                        completeTransformation: true
                    }
                }
            },

            15: {
                levelNumber: 15,
                arc: 3,
                arcName: "Dedication",
                title: "Checkpoint: Mid-Point Mastery",
                subtitle: "Halfway to Excellence",
                description: "Checkpoint 3 - the midpoint of your journey. Demonstrate your dedication, consistency, and transformation. Update preferences and review progress.",

                session: {
                    duration: { min: 70, target: 90, max: 120 },
                    tasks: {
                        total: 10,
                        types: ['comprehensive', 'edge', 'endurance', 'dedication', 'immersion', 'focus', 'transformation', 'marathon', 'challenge', 'obey'],
                        difficulty: 'expert'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 25,
                        duration: 120
                    }
                },

                media: {
                    videos: {
                        required: 20,
                        categories: 'user-preferences',
                        duration: { min: 15, max: 90 },
                        preferenceWeight: 1.0
                    },
                    images: {
                        required: 35,
                        categories: 'user-preferences',
                        timing: 'throughout'
                    }
                },

                tasks: [
                    {
                        type: 'comprehensive',
                        duration: 2700,
                        phase: 'midpoint-assessment',
                        aspects: 'all-arc3',
                        instructions: "Forty-five minute comprehensive session. All Arc 3 skills. Complete demonstration."
                    },
                    {
                        type: 'edge',
                        count: 50,
                        duration: 1200,
                        intensity: 'comprehensive',
                        variety: 'all-learned',
                        instructions: "Fifty edges. Your greatest challenge yet. All techniques. Perfect execution.",
                        successCriteria: {
                            edges: 50,
                            cooldown: 10,
                            techniqueVariety: 'all',
                            perfectControl: true
                        }
                    },
                    {
                        type: 'endurance',
                        duration: 1800,
                        stroking: {
                            pace: 'expert-level',
                            pattern: 'comprehensive',
                            breaks: 'strategic'
                        },
                        instructions: "Thirty minutes endurance. Demonstrate mastery of pacing and stamina."
                    },
                    {
                        type: 'dedication',
                        duration: 1200,
                        proof: 'comprehensive',
                        aspects: 'all',
                        instructions: "Twenty minutes proving your dedication. Everything you've learned in Arc 3."
                    },
                    {
                        type: 'immersion',
                        duration: 1500,
                        depth: 'maximum',
                        maintenance: 'full-session',
                        instructions: "Twenty-five minutes deep immersion. Maintain trance state throughout."
                    },
                    {
                        type: 'focus',
                        duration: 900,
                        target: 'comprehensive-preferred',
                        instructions: "Fifteen minutes peak focus. Your favorite content. Complete absorption.",
                        distractions: 'none',
                        arousal: 'maximum-controlled'
                    },
                    {
                        type: 'transformation',
                        duration: 720,
                        showcase: 'journey',
                        fromStartToNow: true,
                        instructions: "Reflect on your transformation. From Level 1 to Level 15. How far you've come."
                    },
                    {
                        type: 'marathon',
                        duration: 3600,
                        phase: 'midpoint-ultimate',
                        expertise: 'demonstrated',
                        instructions: "One hour marathon. Your ultimate test. Expert-level pacing and control."
                    },
                    {
                        type: 'challenge',
                        description: 'arc3-mastery',
                        requirements: {
                            sessionDuration: 70,
                            edges: 50,
                            endurance: 30,
                            immersion: 25,
                            dedication: 20,
                            marathonComplete: 60,
                            perfectExecution: true
                        },
                        instructions: "Demonstrate complete mastery of Arc 3: Dedication. All skills. Perfect execution."
                    },
                    {
                        type: 'obey',
                        commands: 'comprehensive-all',
                        timing: 'expert-adaptive',
                        instructions: "All commands. Expert timing. Complete obedience. Perfect execution."
                    }
                ],

                objectives: [
                    "Complete 70+ minute comprehensive session",
                    "Achieve 50 perfect edges",
                    "Demonstrate 30 minutes endurance",
                    "Complete 60 minute marathon",
                    "Show complete Arc 3 mastery"
                ],

                rewards: {
                    xp: 1000,
                    unlocks: ['Level 16', 'Arc 4: Transformation'],
                    achievements: ['Arc 3 Complete', 'Dedicated Master', 'Midpoint Champion', 'Halfway to Excellence'],
                    bonuses: {
                        preferenceUpdate: true,
                        libraryAccess: 'premium',
                        techniqueUnlocks: 'expert-set',
                        transformationBadge: true
                    }
                },

                story: {
                    intro: "Checkpoint 3. The midpoint. You've come so far. From beginner to dedicated expert. Now prove everything you've learned.",
                    checkpoint: {
                        preferenceModal: true,
                        progressSummary: true,
                        statsDisplay: true,
                        achievementShowcase: true,
                        transformationReview: true
                    },
                    outro: "Extraordinary. Arc 3: Dedication is complete. You're halfway through your journey. The foundation is solid. The dedication is proven. Arc 4: Transformation awaits - where you become something more."
                },

                completion: {
                    required: {
                        tasksCompleted: 10,
                        edgesAchieved: 50,
                        enduranceTime: 30,
                        immersionTime: 25,
                        marathonTime: 60,
                        timeSpent: 70
                    },
                    optional: {
                        perfectScore: true,
                        recordBreaking: true,
                        allBonusesEarned: true,
                        legendaryPerformance: true
                    }
                }
            },

            // ARC 4: TRANSFORMATION (Levels 16-20)  
            16: {
                levelNumber: 16,
                arc: 4,
                arcName: "Transformation",
                title: "Evolution",
                subtitle: "Becoming Something More",
                description: "Arc 4: Transformation. You're no longer who you were. Now you evolve into what you're meant to become.",

                session: {
                    duration: { min: 70, target: 80, max: 100 },
                    tasks: {
                        total: 9,
                        types: ['evolution', 'edge', 'identity', 'reshaping', 'focus', 'acceptance', 'becoming', 'challenge', 'obey'],
                        difficulty: 'expert'
                    },
                    breaks: {
                        enabled: true,
                        frequency: 20,
                        duration: 90
                    }
                },

                media: {
                    videos: {
                        required: 18,
                        categories: ['transformative', 'identity-focused', 'evolution'],
                        duration: { min: 20, max: 80 },
                        preferenceWeight: 0.8
                    },
                    images: {
                        required: 30,
                        categories: ['transformative', 'powerful'],
                        timing: 'transformation-moments'
                    }
                },

                tasks: [
                    {
                        type: 'evolution',
                        duration: 1200,
                        from: 'old-self',
                        to: 'new-self',
                        process: 'conscious',
                        instructions: "Twenty minutes of conscious evolution. Feel yourself changing. Becoming."
                    },
                    {
                        type: 'edge',
                        count: 40,
                        duration: 900,
                        intensity: 'transformative',
                        meaning: 'evolution',
                        instructions: "Forty edges that transform you. Each one changes you slightly. By the end, you're different.",
                        successCriteria: {
                            edges: 40,
                            cooldown: 15,
                            transformationFelt: true
                        }
                    },
                    {
                        type: 'identity',
                        duration: 720,
                        exploration: 'deep',
                        reshaping: 'active',
                        instructions: "Who are you becoming? Explore your evolving identity. Accept the changes."
                    },
                    {
                        type: 'reshaping',
                        duration: 600,
                        aspects: ['desires', 'preferences', 'responses', 'identity'],
                        instructions: "Active reshaping. Your desires evolve. Your responses change. This is transformation."
                    },
                    {
                        type: 'focus',
                        duration: 720,
                        target: 'transformative-content',
                        instructions: "Focus on content that transforms you. Let it reshape your desires.",
                        distractions: 'internal-resistance',
                        arousal: 'transformative'
                    },
                    {
                        type: 'acceptance',
                        duration: 480,
                        of: 'transformation',
                        resistance: 'release',
                        instructions: "Accept your transformation. Stop resisting. This is who you're becoming."
                    },
                    {
                        type: 'becoming',
                        duration: 900,
                        process: 'active',
                        awareness: 'maintained',
                        instructions: "Fifteen minutes of active becoming. Watch yourself transform. Feel it happening."
                    },
                    {
                        type: 'challenge',
                        description: 'transformation-proof',
                        requirements: {
                            evolutionTime: 20,
                            edges: 40,
                            identityExploration: true,
                            acceptanceComplete: true
                        },
                        instructions: "Prove your transformation is real. Show how you've changed."
                    },
                    {
                        type: 'obey',
                        commands: ['evolve', 'transform', 'become', 'accept'],
                        timing: 'transformation-support',
                        instructions: "Commands to guide your transformation. Obey. Let them reshape you."
                    }
                ],

                objectives: [
                    "Complete 20 minutes conscious evolution",
                    "Achieve 40 transformative edges",
                    "Demonstrate identity exploration",
                    "Show complete acceptance of transformation"
                ],

                rewards: {
                    xp: 700,
                    unlocks: ['Level 17'],
                    achievements: ['Evolved Being']
                },

                story: {
                    intro: "Welcome to Arc 4: Transformation. The second half of your journey begins. You're no longer the person who started. Now you actively shape who you're becoming.",
                    checkpoint: null,
                    outro: "You feel it, don't you? The transformation is real. You're evolving into something more."
                },

                completion: {
                    required: {
                        tasksCompleted: 9,
                        edgesAchieved: 40,
                        evolutionTime: 20,
                        acceptanceShown: true,
                        timeSpent: 70
                    },
                    optional: {
                        deepTransformation: true,
                        resistanceGone: true
                    }
                }
            }

            // Levels 17-30 generated programmatically
        };
        
        // Merge manually configured levels with generated ones
        return { ...manualLevels, ...this.generateRemainingLevels() };
    }

    /**
     * Generate remaining levels programmatically
     * Levels 17-30 follow progression patterns with increasing difficulty
     */
    generateRemainingLevels() {
        const remaining = {};
        
        // Arc 4 completion (17-20)
        const arc4Levels = [
            { num: 17, title: "Deep Changes", edges: 45, duration: 75 },
            { num: 18, title: "New Identity", edges: 50, duration: 80 },
            { num: 19, title: "Living Transformed", edges: 55, duration: 85 },
            { num: 20, title: "Checkpoint: Transformation Complete", edges: 75, duration: 90, checkpoint: true }
        ];
        
        // Arc 5: Mastery (21-25)
        const arc5Levels = [
            { num: 21, title: "Advanced Training", edges: 60, duration: 90 },
            { num: 22, title: "Perfecting Technique", edges: 65, duration: 95 },
            { num: 23, title: "Expert Performance", edges: 70, duration: 100 },
            { num: 24, title: "Near Perfection", edges: 75, duration: 105 },
            { num: 25, title: "Checkpoint: Mastery Achieved", edges: 100, duration: 120, checkpoint: true }
        ];
        
        // Arc 6: Transcendence (26-30)
        const arc6Levels = [
            { num: 26, title: "Expert Trials", edges: 80, duration: 110 },
            { num: 27, title: "Beyond Limits", edges: 90, duration: 120 },
            { num: 28, title: "Peak Performance", edges: 100, duration: 130 },
            { num: 29, title: "Ultimate Challenge", edges: 120, duration: 150 },
            { num: 30, title: "Final Checkpoint: Ultimate Achievement", edges: 150, duration: 180, checkpoint: true }
        ];
        
        [...arc4Levels, ...arc5Levels, ...arc6Levels].forEach(level => {
            const arcNum = level.num <= 20 ? 4 : (level.num <= 25 ? 5 : 6);
            const arcName = arcNum === 4 ? "Transformation" : (arcNum === 5 ? "Mastery" : "Transcendence");
            
            remaining[level.num] = {
                levelNumber: level.num,
                arc: arcNum,
                arcName: arcName,
                title: level.title,
                subtitle: `Arc ${arcNum} Progress`,
                description: `Level ${level.num} of The Academy training program.`,
                
                session: {
                    duration: { min: level.duration - 10, target: level.duration, max: level.duration + 20 },
                    tasks: {
                        total: 8 + Math.floor(level.num / 5),
                        types: ['edge', 'endurance', 'focus', 'pattern', 'obey', 'challenge'],
                        difficulty: level.num < 21 ? 'expert' : (level.num < 26 ? 'master' : 'transcendent')
                    },
                    breaks: {
                        enabled: true,
                        frequency: 15 + Math.floor(level.num / 3),
                        duration: 90 + (level.num * 2)
                    }
                },
                
                media: {
                    videos: {
                        required: 10 + level.num,
                        categories: level.checkpoint ? 'user-preferences' : 'advanced',
                        duration: { min: 15 + level.num, max: 30 + (level.num * 2) },
                        preferenceWeight: level.checkpoint ? 1.0 : 0.7 + (level.num * 0.01)
                    },
                    images: {
                        required: 15 + (level.num * 2),
                        categories: level.checkpoint ? 'user-preferences' : 'advanced',
                        timing: 'throughout'
                    }
                },
                
                tasks: [
                    {
                        type: 'edge',
                        count: level.edges,
                        duration: 300 + (level.num * 30),
                        intensity: 'progressive',
                        instructions: `Complete ${level.edges} edges demonstrating your mastery.`,
                        successCriteria: {
                            edges: level.edges,
                            cooldown: Math.max(10, 60 - level.num),
                            perfectControl: true
                        }
                    }
                ],
                
                objectives: [
                    `Complete ${level.edges} perfect edges`,
                    `Demonstrate Arc ${arcNum} skills`,
                    `Maintain ${level.duration}+ minute session`
                ],
                
                rewards: {
                    xp: 500 + (level.num * 50),
                    unlocks: level.num < 30 ? [`Level ${level.num + 1}`] : ['Academy Complete'],
                    achievements: level.checkpoint ? [`Arc ${arcNum} Complete`, `Level ${level.num} Master`] : [`Level ${level.num} Complete`]
                },
                
                story: {
                    intro: `Level ${level.num}: ${level.title}. ${level.checkpoint ? 'Checkpoint - demonstrate everything learned.' : 'Continue your progression through Arc ' + arcNum + '.'}`,
                    checkpoint: level.checkpoint ? {
                        preferenceModal: true,
                        progressSummary: true,
                        statsDisplay: true
                    } : null,
                    outro: level.checkpoint ? `Arc ${arcNum} complete! ${level.num === 30 ? 'Congratulations on completing The Academy!' : 'Prepare for Arc ' + (arcNum + 1) + '.'}` : `Level ${level.num} complete. Excellent progress.`
                },
                
                completion: {
                    required: {
                        tasksCompleted: 1,
                        edgesAchieved: level.edges,
                        timeSpent: level.duration - 10
                    },
                    optional: {
                        perfectScore: true,
                        recordBreaking: level.checkpoint
                    }
                }
            };
        });
        
        return remaining;
    }

    /**
     * Get media requirements for a level based on user preferences
     * @param {number} levelNumber 
     * @param {Object} userPreferences 
     * @returns {Object} Filtered media config
     */
    getMediaForLevel(levelNumber, userPreferences) {
        const levelConfig = this.getLevelConfig(levelNumber);
        if (!levelConfig) return null;

        const mediaConfig = levelConfig.media;
        const preferenceWeight = mediaConfig.videos.preferenceWeight;

        // Build content filter
        const filter = {
            tags: [],
            excludeTags: [],
            minRating: 0,
            duration: mediaConfig.videos.duration
        };

        // Apply level requirements
        if (Array.isArray(mediaConfig.videos.categories)) {
            filter.tags = [...mediaConfig.videos.categories];
        }

        // Blend with user preferences based on preference weight
        if (preferenceWeight > 0 && userPreferences) {
            const userFilter = window.preferenceManager.getContentFilter();
            
            // Merge tags with preference weight
            if (userFilter.tags.length > 0) {
                const userTagCount = Math.floor(userFilter.tags.length * preferenceWeight);
                const levelTagCount = filter.tags.length;
                
                // Take percentage of user tags based on weight
                const selectedUserTags = userFilter.tags.slice(0, userTagCount);
                filter.tags = [...filter.tags, ...selectedUserTags];
            }

            // Apply user exclusions
            if (userFilter.excludeTags) {
                filter.excludeTags = userFilter.excludeTags;
            }
        }

        return {
            videoFilter: filter,
            videoCount: mediaConfig.videos.required,
            imageFilter: { tags: mediaConfig.images.categories },
            imageCount: mediaConfig.images.required
        };
    }

    /**
     * Calculate level difficulty score
     * @param {number} levelNumber 
     * @returns {number} Difficulty score 0-100
     */
    getDifficultyScore(levelNumber) {
        const levelConfig = this.getLevelConfig(levelNumber);
        if (!levelConfig) return 0;

        let score = 0;

        // Base score from level number
        score += (levelNumber - 1) * 2; // 0-58 points

        // Task complexity
        score += levelConfig.session.tasks.total * 2; // Task count

        // Duration
        const targetDuration = levelConfig.session.duration.target;
        score += Math.min(targetDuration / 2, 20); // Up to 20 points for duration

        // Edge count
        const edgeTask = levelConfig.tasks.find(t => t.type === 'edge');
        if (edgeTask) {
            score += Math.min(edgeTask.count, 15); // Up to 15 points for edges
        }

        return Math.min(Math.round(score), 100);
    }
}

// Initialize and expose globally
window.academyLevelData = new AcademyLevelData();
console.log('📚 Academy Level Data initialized - Levels 1-5 configured');
