function toggleExpandable(container,panel){const isOpen=container.classList.toggle("expanded");if(isOpen){panel.style.maxHeight="0px";requestAnimationFrame(()=>{panel.style.maxHeight=panel.scrollHeight+32+"px";});}else{panel.style.maxHeight="0px";} container.setAttribute("aria-expanded",isOpen);} function initGlobalContentCards(){document.querySelectorAll(".content-card").forEach(card=>{const panel=card.querySelector(".card-expansion");if(!panel)return;card.setAttribute("role","button");card.setAttribute("tabindex","0");card.setAttribute("aria-expanded","false");card.addEventListener("click",e=>{if(e.target.closest("a, button"))return;toggleExpandable(card,panel);});card.addEventListener("keydown",e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();toggleExpandable(card,panel);}});});} function initGlobalTimeline(){document.querySelectorAll(".timeline-item .box").forEach(box=>{const panel=box.querySelector(".timeline-detail");if(!panel)return;box.setAttribute("role","button");box.setAttribute("tabindex","0");box.setAttribute("aria-expanded","false");box.addEventListener("click",e=>{if(e.target.closest("a, button"))return;toggleExpandable(box,panel);});box.addEventListener("keydown",e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();toggleExpandable(box,panel);}});});} document.addEventListener("DOMContentLoaded",()=>{initGlobalContentCards();initGlobalTimeline();});function initRevealSections(){document.querySelectorAll(".reveal-section").forEach(section=>{const btn=section.querySelector(".reveal-trigger");const content=section.querySelector(".reveal-content");if(!btn||!content)return;btn.setAttribute("type","button");btn.setAttribute("aria-expanded","false");content.setAttribute("aria-hidden","true");content.style.maxHeight="0px";content.style.overflow="hidden";btn.addEventListener("click",()=>{const isOpen=section.classList.toggle("active");btn.classList.toggle("active",isOpen);btn.setAttribute("aria-expanded",isOpen?"true":"false");content.classList.toggle("active",isOpen);content.setAttribute("aria-hidden",isOpen?"false":"true");if(isOpen){content.style.maxHeight=content.scrollHeight+24+"px";}else{content.style.maxHeight="0px";}});});window.addEventListener("resize",()=>{document.querySelectorAll(".reveal-section.active .reveal-content").forEach(content=>{content.style.maxHeight=content.scrollHeight+24+"px";});});} document.addEventListener("DOMContentLoaded",initRevealSections);(function(){function openReveal(section){const btn=section.querySelector('.reveal-trigger');const content=section.querySelector('.reveal-content');if(!btn||!content)return;btn.classList.add('active');section.classList.add('active');content.classList.add('active');content.style.maxHeight=content.scrollHeight+'px';} function closeReveal(section){const btn=section.querySelector('.reveal-trigger');const content=section.querySelector('.reveal-content');if(!btn||!content)return;btn.classList.remove('active');section.classList.remove('active');content.classList.remove('active');content.style.maxHeight=null;} function toggleReveal(section){const isOpen=section.classList.contains('active');if(isOpen)closeReveal(section);else openReveal(section);} document.addEventListener('click',(e)=>{const btn=e.target.closest('.reveal-trigger');if(!btn)return;e.preventDefault();const section=btn.closest('.reveal-section');if(!section)return;btn.setAttribute('type','button');toggleReveal(section);});document.addEventListener('keydown',(e)=>{if(e.key==='Escape'){document.querySelectorAll('.reveal-section.active').forEach(closeReveal);return;} const activeEl=document.activeElement;if(!activeEl)return;const isTrigger=activeEl.classList&&activeEl.classList.contains('reveal-trigger');if(!isTrigger)return;if(e.key==='Enter'||e.key===' '){e.preventDefault();const section=activeEl.closest('.reveal-section');if(section)toggleReveal(section);}});window.addEventListener('resize',()=>{document.querySelectorAll('.reveal-section.active .reveal-content').forEach((content)=>{content.style.maxHeight=content.scrollHeight+'px';});});})();window.toggleReveal=function(button){const section=button.closest(".reveal-section")||button.parentElement;const content=section?.querySelector(".reveal-content")||button.nextElementSibling?.classList?.contains("reveal-content")?button.nextElementSibling:null;if(!content)return;const isOpen=content.classList.contains("active");button.classList.toggle("active",!isOpen);section?.classList.toggle("active",!isOpen);content.classList.toggle("active",!isOpen);if(!isOpen){content.style.maxHeight=content.scrollHeight+"px";}else{content.style.maxHeight=null;}};window.toggleTimelineDetail=function(box){const detail=box.querySelector(".timeline-detail");if(!detail)return;const isExpanded=box.classList.contains("expanded");box.classList.toggle("expanded",!isExpanded);if(!isExpanded){detail.style.maxHeight=detail.scrollHeight+"px";detail.style.marginTop="1.5rem";}else{detail.style.maxHeight="0px";detail.style.marginTop="0";}};document.addEventListener("click",function(e){const revealBtn=e.target.closest(".reveal-trigger");if(revealBtn&&!e.target.closest("a")){if(!revealBtn.hasAttribute("onclick")){e.preventDefault();window.toggleReveal(revealBtn);}} const timelineBox=e.target.closest(".timeline-item .box");if(timelineBox&&timelineBox.querySelector(".timeline-detail")){if(e.target.closest("a, button"))return;if(!timelineBox.hasAttribute("onclick")){window.toggleTimelineDetail(timelineBox);}} const card=e.target.closest(".content-card");if(card&&card.querySelector(".card-expansion")){if(e.target.closest("a, button"))return;if(!card.hasAttribute("data-expand-bound")){card.setAttribute("data-expand-bound","1");}}});document.addEventListener("click",(e)=>{const revealBtn=e.target.closest(".reveal-trigger");if(revealBtn){e.preventDefault();const section=revealBtn.closest(".reveal-section");const content=section?.querySelector(".reveal-content");if(!content)return;revealBtn.classList.toggle("active");section.classList.toggle("active");content.classList.toggle("active");if(content.classList.contains("active")){content.style.maxHeight=content.scrollHeight+"px";content.style.padding="2rem";}else{content.style.maxHeight="";content.style.padding="";} return;} const timelineBox=e.target.closest(".timeline-item .box");if(timelineBox){if(e.target.closest("a, button"))return;const detail=timelineBox.querySelector(".timeline-detail")||timelineBox.closest(".timeline-item")?.querySelector(".timeline-detail");if(!detail)return;timelineBox.classList.toggle("expanded");const open=timelineBox.classList.contains("expanded");timelineBox.setAttribute("aria-expanded",open?"true":"false");if(open){detail.style.maxHeight=detail.scrollHeight+"px";detail.style.marginTop="1.5rem";}else{detail.style.maxHeight="";detail.style.marginTop="";} return;} const card=e.target.closest(".content-card");if(card){const expansion=card.querySelector(".card-expansion");if(!expansion)return;if(e.target.closest("a, button"))return;document.querySelectorAll(".content-card.expanded").forEach((other)=>{if(other!==card){other.classList.remove("expanded");const ex=other.querySelector(".card-expansion");if(ex)ex.style.maxHeight="";}});card.classList.toggle("expanded");const open=card.classList.contains("expanded");card.setAttribute("aria-expanded",open?"true":"false");if(open){expansion.style.maxHeight=expansion.scrollHeight+"px";}else{expansion.style.maxHeight="";}}});