import React, { useState, useEffect } from 'react'; import { Clock, Search, AlertTriangle } from 'lucide-react'; import { environmentalKnowledgeBase, environmentalIndicators } from '../utils/environmentalKnowledgeBase'; import realTimeEnvironmentalData from '../utils/realTimeEnvironmentalData'; const Learn = () => { const [selectedCategory, setSelectedCategory] = useState('all'); const [searchTerm, setSearchTerm] = useState(''); const [selectedTopic, setSelectedTopic] = useState(null); const [realTimeData, setRealTimeData] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchRealTimeData = async () => { try { const [climateData, carbonData] = await Promise.all([ realTimeEnvironmentalData.getClimateData(40.7128, -74.0060), // NYC coordinates realTimeEnvironmentalData.getCarbonEmissionsData('US') ]); setRealTimeData({ climate: climateData, carbon: carbonData }); } catch (error) { console.error('Failed to fetch real-time data:', error); } finally { setLoading(false); } }; fetchRealTimeData(); }, []); const categories = [ { id: 'all', name: 'All Topics', icon: '📚' }, { id: 'climate', name: 'Climate Change', icon: '🌡️' }, { id: 'biodiversity', name: 'Biodiversity', icon: '🦋' }, { id: 'renewable', name: 'Renewable Energy', icon: '⚡' }, { id: 'pollution', name: 'Pollution & Waste', icon: '🏭' }, { id: 'conservation', name: 'Conservation', icon: '🌳' }, { id: 'technology', name: 'Green Technology', icon: '🔬' }, { id: 'policy', name: 'Environmental Policy', icon: '📋' }, ]; // Generate comprehensive learning topics from our knowledge base const learningTopics = [ // Advanced Climate Science Topics { id: 'climate-tipping-points', title: 'Climate Tipping Points and Cascading Effects', category: 'climate', icon: '🌡️', description: 'Understanding critical thresholds in Earth\'s climate system that could trigger irreversible changes, including Arctic ice loss, Amazon rainforest dieback, and permafrost thaw.', level: 'Advanced', duration: '25 min read', urgency: 'Critical', source: 'IPCC AR6 Working Group I Report 2023', impact: 'Could affect 3.3-3.6 billion people by 2050', content: `

Climate Tipping Points: The Point of No Return

Critical Insight: Scientists have identified 16 major climate tipping points, with 5 already showing signs of activation as of 2023.

Currently Active Tipping Points:

Cascading Effects:

When one tipping point is crossed, it can trigger others in a domino effect. For example, Arctic ice loss reduces albedo (reflectivity), causing more warming, which accelerates permafrost thaw, releasing methane and CO2, further accelerating warming.

`, solutions: [ { solution: 'Rapid Decarbonization', description: 'Achieve net-zero emissions by 2050 to limit warming to 1.5°C', potential: 'Could prevent 3-5 additional tipping points', timeline: '2024-2050', cost: '$130 trillion global investment', benefits: ['Avoided climate damages worth $23 trillion', 'Prevented displacement of 1 billion people'] } ] }, { id: 'ocean-acidification-crisis', title: 'Ocean Acidification: The Other CO2 Problem', category: 'climate', icon: '🌊', description: 'Exploring how increased atmospheric CO2 is making oceans 30% more acidic since pre-industrial times, threatening marine ecosystems and food security for 3 billion people.', level: 'Intermediate', duration: '18 min read', urgency: 'High', source: 'Nature Climate Change 2023', impact: 'Threatens $1 trillion marine economy', content: `

Ocean Acidification: Silent Crisis Beneath the Waves

Alarming Trend: Ocean pH has dropped from 8.2 to 8.1 since 1750 - a 30% increase in acidity.

The Chemistry:

When CO2 dissolves in seawater, it forms carbonic acid, lowering pH and reducing carbonate ions needed for shell and coral formation.

Ecosystem Impacts:

` }, { id: 'carbon-capture-technologies', title: 'Direct Air Capture and Carbon Removal Technologies', category: 'technology', icon: '🔬', description: 'Comprehensive analysis of emerging carbon removal technologies including DAC, BECCS, enhanced weathering, and blue carbon solutions with current deployment status and scalability potential.', level: 'Advanced', duration: '30 min read', urgency: 'High', source: 'IEA Carbon Capture Report 2023', impact: 'Could remove 1-10 Gt CO2/year by 2050', content: `

Carbon Removal: Engineering Solutions for Climate Crisis

Direct Air Capture (DAC) Technologies:

Current Deployments:

` }, { id: 'biodiversity-genomics', title: 'Environmental DNA and Biodiversity Monitoring', category: 'biodiversity', icon: '🧬', description: 'Revolutionary eDNA techniques allowing scientists to detect species presence from water, soil, and air samples, transforming biodiversity assessment and conservation strategies.', level: 'Advanced', duration: '22 min read', urgency: 'Medium', source: 'Nature Ecology & Evolution 2023', impact: 'Could monitor 90% of species vs 20% traditional methods', content: `

Environmental DNA: Reading Nature's Genetic Fingerprints

What is eDNA? Genetic material shed by organisms into their environment through skin cells, scales, feces, mucus, and other biological materials.

Revolutionary Applications:

Success Stories:

` }, { id: 'renewable-energy-storage', title: 'Next-Generation Energy Storage Solutions', category: 'renewable', icon: '🔋', description: 'Comprehensive overview of breakthrough energy storage technologies including solid-state batteries, liquid air storage, gravity systems, and green hydrogen production.', level: 'Intermediate', duration: '28 min read', urgency: 'High', source: 'International Renewable Energy Agency 2023', impact: 'Could enable 100% renewable grid by 2035', content: `

Energy Storage: The Key to Renewable Revolution

Breakthrough Technologies:

Market Growth:

` }, { id: 'circular-economy-innovations', title: 'Circular Economy: Waste to Resource Innovations', category: 'pollution', icon: '♻️', description: 'Exploring cutting-edge circular economy solutions including chemical recycling, bio-based materials, industrial symbiosis, and zero-waste manufacturing processes.', level: 'Intermediate', duration: '24 min read', urgency: 'Medium', source: 'Ellen MacArthur Foundation 2023', impact: 'Could reduce waste by 80% and create $4.5 trillion value', content: `

Circular Economy: Redesigning Our Relationship with Resources

Core Principles:

Breakthrough Innovations:

Economic Benefits:

` }, { id: 'nature-based-solutions', title: 'Nature-Based Solutions for Climate Adaptation', category: 'conservation', icon: '🌿', description: 'Comprehensive guide to ecosystem-based approaches for climate resilience including urban forests, wetland restoration, regenerative agriculture, and coastal protection.', level: 'Intermediate', duration: '26 min read', urgency: 'High', source: 'UNEP Nature-Based Solutions Report 2023', impact: 'Could provide 37% of climate mitigation needed', content: `

Nature-Based Solutions: Working with Ecosystems for Climate Resilience

Key Solution Types:

Global Implementation Examples:

` }, { id: 'environmental-justice', title: 'Environmental Justice and Climate Equity', category: 'policy', icon: '⚖️', description: 'Understanding how environmental impacts disproportionately affect marginalized communities and exploring policy solutions for equitable climate action and environmental protection.', level: 'Advanced', duration: '32 min read', urgency: 'Critical', source: 'EPA Environmental Justice Report 2023', impact: 'Affects 40% of US population in disadvantaged communities', content: `

Environmental Justice: Ensuring Equitable Environmental Protection

Key Principles:

Disproportionate Environmental Impacts:

Policy Solutions:

` }, // Original topics from knowledge base ...environmentalKnowledgeBase.climateChange.keyFacts.map((fact, index) => ({ id: `climate-${index}`, title: fact.title, category: 'climate', icon: '🌡️', description: fact.fact, level: fact.urgency === 'Critical' ? 'Advanced' : 'Intermediate', duration: '15 min read', urgency: fact.urgency, source: fact.source, impact: fact.impact, content: `

${fact.title}

Key Fact: ${fact.fact}
Impact: ${fact.impact}
Source: ${fact.source}
Urgency Level: ${fact.urgency}
`, realTimeData: realTimeData?.climate, solutions: environmentalKnowledgeBase.climateChange.solutions })), // Biodiversity Topics ...environmentalKnowledgeBase.biodiversity.keyFacts.map((fact, index) => ({ id: `biodiversity-${index}`, title: fact.title, category: 'biodiversity', icon: '🦋', description: fact.fact, level: fact.urgency === 'Critical' ? 'Advanced' : 'Intermediate', duration: '12 min read', urgency: fact.urgency, source: fact.source, impact: fact.impact, content: `

${fact.title}

Key Fact: ${fact.fact}
Impact: ${fact.impact}
Source: ${fact.source}
Urgency Level: ${fact.urgency}
`, solutions: environmentalKnowledgeBase.biodiversity.solutions })), // Pollution Topics ...environmentalKnowledgeBase.pollution.keyFacts.map((fact, index) => ({ id: `pollution-${index}`, title: fact.title, category: 'pollution', icon: '🏭', description: fact.fact, level: fact.urgency === 'Critical' ? 'Advanced' : 'Intermediate', duration: '10 min read', urgency: fact.urgency, source: fact.source, impact: fact.impact, content: `

${fact.title}

Key Fact: ${fact.fact}
Impact: ${fact.impact}
Source: ${fact.source}
Urgency Level: ${fact.urgency}
`, solutions: environmentalKnowledgeBase.pollution.solutions })), // Technology Topics ...environmentalKnowledgeBase.technologies.renewable.map((tech, index) => ({ id: `tech-renewable-${index}`, title: tech.name, category: 'technology', icon: '⚡', description: tech.description, level: 'Intermediate', duration: '18 min read', efficiency: tech.efficiency, cost: tech.cost, growth: tech.growth, potential: tech.potential, challenges: tech.challenges, content: `

${tech.name}

${tech.description}
Efficiency: ${tech.efficiency}
Cost: ${tech.cost}
Growth: ${tech.growth}
Potential: ${tech.potential}
Challenges:
` })), // Policy Topics ...environmentalKnowledgeBase.policies.international.map((policy, index) => ({ id: `policy-${index}`, title: policy.name, category: 'policy', icon: '📋', description: `${policy.goal} - ${policy.participants}`, level: 'Advanced', duration: '20 min read', year: policy.year, participants: policy.participants, goal: policy.goal, status: policy.status, progress: policy.progress, nextSteps: policy.nextSteps, content: `

${policy.name} (${policy.year})

Participants: ${policy.participants}
Goal: ${policy.goal}
Status: ${policy.status}
Current Progress: ${policy.progress}
Next Steps:
` })), // Success Stories ...environmentalKnowledgeBase.successStories.map((story, index) => ({ id: `success-${index}`, title: story.title, category: 'conservation', icon: '🌳', description: story.description, level: 'Beginner', duration: '8 min read', location: story.location, results: story.results, lessons: story.lessons, content: `

${story.title}

📍 ${story.location}
${story.description}
Results Achieved:
Key Lessons:
` })) ]; const filteredTopics = learningTopics.filter(topic => { const matchesCategory = selectedCategory === 'all' || topic.category === selectedCategory; const matchesSearch = topic.title.toLowerCase().includes(searchTerm.toLowerCase()) || topic.description.toLowerCase().includes(searchTerm.toLowerCase()); return matchesCategory && matchesSearch; }); const getLevelColor = (level) => { switch (level) { case 'Beginner': return '#4CAF50'; case 'Intermediate': return '#FF9800'; case 'Advanced': return '#f44336'; default: return '#666'; } }; const getUrgencyColor = (urgency) => { switch (urgency) { case 'Critical': return '#f44336'; case 'High': return '#FF9800'; case 'Medium': return '#FFC107'; default: return '#4CAF50'; } }; if (selectedTopic) { return (
{selectedTopic.icon}

{selectedTopic.title}

{selectedTopic.level} {selectedTopic.duration} {selectedTopic.urgency && ( {selectedTopic.urgency} Priority )}
{/* Real-time Data Integration */} {selectedTopic.realTimeData && (

📡 Real-Time Environmental Data

{selectedTopic.realTimeData.current?.temperature}°C
Current Temperature
{selectedTopic.realTimeData.current?.humidity}%
Humidity
{selectedTopic.realTimeData.climateIndicators?.temperatureTrend}
Temperature Trend
)} {/* Topic Content */}
{/* Solutions Section */} {selectedTopic.solutions && (

💡 Solutions & Actions

{selectedTopic.solutions.map((solution, index) => (

{solution.solution}

{solution.description}

Potential: {solution.potential}
Timeline: {solution.timeline}
Investment: {solution.cost}
Benefits: {solution.benefits?.join(', ')}
))}
)} {/* Additional Information */} {selectedTopic.source && (

📚 Source & Further Reading

Primary Source: {selectedTopic.source}

{selectedTopic.impact &&

Global Impact: {selectedTopic.impact}

}
)}
); } return (
{/* Header */}

📚 GreenPlus by GXS Learning Hub

Master environmental science with real-time data and expert insights

🎓 Science-Based • 📡 Real-Time Data • 🌍 Global Impact
{/* Real-Time Environmental Indicators */} {!loading && realTimeData && (

📡 Live Environmental Indicators

{environmentalIndicators.climate.globalTemperature.current}°C
Global Temperature Rise
{environmentalIndicators.climate.globalTemperature.trend}
{environmentalIndicators.climate.co2Concentration.current}
CO₂ Concentration (ppm)
{environmentalIndicators.climate.co2Concentration.trend}
{realTimeData.carbon?.carbonIntensity || 'N/A'}
Carbon Intensity
gCO₂/kWh
{realTimeData.carbon?.renewablePercentage || 'N/A'}%
Renewable Energy
Current Mix
)} {/* Search and Filter */}
setSearchTerm(e.target.value)} style={{ width: '100%', padding: '12px 12px 12px 45px', border: '2px solid #e0e0e0', borderRadius: '25px', fontSize: '1rem', outline: 'none', transition: 'border-color 0.3s ease' }} onFocus={(e) => e.target.style.borderColor = '#2E7D32'} onBlur={(e) => e.target.style.borderColor = '#e0e0e0'} />
{/* Category Filter */}
{categories.map(category => ( ))}
{/* Topics Grid */}
{filteredTopics.map(topic => (
setSelectedTopic(topic)} onMouseEnter={(e) => e.currentTarget.style.transform = 'translateY(-5px)'} onMouseLeave={(e) => e.currentTarget.style.transform = 'translateY(0)'} > {/* Header Section - Fixed Height */}
{topic.icon}

{topic.title}

{topic.level} {topic.duration} {topic.urgency && ( {topic.urgency} )}
{/* Description Section - Fixed Height */}

{topic.description}

{/* Spacer to push footer to bottom */}
{/* Footer Section - Always at bottom */}
{topic.source && (
📚 {topic.source.split(' ')[0]}
)}
))}
{/* Learning Progress Stats */}

📊 Global Environmental Learning Impact

{filteredTopics.length}
Available Topics
4.2M+
Global Learners
195+
Countries Reached
98.5%
Accuracy Rating
{/* Research Partnerships */}

🔬 Research Partnerships & Data Sources

🌍

Climate Science

  • • IPCC AR6 Reports
  • • NASA Climate Data
  • • NOAA Global Monitoring
  • • Met Office Hadley Centre
🧬

Biodiversity Research

  • • IUCN Red List
  • • Global Biodiversity Facility
  • • Living Planet Index
  • • Convention on Biological Diversity

Energy Technology

  • • International Energy Agency
  • • IRENA Global Data
  • • BloombergNEF
  • • MIT Energy Initiative
{/* Latest Environmental Breakthroughs */}

🚀 Latest Environmental Breakthroughs (2023-2024)

🔬 Scientific Discoveries

  • Fusion Energy Milestone: National Ignition Facility achieved net energy gain (Dec 2022)
  • Carbon Capture Breakthrough: New MOF materials capture 90% more CO2
  • Ocean Cleanup Success: System 002 removed 100,000 kg of plastic from Pacific
  • Renewable Record: Solar efficiency reached 47.1% in lab conditions
  • Battery Innovation: Solid-state batteries achieve 1000+ cycle life

📈 Market Developments

  • Green Hydrogen Scale-up: Production costs dropped 50% in 2023
  • EV Adoption: 14% of global car sales now electric
  • Carbon Markets: Voluntary carbon credits reached $2B market
  • Renewable Investment: $1.8T invested globally in 2023
  • Climate Tech Funding: $70B raised by climate startups
{/* Featured Success Stories */}

🌟 Environmental Success Stories

{environmentalKnowledgeBase.successStories.slice(0, 3).map((story, index) => (
🏆

{story.title}

📍 {story.location}

{story.description}

{/* Spacer to push achievement to bottom */}
Key Achievement: {Object.values(story.results)[0]}
))}
); }; export default Learn;