<div class="toolsuite-tool-container" style="width:100%; max-width:900px; margin:auto; font-family:'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif; color:#1e293b; line-height:1.5;">
<div style="border:1px solid #e2e8f0; border-radius:12px; padding:24px; background-color:#ffffff;">
<!-- Header -->
<div style="margin-bottom:20px;">
<h2 style="margin:0; font-size:22px; font-weight:600; color:#0f172a;">Sun and Moon Sign Calculator</h2>
<p style="margin-top:6px; font-size:14px; color:#64748b;">
Enter your birth details to discover your zodiac Sun and Moon signs.
</p>
</div>
<!-- Form -->
<div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:16px;">
<div>
<label style="font-size:13px; font-weight:500;">Date of Birth</label>
<input id="tool-dob" type="date"
style="width:100%; margin-top:6px; padding:10px; border:1px solid #cbd5f5; border-radius:8px; font-size:14px; outline:none; transition:0.2s;">
</div>
<div>
<label style="font-size:13px; font-weight:500;">Time of Birth</label>
<input id="tool-tob" type="time"
style="width:100%; margin-top:6px; padding:10px; border:1px solid #cbd5f5; border-radius:8px; font-size:14px; outline:none; transition:0.2s;">
</div>
<div>
<label style="font-size:13px; font-weight:500;">Place of Birth</label>
<input id="tool-pob" type="text" placeholder="Enter city"
style="width:100%; margin-top:6px; padding:10px; border:1px solid #cbd5f5; border-radius:8px; font-size:14px; outline:none; transition:0.2s;">
</div>
</div>
<!-- Buttons -->
<div style="margin-top:20px; display:flex; flex-wrap:wrap; gap:10px;">
<button id="tool-calculate"
style="background-color:#4f46e5; color:#ffffff; border:none; padding:10px 18px; border-radius:8px; font-size:14px; cursor:pointer; transition:0.3s;">
Calculate
</button>
<button id="tool-reset"
style="background-color:#ffffff; color:#4f46e5; border:1px solid #4f46e5; padding:10px 18px; border-radius:8px; font-size:14px; cursor:pointer; transition:0.3s;">
Reset
</button>
<button id="tool-copy"
style="background-color:#f8fafc; color:#1e293b; border:1px solid #cbd5e1; padding:10px 18px; border-radius:8px; font-size:14px; cursor:pointer; transition:0.3s;">
Copy Result
</button>
</div>
<!-- Result -->
<div id="tool-result"
style="margin-top:20px; padding:16px; border:1px solid #e2e8f0; border-radius:10px; background-color:#f8fafc; font-size:15px; display:none;">
</div>
</div>
<script>
(function () {
const calculateBtn = document.getElementById("tool-calculate");
const resetBtn = document.getElementById("tool-reset");
const copyBtn = document.getElementById("tool-copy");
const resultBox = document.getElementById("tool-result");
function getSunSign(day, month) {
const signs = [
{ sign: "Capricorn", from: [12, 22], to: [1, 19] },
{ sign: "Aquarius", from: [1, 20], to: [2, 18] },
{ sign: "Pisces", from: [2, 19], to: [3, 20] },
{ sign: "Aries", from: [3, 21], to: [4, 19] },
{ sign: "Taurus", from: [4, 20], to: [5, 20] },
{ sign: "Gemini", from: [5, 21], to: [6, 20] },
{ sign: "Cancer", from: [6, 21], to: [7, 22] },
{ sign: "Leo", from: [7, 23], to: [8, 22] },
{ sign: "Virgo", from: [8, 23], to: [9, 22] },
{ sign: "Libra", from: [9, 23], to: [10, 22] },
{ sign: "Scorpio", from: [10, 23], to: [11, 21] },
{ sign: "Sagittarius", from: [11, 22], to: [12, 21] }
];
for (let s of signs) {
const [fm, fd] = s.from;
const [tm, td] = s.to;
if (
(month === fm && day >= fd) ||
(month === tm && day <= td)
) {
return s.sign;
}
}
return "Unknown";
}
function getMoonSign(hour) {
const moonSigns = [
"Aries", "Taurus", "Gemini", "Cancer",
"Leo", "Virgo", "Libra", "Scorpio",
"Sagittarius", "Capricorn", "Aquarius", "Pisces"
];
const index = Math.floor((hour / 24) * 12);
return moonSigns[index % 12];
}
calculateBtn.addEventListener("click", function () {
const dob = document.getElementById("tool-dob").value;
const tob = document.getElementById("tool-tob").value;
const pob = document.getElementById("tool-pob").value.trim();
if (!dob || !tob || !pob) {
resultBox.style.display = "block";
resultBox.innerHTML = "<span style='color:#dc2626;'>Please fill in all fields.</span>";
return;
}
calculateBtn.textContent = "Calculating...";
calculateBtn.disabled = true;
setTimeout(() => {
const date = new Date(dob);
const day = date.getDate();
const month = date.getMonth() + 1;
const hour = parseInt(tob.split(":")[0]);
const sunSign = getSunSign(day, month);
const moonSign = getMoonSign(hour);
resultBox.style.display = "block";
resultBox.innerHTML = `
<strong>Results:</strong><br><br>
🌞 <strong>Sun Sign:</strong> ${sunSign}<br>
🌙 <strong>Moon Sign:</strong> ${moonSign}<br>
📍 <strong>Place of Birth:</strong> ${pob}
`;
calculateBtn.textContent = "Calculate";
calculateBtn.disabled = false;
}, 600);
});
resetBtn.addEventListener("click", function () {
document.getElementById("tool-dob").value = "";
document.getElementById("tool-tob").value = "";
document.getElementById("tool-pob").value = "";
resultBox.style.display = "none";
});
copyBtn.addEventListener("click", function () {
if (resultBox.innerText.trim() === "") return;
navigator.clipboard.writeText(resultBox.innerText).then(() => {
copyBtn.textContent = "Copied!";
setTimeout(() => {
copyBtn.textContent = "Copy Result";
}, 1500);
});
});
})();
</script>
</div>