Files
index.html
script.js
styles.css
Code
3 338
script.js
const elements = [
{ name: 'Air', icon: '🌪️', rarity: 'Common', slug: 'common', description: 'A swift affinity that turns open space into momentum and motion.', abilities: [['Wind Blade', '0s', 'Primary'], ['Tornado', '10s', 'Secondary']], recipe: { grid: ['Fea', '—', 'Fea', 'Str', 'Wol', 'Str', '—', 'Fea', '—'], materials: ['Feather', 'String', 'White Wool'], description: 'A light, accessible recipe for a first elemental bond.' }, random: true },
{ name: 'Wood', icon: '🌳', rarity: 'Common', slug: 'common', description: 'A grounded affinity connected to the living grain and growth of the world.', abilities: [['Vine Whip', '0s', 'Primary'], ['Thorn Shield', '10s', 'Secondary']], recipe: { grid: ['Oak', '—', 'Oak', 'Oak', 'Sap', 'Oak', '—', 'Oak', '—'], materials: ['Oak Log', 'Oak Sapling', 'String'], description: 'A survival-friendly recipe shaped from the forest.' }, random: true },
{ name: 'Earth', icon: '🌍', rarity: 'Common', slug: 'common', description: 'A sturdy affinity drawn from the stone beneath every adventure.', abilities: [['Rock Throw', '0s', 'Primary'], ['Earthquake', '10s', 'Secondary']], recipe: { grid: ['Cob', '—', 'Cob', 'Gra', 'Cob', 'Gra', '—', 'Cob', '—'], materials: ['Cobblestone', 'Gravel', 'Granite'], description: 'A dependable early-game recipe using the ground around you.' }, random: true },
{ name: 'Water', icon: '💧', rarity: 'Uncommon', slug: 'uncommon', description: 'A fluid affinity that follows the rhythm of rivers, rain, and tides.', abilities: [['Water Blast', '0s', 'Primary'], ['Healing Wave', '10s', 'Secondary']], recipe: { grid: ['Ice', '—', 'Ice', 'Lap', 'Buc', 'Lap', '—', 'Ice', '—'], materials: ['Ice', 'Lapis Lazuli', 'Water Bucket'], description: 'A moderately valuable recipe for those who seek the current.' }, random: true },
{ name: 'Fire', icon: '🔥', rarity: 'Uncommon', slug: 'uncommon', description: 'A fierce affinity carrying the heat and hunger of an open flame.', abilities: [['Fireball', '0s', 'Primary'], ['Flame Burst', '10s', 'Secondary']], recipe: { grid: ['Coo', '—', 'Coo', 'Bla', 'Neth', 'Bla', '—', 'Coo', '—'], materials: ['Coal', 'Blaze Powder', 'Netherrack'], description: 'A warm Nether-touched recipe with a moderate cost.' }, random: true },
{ name: 'Nature', icon: '🌿', rarity: 'Uncommon', slug: 'uncommon', description: 'A flourishing affinity that binds healing and danger into one cycle.', abilities: [['Healing Roots', '0s', 'Primary'], ['Poison Bloom', '10s', 'Secondary']], recipe: { grid: ['Moss', '—', 'Moss', 'Aza', 'Bee', 'Aza', '—', 'Moss', '—'], materials: ['Moss Block', 'Azalea', 'Bee Nest'], description: 'A living recipe gathered from the greener corners of the world.' }, random: true },
{ name: 'Ice', icon: '❄️', rarity: 'Rare', slug: 'rare', description: 'A rare affinity that preserves, sharpens, and stills everything it touches.', abilities: [['Ice Shard', '0s', 'Primary'], ['Freeze', '10s', 'Secondary']], recipe: { grid: ['Pac', '—', 'Pac', 'Dia', 'Blu', 'Dia', '—', 'Pac', '—'], materials: ['Packed Ice', 'Diamond', 'Blue Ice'], description: 'A cold, rare recipe that demands diamond-level commitment.' }, random: true },
{ name: 'Metal', icon: '🔩', rarity: 'Rare', slug: 'rare', description: 'A forged affinity built from pressure, precision, and enduring strength.', abilities: [['Metal Spike', '0s', 'Primary'], ['Iron Armor', '10s', 'Secondary']], recipe: { grid: ['Iro', '—', 'Iro', 'Cop', 'Net', 'Cop', '—', 'Iro', '—'], materials: ['Iron Block', 'Copper Block', 'Netherite Scrap'], description: 'A forged recipe for players ready to work with rare ores.' }, random: true },
{ name: 'Lightning', icon: '⚡', rarity: 'Epic', slug: 'epic', description: 'An explosive affinity that moves faster than thought and strikes without warning.', abilities: [['Lightning Bolt', '0s', 'Primary'], ['Chain Lightning', '10s', 'Secondary']], recipe: { grid: ['Rod', '—', 'Rod', 'Eme', 'Cha', 'Eme', '—', 'Rod', '—'], materials: ['Lightning Rod', 'Emerald Block', 'Chain'], description: 'A charged epic recipe for bold explorers and builders.' }, random: true },
{ name: 'Poison', icon: '☠️', rarity: 'Epic', slug: 'epic', description: 'A dangerous affinity that rewards patience, precision, and control.', abilities: [['Poison Dart', '0s', 'Primary'], ['Toxic Cloud', '10s', 'Secondary']], recipe: { grid: ['Spi', '—', 'Spi', 'Fer', 'Anc', 'Fer', '—', 'Spi', '—'], materials: ['Spider Eye', 'Fermented Spider Eye', 'Ancient Debris'], description: 'A dangerous epic recipe combining rare and corrupted materials.' }, random: true },
{ name: 'Light', icon: '💡', rarity: 'Legendary', slug: 'legendary', description: 'A radiant affinity that cuts through the dark with focused brilliance.', abilities: [['Light Beam', '0s', 'Primary'], ['Radiant Shield', '10s', 'Secondary']], recipe: { grid: ['Sea', '—', 'Sea', 'Gol', 'Net', 'Gol', '—', 'Sea', '—'], materials: ['Sea Lantern', 'Gold Block', 'Nether Star'], description: 'An extremely valuable recipe for a radiant legendary bond.' }, random: true },
{ name: 'Darkness', icon: '🌑', rarity: 'Legendary', slug: 'legendary', description: 'A deep affinity that gathers in the spaces where light cannot reach.', abilities: [['Shadow Bolt', '0s', 'Primary'], ['Dark Veil', '10s', 'Secondary']], recipe: { grid: ['Obs', '—', 'Obs', 'Cry', 'Net', 'Cry', '—', 'Obs', '—'], materials: ['Obsidian', 'Crying Obsidian', 'Nether Star'], description: 'An extremely valuable recipe forged at the edge of the Nether.' }, random: true },
{ name: 'Shadow', icon: '👤', rarity: 'Mythic', slug: 'mythic', description: 'A mythic affinity that slips between sight, silence, and the unseen.', abilities: [['Shadow Step', '0s', 'Primary'], ['Invisibility', '10s', 'Secondary']], recipe: { grid: ['End', '—', 'End', 'Ely', 'Net', 'Ely', '—', 'End', '—'], materials: ['Ender Pearl', 'Elytra', 'Nether Star'], description: 'An end-game recipe reserved for those who reach the outer islands.' }, random: true },
{ name: 'Energy', icon: '🔋', rarity: 'Mythic', slug: 'mythic', description: 'A mythic affinity that stores raw potential and releases it in pulses.', abilities: [['Energy Beam', '0s', 'Primary'], ['Energy Pulse', '10s', 'Secondary']], recipe: { grid: ['Red', '—', 'Red', 'Net', 'Con', 'Net', '—', 'Red', '—'], materials: ['Redstone Block', 'Nether Star', 'Conduit'], description: 'An end-game recipe that turns rare reserves into raw potential.' }, random: true },
{ name: 'Space', icon: '🌌', rarity: 'Divine', slug: 'divine', description: 'The highest affinity: a cosmic bond shaped from distance, weight, and the stars beyond.', abilities: [['Teleport', '0s', 'Primary'], ['Gravity Well', '10s', 'Secondary']], recipe: { grid: ['Dra', 'Net', 'Dra', 'Net', 'Con', 'Net', 'Dra', 'Net', 'Dra'], materials: ['Dragon Egg', 'Nether Star', 'Conduit'], description: 'The hardest and most prestigious recipe in the elemental progression.' }, random: false }
];
const rarityInfo = [
['Common', '⚪', '#d8e1eb', 'The first spark.', ['Air', 'Wood', 'Earth']],
['Uncommon', '🟢', '#52dc85', 'A growing force.', ['Water', 'Fire', 'Nature']],
['Rare', '🔵', '#4e9fff', 'A magical edge.', ['Ice', 'Metal']],
['Epic', '🟣', '#b66aff', 'Power unleashed.', ['Lightning', 'Poison']],
['Legendary', '🟠', '#ffab51', 'A radiant legend.', ['Light', 'Darkness']],
['Mythic', '🔴', '#ff556d', 'Beyond the known.', ['Shadow', 'Energy']],
['Divine', '🌈', '#e8aaff', 'The highest rarity.', ['Space']]
];
const elementsGrid = document.querySelector('#elements-grid');
const abilityList = document.querySelector('#ability-list');
const recipesGrid = document.querySelector('#recipes-grid');
const rarityTrack = document.querySelector('#rarity-track');
const eligibleList = document.querySelector('#eligible-list');
let activeRarity = 'all';
function colorFor(element) { return { common: '#d8e1eb', uncommon: '#52dc85', rare: '#4e9fff', epic: '#b66aff', legendary: '#ffab51', mythic: '#ff556d', divine: '#e8aaff' }[element.slug]; }
function cooldownBadge(value) { return `<span class="cooldown">${value} Cooldown</span>`; }
function renderElements() {
const query = document.querySelector('#element-search').value.trim().toLowerCase();
const acquisition = document.querySelector('#acquisition-filter').value;
const filtered = elements.filter(element => {
const matchesQuery = element.name.toLowerCase().includes(query);
const matchesRarity = activeRarity === 'all' || element.slug === activeRarity;
const matchesAcquisition = acquisition === 'all' || (acquisition === 'random' && element.random) || (acquisition === 'craftable' && element.random) || (acquisition === 'crafting-only' && !element.random);
return matchesQuery && matchesRarity && matchesAcquisition;
});
elementsGrid.innerHTML = filtered.map((element) => `<article class="element-card ${element.slug} reveal visible" style="--card-color:${colorFor(element)}" data-element="${element.name}">
<div class="card-top"><span class="element-icon">${element.icon}</span><span class="rarity-pill">${element.rarity}</span></div>
<h3>${element.name}</h3><div class="card-divider"></div>
<div class="mini-ability"><span>${element.abilities[0][0]}</span>${cooldownBadge(element.abilities[0][1])}</div>
<div class="mini-ability"><span>${element.abilities[1][0]}</span>${cooldownBadge(element.abilities[1][1])}</div>
<div class="card-foot"><span>${element.random ? 'Random + Craftable' : 'Crafting Only'}</span><strong>View details →</strong></div>
</article>`).join('');
document.querySelector('#empty-state').hidden = filtered.length !== 0;
elementsGrid.querySelectorAll('.element-card').forEach(card => card.addEventListener('click', () => openModal(card.dataset.element)));
}
function renderAbilities() {
abilityList.innerHTML = elements.map(element => `<article class="ability-group ${element.slug}" style="--card-color:${colorFor(element)}"><div class="ability-group-head"><span class="element-icon">${element.icon}</span><h3>${element.name}</h3><span class="rarity-pill" style="margin-left:auto;color:${colorFor(element)}">${element.rarity}</span></div>${element.abilities.map((ability, index) => `<div class="ability-row"><div>${ability[0]}<small>${ability[2]} ability</small></div>${cooldownBadge(ability[1])}</div>`).join('')}</article>`).join('');
}
function renderRarities() {
rarityTrack.innerHTML = rarityInfo.map((rarity, index) => `<article class="rarity-step" style="--rarity-color:${rarity[2]}"><span class="rarity-number">0${index + 1}</span><span class="rarity-symbol">${rarity[1]}</span><h3>${rarity[0]}</h3><p>${rarity[3]}</p><div class="rarity-members">${rarity[4].map(name => `<span>${name}</span>`).join('')}</div></article>`).join('');
}
function renderRecipes() {
recipesGrid.innerHTML = elements.map(element => `<article class="recipe-card ${element.slug}" style="--card-color:${colorFor(element)}"><div class="recipe-head"><span class="element-icon">${element.icon}</span><div><h3>${element.name}</h3><small>${element.rarity} Recipe</small></div></div><div class="recipe-body"><div class="craft-grid">${element.recipe.grid.map(slot => `<span class="craft-slot">${slot}</span>`).join('')}</div><div class="craft-result">${element.icon}<b>${element.name}<br>Element</b></div></div><div class="recipe-materials"><p>${element.recipe.description}</p><div class="material-list">${element.recipe.materials.map(material => `<span>${material}</span>`).join('')}</div></div><div class="recipe-footer"><span>${element.random ? 'First Join Eligible' : 'First Join Unavailable'}</span><strong>${element.random ? 'Random + Craftable' : 'Crafting Only'}</strong></div></article>`).join('');
}
function openModal(name) {
const element = elements.find(item => item.name === name);
const backdrop = document.querySelector('#modal-backdrop');
const modal = document.querySelector('#element-modal');
modal.className = `element-modal ${element.slug}`;
modal.style.setProperty('--card-color', colorFor(element));
document.querySelector('#modal-icon').textContent = element.icon;
document.querySelector('#modal-rarity').textContent = `${element.rarity} · ${element.random ? 'Random First Join + Craftable' : 'Crafting Only'}`;
document.querySelector('#modal-title').textContent = element.name;
document.querySelector('#modal-description').textContent = element.description;
document.querySelector('#modal-abilities').innerHTML = element.abilities.map((ability, index) => `<div class="modal-ability"><div>${ability[0]}<small>${index === 0 ? 'Primary / basic ability' : 'Secondary / stronger ability'}</small></div>${cooldownBadge(ability[1])}</div>`).join('');
document.querySelector('#modal-recipe').innerHTML = `<strong>Crafting recipe</strong>${element.recipe.description} Required materials: ${element.recipe.materials.join(', ')}.`;
document.querySelector('#modal-acquisition').innerHTML = `<strong>Acquisition</strong>${element.random ? 'This element can be randomly received exactly once on a player’s first SMP join, and can also be crafted.' : '<b>Space cannot be randomly received when a player joins.</b> It can only be obtained by crafting its special Divine recipe.'}`;
backdrop.hidden = false;
document.body.style.overflow = 'hidden';
document.querySelector('#modal-close').focus();
}
function closeModal() { document.querySelector('#modal-backdrop').hidden = true; document.body.style.overflow = ''; }
document.querySelector('#element-search').addEventListener('input', renderElements);
document.querySelector('#acquisition-filter').addEventListener('change', renderElements);
document.querySelectorAll('.filter-chip').forEach(button => button.addEventListener('click', () => { document.querySelectorAll('.filter-chip').forEach(chip => chip.classList.remove('selected')); button.classList.add('selected'); activeRarity = button.dataset.filter; renderElements(); }));
document.querySelector('#modal-close').addEventListener('click', closeModal);
document.querySelector('#modal-backdrop').addEventListener('click', event => { if (event.target.id === 'modal-backdrop') closeModal(); });
document.addEventListener('keydown', event => { if (event.key === 'Escape') closeModal(); });
const rouletteWheel = document.querySelector('#roulette-wheel');
const rouletteResult = document.querySelector('#roulette-result');
document.querySelector('#spin-button').addEventListener('click', event => {
const button = event.currentTarget;
const eligible = elements.filter(element => element.random);
const winner = eligible[Math.floor(Math.random() * eligible.length)];
button.disabled = true;
rouletteResult.textContent = 'The elements are choosing...';
rouletteWheel.style.animation = 'none';
rouletteWheel.offsetHeight;
rouletteWheel.style.animation = 'roulette-spin 2.4s cubic-bezier(.15,.8,.22,1)';
setTimeout(() => { rouletteResult.innerHTML = `The world chose <strong style="color:${colorFor(winner)}">${winner.icon} ${winner.name}</strong>.`; button.disabled = false; }, 2450);
});
document.querySelectorAll('[data-placeholder]').forEach(link => link.addEventListener('click', event => { event.preventDefault(); }));
const navToggle = document.querySelector('.nav-toggle');
navToggle.addEventListener('click', () => { const nav = document.querySelector('.main-nav'); nav.classList.toggle('open'); navToggle.setAttribute('aria-expanded', nav.classList.contains('open')); });
document.querySelectorAll('.main-nav a').forEach(link => link.addEventListener('click', () => document.querySelector('.main-nav').classList.remove('open')));
const sections = document.querySelectorAll('main section[id]');
const navLinks = document.querySelectorAll('.main-nav a[href^="#"]');
const observer = new IntersectionObserver(entries => entries.forEach(entry => { if (entry.isIntersecting) { const matching = document.querySelector(`.main-nav a[href="#${entry.target.id}"]`); if (matching) { navLinks.forEach(link => link.classList.remove('active')); matching.classList.add('active'); } } }), { rootMargin: '-35% 0px -55% 0px' });
sections.forEach(section => observer.observe(section));
const revealObserver = new IntersectionObserver(entries => entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); revealObserver.unobserve(entry.target); } }), { threshold: .08 });
document.querySelectorAll('.reveal').forEach(item => revealObserver.observe(item));
eligibleList.innerHTML = elements.filter(element => element.random).map(element => `<b>${element.icon} ${element.name}</b>`).join('');
renderElements();
renderAbilities();
renderRarities();
renderRecipes();