<!DOCTYPE html>
<html lang="sq">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shqip Today — Shqipëria jote, kudo që të jesh</title>
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
<style>
:root { --red: #C8102E; --black: #0A0A0A; --card-black: #111111; --warm-white: #F5F0EB; --grey: #888888; }
/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Nascondiamo il body inizialmente per evitare il "balletto" visivo */
body {
background: var(--black);
color: var(--warm-white);
font-family: 'DM Sans', sans-serif;
opacity: 0;
transition: opacity 0.4s ease-in;
}
body.ready { opacity: 1; }
header {
position: fixed; top: 0; left: 0; right: 0; z-index: 100;
padding: 20px 48px; display: flex; align-items: center; justify-content: space-between;
background: rgba(10,10,10,0.98); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(200,16,46,0.15);
}
.logo { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--warm-white); text-decoration: none; }
.logo span { color: var(--red); }
nav { display: flex; gap: 30px; }
nav a { font-size: 11px; color: var(--grey); text-decoration: none; text-transform: uppercase; letter-spacing: 1px; }
.hero { height: 60vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px; }
/* Sezioni con altezza minima per stabilità */
section {
padding: 100px 48px;
border-bottom: 1px solid rgba(245,240,235,0.06);
scroll-margin-top: 100px;
min-height: 400px;
}
.news-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 2px;
margin-top: 40px;
}
.news-card {
background: var(--card-black);
padding: 40px;
border: 1px solid rgba(245,240,235,0.04);
cursor: pointer;
transition: background 0.2s;
}
.news-card:hover { background: #161616; border-color: var(--red); }
/* Modal */
.modal-overlay {
display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95);
z-index: 1000; padding: 20px; overflow-y: auto; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--card-black); max-width: 750px; width: 100%; padding: 50px; margin: 40px auto; border: 1px solid var(--red); position: relative; }
.modal-close { position: absolute; top: 20px; right: 25px; color: white; font-size: 30px; cursor: pointer; border: none; background: none; }
@media (max-width: 768px) {
header { padding: 15px 20px; }
nav a:not(.nav-cta) { display: none; }
section { padding: 60px 20px; }
}
</style>
</head>
<body>
<header>
<a href="#" class="logo">Shqip<span>.</span>Today</a>
<nav>
<a href="#lajme-section">Lajme</a>
<a href="#curiositet">Curiositet</a>
<a href="#pse-si">Pse & Si</a>
<a href="#diaspora">Diaspora</a>
</nav>
</header>
<div class="hero">
<div>
<h1 style="font-family:'Playfair Display'; font-size: clamp(40px, 8vw, 70px);">Shqip Today<span>.</span></h1>
<p style="color:var(--grey); font-size: 18px; margin-top: 15px;">Shqipëria jote, kudo që të jesh.</p>
</div>
</div>
<section id="lajme-section">
<h2 style="font-family:'Playfair Display'; font-size:32px;">Lajmet e fundit</h2>
<div class="news-grid" id="newsGrid"></div>
</section>
<section id="curiositet">
<h2 style="font-family:'Playfair Display'; font-size:32px;">💡 Curiositet</h2>
<div class="news-grid" id="curiositetCards"></div>
</section>
<section id="pse-si">
<h2 style="font-family:'Playfair Display'; font-size:32px;">📚 Pse & Si</h2>
<div class="news-grid" id="pseSiGrid"></div>
</section>
<section id="diaspora">
<h2 style="font-family:'Playfair Display'; font-size:32px;">🌍 Diaspora</h2>
<div class="news-grid" id="diasporaGrid"></div>
</section>
<div class="modal-overlay" id="articleModal">
<div class="modal"><button class="modal-close" onclick="closeModal()">✕</button><div id="modalContent"></div></div>
</div>
<script>
// 1. Catturiamo subito l'ancora e puliamo l'URL per fermare il browser
const savedHash = window.location.hash;
if (savedHash) {
window.history.replaceState(null, null, window.location.pathname);
}
const IDS = {
news: '1cK7XXXODEQ6k1CKduzlGeMrtHiNqQmD0Yi8rFp3jlA8',
curi: '1W2OIZ7ofT1drVbkeplD_mQPnaWgIXz7vz2xTeCBTNx4',
pse: '1RMV0c30Zlj4hGv02Iv1BFtCcQ2Cri3_BtqVYVov7en4'
};
async function fetchSheet(id) {
try {
const response = await fetch(`https://docs.google.com/spreadsheets/d/${id}/gviz/tq?tqx=out:json`);
const text = await response.text();
const json = JSON.parse(text.substring(47).slice(0, -2));
return json.table.rows;
} catch (e) { return []; }
}
function createCards(containerId, rows, type) {
const grid = document.getElementById(containerId);
if (!rows || rows.length === 0) return;
grid.innerHTML = rows.slice(0, 6).map(row => {
// Logica corretta per estrarre i testi dalle colonne giuste
let fullText = "";
let category = "";
if (type === 'PSE') {
fullText = row.c[4]?.v || "";
category = "📚 PSE & SI";
} else if (type === 'CURI') {
fullText = row.c[3]?.v || "";
category = "💡 CURIOSITET";
} else {
fullText = row.c[3]?.v || "";
category = row.c[2]?.v || "LAJME";
}
const title = fullText.split('\n')[0].substring(0, 90);
const excerpt = fullText.split('\n').slice(1).join(' ').substring(0, 110) + "...";
// Pulizia testo per passare dati al modal senza errori di virgolette
const safeText = fullText.replace(/`/g, "'").replace(/"/g, """);
return `
<div class="news-card" onclick="openModal(\`${safeText}\`, '${category}')">
<div style="color:var(--red); font-size:10px; font-weight:700; margin-bottom:12px; text-transform:uppercase; letter-spacing:1px;">${category}</div>
<h3 style="font-family:'Playfair Display'; font-size:20px; line-height:1.3; margin-bottom:15px;">${title}</h3>
<p style="font-size:14px; color:var(--grey); line-height:1.6;">${excerpt}</p>
</div>`;
}).join('');
}
async function startApp() {
// Caricamento dati in parallelo
const [news, curi, pse] = await Promise.all([
fetchSheet(IDS.news),
fetchSheet(IDS.curi),
fetchSheet(IDS.pse)
]);
// Generazione Griglie
createCards('newsGrid', [...news].reverse().filter(r => r.c[2]?.v !== 'DIASPORA'), 'NEWS');
createCards('curiositetCards', [...curi].reverse(), 'CURI');
createCards('pseSiGrid', [...pse].reverse(), 'PSE');
createCards('diasporaGrid', [...news].reverse().filter(r => r.c[2]?.v === 'DIASPORA'), 'DIASPORA');
// Rendiamo visibile il sito
document.body.classList.add('ready');
// Gestione Scroll: ora che il sito è visibile e popolato, ci spostiamo
if (savedHash) {
setTimeout(() => {
const targetElement = document.querySelector(savedHash);
if (targetElement) {
const topPos = targetElement.getBoundingClientRect().top + window.pageYOffset - 90;
window.scrollTo({ top: topPos, behavior: 'auto' }); // 'auto' è più stabile di 'smooth' per i link esterni
window.history.replaceState(null, null, savedHash);
}
}, 200);
}
}
function openModal(text, cat) {
const lines = text.split('\n');
document.getElementById('modalContent').innerHTML = `
<div style="color:var(--red); font-size:11px; font-weight:700; margin-bottom:15px; text-transform:uppercase;">${cat}</div>
<h2 style="font-family:'Playfair Display'; font-size:30px; margin-bottom:25px; line-height:1.2;">${lines[0]}</h2>
<div style="font-size:17px; line-height:1.8; color:rgba(245,240,235,0.85);">
${lines.slice(1).map(l => l.trim() ? `<p style="margin-bottom:18px;">${l}</p>` : '').join('')}
</div>`;
document.getElementById('articleModal').classList.add('open');
document.body.style.overflow = 'hidden';
}
function closeModal() {
document.getElementById('articleModal').classList.remove('open');
document.body.style.overflow = '';
}
// Lancio
startApp();
</script>
</body>
</html>