@php $currentFilter = $currentFilter ?? 'all'; $currentType = $currentType ?? 'all'; $curriculumCourses = $curriculumCourses ?? $courses->where('resolved_type', 'curriculum')->values(); $skillCourses = $skillCourses ?? $courses->where('resolved_type', 'skill')->values(); $showCurriculumSection = ($currentType === 'all' || $currentType === 'curriculum'); $showSkillSection = ($currentType === 'all' || $currentType === 'skill'); $renderCourseCard = function ($course) { $isSkill = (($course->resolved_type ?? 'curriculum') === 'skill'); $percentage = max(0, min(100, (int) ($course->progress_pct ?? 0))); $starsLit = $percentage >= 100 ? 3 : ($percentage >= 66 ? 2 : ($percentage >= 25 ? 1 : 0)); $barWidth = $percentage > 0 ? max(8, $percentage) : 4; $hasSyllabus = !empty($course->syllabus) && strtoupper((string) $course->syllabus) !== 'NULL'; $langText = $course->language ? strtoupper($course->language) : 'CODING'; $searchBlob = strtolower(trim(($course->coursename ?? '') . ' ' . ($course->coursecode ?? '') . ' ' . ($course->language ?? '') . ' ' . ($isSkill ? 'skill' : 'curriculum'))); return compact('isSkill', 'percentage', 'starsLit', 'barWidth', 'hasSyllabus', 'langText', 'searchBlob'); }; @endphp @if($courses->isEmpty())

@if($currentFilter === 'completed') No Completed Adventures Yet! @elseif($currentFilter === 'current') All Caught Up! @else No Courses Available Yet @endif

@if($currentFilter === 'completed') Solve coding puzzles & quizzes inside your courses to earn all 3 golden stars! @elseif($currentFilter === 'current') Superstar! You finished every course in this category! @else No class tracks or skill quests have been added yet. Check back soon! @endif

@else
{{-- ================================================================ SECTION 1: CURRICULUM COURSES ================================================================ --}} @if($showCurriculumSection && ($curriculumCourses->isNotEmpty() || $currentType === 'curriculum'))

Class Coding Tracks

Your main coding adventures — collect all 3 stars on each track!

{{ $curriculumCourses->count() }} {{ \Illuminate\Support\Str::plural('Course', $curriculumCourses->count()) }}
@if($curriculumCourses->isEmpty())

No Class Tracks Here

No curriculum courses match this filter right now. Check Skill Quests below to keep coding!

@else
@foreach($curriculumCourses as $course) @php $m = $renderCourseCard($course); @endphp
@csrf
{{-- ILLUSTRATED WAVE BANNER + 3-STAR MASTERY --}}
{{ $m['percentage'] >= 100 ? 'Completed!' : 'Class Track' }}
{{-- FLOATING LANGUAGE MEDALLION --}}
@if(!empty($course->formatted_image)) {{ $m['langText'] }} @else @endif
{{ $m['langText'] }} @if(!empty($course->coursecode)) {{ $course->coursecode }} @endif
{{-- CARD BODY --}}

{{ $course->coursename ?? 'Unnamed Course' }}

{{-- KID-FRIENDLY PROGRESS BAR --}}
Adventure Progress {{ $m['percentage'] }}%
{{-- 3 MINI STATS --}}
{{ $course->modules_count ?? 0 }} Levels
{{ $course->coding_total ?? 0 }} Puzzles
{{ $course->mcq_total ?? 0 }} Quizzes
{{-- BIG 3D PLAY BUTTON + OPTIONAL SYLLABUS --}}
@endforeach
@endif
@endif {{-- ================================================================ SECTION 2: SKILL-BASED COURSES ================================================================ --}} @if($showSkillSection && ($skillCourses->isNotEmpty() || $currentType === 'skill'))

Bonus Skill Quests

Extra coding adventures open for every Little Buds coder!

{{ $skillCourses->count() }} {{ \Illuminate\Support\Str::plural('Course', $skillCourses->count()) }}
@if($skillCourses->isEmpty())

No Bonus Quests Yet

No skill quests match this filter right now. New bonus tracks will appear here automatically!

@else
@foreach($skillCourses as $course) @php $m = $renderCourseCard($course); @endphp
@csrf
{{-- ILLUSTRATED WAVE BANNER + CERTIFICATE ICON + 3-STAR MASTERY --}}
{{ $m['percentage'] >= 100 ? 'Completed!' : 'Skill Quest' }}
{{-- FLOATING LANGUAGE MEDALLION --}}
@if(!empty($course->formatted_image)) {{ $m['langText'] }} @else @endif
{{ $m['langText'] }} @if(!empty($course->coursecode)) {{ $course->coursecode }} @endif
{{-- CARD BODY --}}

{{ $course->coursename ?? 'Unnamed Course' }}

{{-- KID-FRIENDLY PROGRESS BAR --}}
Quest Progress {{ $m['percentage'] }}%
{{-- 3 MINI STATS --}}
{{ $course->modules_count ?? 0 }} Levels
{{ $course->coding_done ?? 0 }}/{{ $course->coding_total ?? 0 }} Solved
{{ $course->mcq_total ?? 0 }} Quizzes
{{-- BIG 3D PLAY BUTTON + OPTIONAL SYLLABUS --}}
@endforeach
@endif
@endif
@endif