// ============================================================
// RENDER LOGIC — you shouldn't need to touch this file.
// To add or change content, edit data.js instead.
// ============================================================
document.addEventListener("DOMContentLoaded", () => {
initThemeToggle();
renderHero();
renderAbout();
renderCareerPath();
renderSkills();
renderProjects();
renderCredentials();
renderContact();
renderFooter();
});
// ----------------------------------------------------------------
// THEME — three modes: light, dark, auto (follows system setting)
// ----------------------------------------------------------------
function initThemeToggle() {
const root = document.documentElement;
const toggle = document.getElementById("theme-toggle");
const label = document.getElementById("theme-mode-label");
const media = window.matchMedia("(prefers-color-scheme: light)");
const modes = ["light", "dark", "auto"];
function resolve(mode) {
if (mode === "auto") return media.matches ? "light" : "dark";
return mode;
}
function apply(mode) {
root.setAttribute("data-theme-mode", mode);
root.setAttribute("data-theme", resolve(mode));
if (label) label.textContent = mode.charAt(0).toUpperCase() + mode.slice(1);
localStorage.setItem("themeMode", mode);
}
let currentMode = localStorage.getItem("themeMode") || "auto";
apply(currentMode);
toggle.addEventListener("click", () => {
const next = modes[(modes.indexOf(currentMode) + 1) % modes.length];
currentMode = next;
apply(currentMode);
});
media.addEventListener("change", () => {
if (currentMode === "auto") apply("auto");
});
}
// ----------------------------------------------------------------
// HERO
// ----------------------------------------------------------------
function renderHero() {
document.getElementById("hero-title").innerHTML =
`Hi, I'm ${SITE.name}.
${SITE.role}`;
document.getElementById("hero-tagline").textContent = SITE.tagline;
const cta = document.getElementById("hero-cta");
cta.appendChild(makeLink("View Projects", "#projects", "btn btn-primary"));
cta.appendChild(makeLink("Get in Touch", "#contact", "btn btn-ghost"));
if (SITE.resumeLink && SITE.resumeLink !== "#") {
cta.appendChild(makeLink("Download Resume", SITE.resumeLink, "btn btn-ghost", true));
}
document.getElementById("id-avatar").textContent = SITE.initials;
document.getElementById("id-name").textContent = SITE.name;
document.getElementById("id-role").textContent = SITE.role;
document.getElementById("id-location").textContent = SITE.location;
document.getElementById("id-status").textContent = SITE.status;
}
function makeLink(text, href, className, external) {
const a = document.createElement("a");
a.href = href;
a.className = className;
a.textContent = text;
if (external) {
a.target = "_blank";
a.rel = "noopener";
}
return a;
}
// ----------------------------------------------------------------
// ABOUT
// ----------------------------------------------------------------
function renderAbout() {
const container = document.getElementById("about-body");
const mid = Math.ceil(ABOUT.length / 2);
const columns = [ABOUT.slice(0, mid), ABOUT.slice(mid)];
columns.forEach((paragraphs) => {
const col = document.createElement("div");
col.className = "about-col";
paragraphs.forEach((text) => {
const p = document.createElement("p");
p.textContent = text;
col.appendChild(p);
});
container.appendChild(col);
});
}
// ----------------------------------------------------------------
// CAREER PATH (timeline)
// ----------------------------------------------------------------
function renderCareerPath() {
const track = document.getElementById("path-track");
CAREER_PATH.forEach((step) => {
const div = document.createElement("div");
div.className = "path-step";
div.innerHTML = `
${p.summary}