${t.year}
${t.description}`).style("left",e.pageX+10+"px").style("top",e.pageY-28+"px")}).on("mouseout",function(){d3.selectAll(".map-tooltip").remove()})}n.append("g").selectAll("path").data([{type:"Sphere"}]).enter().append("path").attr("d",o).attr("fill","none").attr("stroke","#333").attr("stroke-width",1),r(),document.getElementById("time-period").addEventListener("change",e=>{const t=document.getElementById("projection-type").value;r(e.target.value,t)}),document.getElementById("projection-type").addEventListener("change",e=>{r(document.getElementById("time-period").value,e.target.value)}),document.getElementById("play-timeline").addEventListener("click",()=>{!function(){const e=["ancient","medieval","early-modern","modern","contemporary"];let t=0;const n=setInterval(()=>{document.getElementById("time-period").value=e[t],r(e[t],"all"),t++,t>=e.length&&(clearInterval(n),document.getElementById("time-period").value="all",r("all","all"))},2e3)}()})}function initializeShadowSimulator(){const e=[{conscious:["Kind","Helpful","Organized","Polite"],shadow:["Angry","Selfish","Chaotic","Rude"],projected:["Angry","Selfish"],perceived:["Always angry","Very selfish","Inconsiderate"],actual:["Sometimes frustrated","Independent","Direct communicator"]},{conscious:["Rational","Controlled","Professional","Logical"],shadow:["Emotional","Wild","Unprofessional","Intuitive"],projected:["Emotional","Wild"],perceived:["Too emotional","Unpredictable","Unreliable"],actual:["Passionate","Creative","Authentic"]},{conscious:["Moral","Pure","Good","Righteous"],shadow:["Immoral","Dirty","Bad","Sinful"],projected:["Immoral","Bad"],perceived:["Corrupt","Evil","Dangerous"],actual:["Human","Complex","Flawed like everyone"]}];let t=0,n=0;function i(t){const i=e[t];document.getElementById("conscious-traits").innerHTML="",document.getElementById("shadow-traits").innerHTML="",document.getElementById("perceived-traits").innerHTML="",document.getElementById("actual-traits").innerHTML="",i.conscious.forEach(e=>{const t=document.createElement("div");t.className="trait-item",t.textContent=e,document.getElementById("conscious-traits").appendChild(t)}),i.shadow.forEach(e=>{const t=document.createElement("div");t.className="trait-item shadow",t.textContent=e,document.getElementById("shadow-traits").appendChild(t)}),i.perceived.forEach(e=>{const t=document.createElement("div");t.className="trait-item projected",t.textContent=e,document.getElementById("perceived-traits").appendChild(t)}),i.actual.forEach(e=>{const t=document.createElement("div");t.className="trait-item",t.textContent=e,document.getElementById("actual-traits").appendChild(t)}),n=0,a()}function a(){document.querySelectorAll(".step").forEach((e,t)=>{e.classList.remove("active");e.querySelector("button").disabled=t!==n}),n<3&&document.querySelectorAll(".step")[n].classList.add("active")}document.getElementById("recognize-projection").addEventListener("click",()=>{document.getElementById("integration-feedback").innerHTML="Recognition: You notice that you have a strong emotional reaction to this person. This intensity often signals a projection.",n=1,a()}),document.getElementById("own-shadow").addEventListener("click",()=>{document.querySelectorAll("#shadow-traits .trait-item").forEach(e=>{e.classList.remove("shadow")}),document.getElementById("integration-feedback").innerHTML="Ownership: You recognize that the traits you dislike in them are actually disowned parts of yourself. This takes courage and honesty.",n=2,a()}),document.getElementById("integrate-shadow").addEventListener("click",()=>{document.querySelectorAll("#perceived-traits .trait-item").forEach(e=>{e.classList.remove("projected"),e.style.background="var(--surface-glass)"}),document.getElementById("integration-feedback").innerHTML="Integration: You consciously accept these shadow aspects as part of your complete personality. The projection dissolves and you see the other person more clearly.",n=3,a()}),document.getElementById("new-scenario").addEventListener("click",()=>{t=(t+1)%e.length,i(t)}),i(0)}function initializeShadowTimeline(){const e=document.getElementById("shadow-timeline");if(!e)return;const t=40,n=30,i=60,a=80,o=e.offsetWidth-a-n,r=400-t-i,s=d3.select(e).append("svg").attr("width",o+a+n).attr("height",r+t+i),l=s.append("g").attr("transform",`translate(${a},${t})`),c=[{year:-500,event:"Scapegoat Ritual",type:"religious",intensity:.3,description:"Ancient ritual projection"},{year:30,event:"Crucifixion",type:"religious",intensity:.9,description:"Ultimate scapegoat sacrifice"},{year:1096,event:"First Crusade",type:"religious",intensity:.8,description:"Christian shadow projected onto Muslims"},{year:1348,event:"Black Death Blame",type:"racial",intensity:.7,description:"Jews blamed for plague"},{year:1492,event:"Spanish Expulsion",type:"religious",intensity:.8,description:"Jewish expulsion from Spain"},{year:1692,event:"Salem Trials",type:"religious",intensity:.6,description:"Witch hunt projections"},{year:1881,event:"Russian Pogroms",type:"racial",intensity:.7,description:"Anti-Jewish violence"},{year:1915,event:"Armenian Genocide",type:"racial",intensity:1,description:"Ottoman ethnic cleansing"},{year:1933,event:"Nazi Rise",type:"racial",intensity:1,description:"Industrial scapegoating"},{year:1950,event:"McCarthyism",type:"political",intensity:.5,description:"Red Scare projections"},{year:1994,event:"Rwanda Genocide",type:"racial",intensity:1,description:"Ethnic shadow explosion"},{year:2001,event:"9/11 Response",type:"cultural",intensity:.6,description:"Religious profiling surge"}],d=d3.scaleLinear().domain(d3.extent(c,e=>e.year)).range([0,o]),p=d3.scaleLinear().domain([0,1]).range([r,0]);l.append("g").attr("transform",`translate(0,${r})`).call(d3.axisBottom(d).tickFormat(e=>e>0?`${e} CE`:`${Math.abs(e)} BCE`)),l.append("g").call(d3.axisLeft(p).tickFormat(e=>100*e+"%")),s.append("text").attr("transform","rotate(-90)").attr("y",0+a/3).attr("x",0-r/2).attr("dy","1em").style("text-anchor","middle").style("fill","var(--text-secondary)").text("Shadow Projection Intensity"),s.append("text").attr("transform",`translate(${(o+a+n)/2}, ${r+t+i-10})`).style("text-anchor","middle").style("fill","var(--text-secondary)").text("Historical Timeline");const y=d3.line().x(e=>d(e.year)).y(e=>p(e.intensity)).curve(d3.curveCardinal);l.append("path").datum(c).attr("fill","none").attr("stroke","#DC143C").attr("stroke-width",2).attr("d",y),l.selectAll(".timeline-point").data(c).enter().append("circle").attr("class","timeline-point").attr("cx",e=>d(e.year)).attr("cy",e=>p(e.intensity)).attr("r",6).attr("fill",e=>({religious:"#DC143C",racial:"#8B0000",political:"#4169E1",cultural:"#9932CC"}[e.type]||"#666")).attr("stroke","#fff").attr("stroke-width",2).on("mouseover",function(e,t){const n=d3.select("body").append("div").attr("class","timeline-tooltip").style("position","absolute").style("background","rgba(0,0,0,0.9)").style("color","white").style("padding","10px").style("border-radius","5px").style("pointer-events","none").style("opacity",0);n.transition().duration(200).style("opacity",1),n.html(`${t.event}
${t.year>0?t.year+" CE":Math.abs(t.year)+" BCE"}
${t.description}`).style("left",e.pageX+10+"px").style("top",e.pageY-28+"px")}).on("mouseout",function(){d3.selectAll(".timeline-tooltip").remove()})}document.addEventListener("DOMContentLoaded",()=>{initializeShadowMap(),initializeShadowSimulator(),initializeShadowTimeline()})