;(function(){ const CloudTheme = { init(){ this.observeLists() this.bindRipple() this.observeCards() this.initNavToggle() this.initThemeToggle() }, onSectionSwitch(){}, observeLists(){ const ids=['ecs-body','vas-body','rn-body'] ids.forEach(id=>{ const el=document.getElementById(id) if(!el) return const mo=new MutationObserver(muts=>{ muts.forEach(m=>{ m.addedNodes.forEach(n=>{ if(n.nodeType===1) n.classList.add('fade-in') }) }) }) mo.observe(el,{childList:true}) }) }, bindRipple(){ document.body.addEventListener('pointerdown',e=>{ const t=e.target.closest('.btn') if(!t || !document.body.classList.contains('theme-cloud')) return const r=document.createElement('span') r.className='ripple' const rect=t.getBoundingClientRect() const size=Math.max(rect.width,rect.height) r.style.width=r.style.height=size+'px' r.style.left=(e.clientX-rect.left-size/2)+'px' r.style.top=(e.clientY-rect.top-size/2)+'px' t.appendChild(r) setTimeout(()=>{ try{ r.remove() }catch{} },420) },{passive:true}) }, observeCards(){ const cards=[...document.querySelectorAll('body.theme-cloud .panel.card')] const io=new IntersectionObserver(entries=>{ entries.forEach(en=>{ if(en.isIntersecting){ en.target.style.boxShadow='var(--shadow)' } else { en.target.style.boxShadow='none' } }) }) cards.forEach(c=>io.observe(c)) }, initNavToggle(){ const key='cloud_nav_visible' const btn=document.getElementById('cloud-toggle-nav') const eye=`` const setVisible=(v)=>{ document.body.classList.toggle('nav-visible', !!v); if(btn) { btn.setAttribute('aria-pressed', v?'true':'false'); btn.title=v?'隐藏导航':'显示导航'; btn.innerHTML=eye } } const initVal=localStorage.getItem(key)==='1' setVisible(initVal) if(btn) btn.addEventListener('click',()=>{ const cur=document.body.classList.contains('nav-visible'); const next=!cur; localStorage.setItem(key, next?'1':'0'); setVisible(next) }) }, initThemeToggle(){ const key='cloud_theme' const btn=document.getElementById('cloud-toggle-theme') const moon=`` const sun=`` const apply=(mode)=>{ document.body.setAttribute('data-theme', mode); if(btn) btn.innerHTML=mode==='dark'?moon:sun } const init=localStorage.getItem(key) || 'dark' apply(init) if(btn) btn.addEventListener('click',()=>{ const cur=document.body.getAttribute('data-theme')||'dark'; const next=cur==='dark'?'light':'dark'; localStorage.setItem(key,next); apply(next) }) } } window.CloudTheme=CloudTheme if(document.body && document.body.classList.contains('theme-cloud')) { CloudTheme.init() } })();