:root {
  --bg: #07080f;
  --surface: #0d0f1a;
  --card: #111420;
  --border: rgba(255,255,255,0.07);
  --accent: #4f8eff;
  --accent2: #7c5cfc;
  --text: #e8eaf0;
  --muted: #6b7280;
  --gradient: linear-gradient(135deg, #4f8eff 0%, #7c5cfc 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

/* NAV */
nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 4rem;
  background: rgba(7,8,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.3rem;
  color: var(--text); text-decoration: none; letter-spacing: -0.03em;
  display: flex; align-items: baseline; gap: 0.5rem;
}
.nav-logo span { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav-logo em { font-style: normal; font-size: 0.7rem; font-weight: 500; color: var(--muted); border: 1px solid var(--border); padding: 0.15rem 0.5rem; border-radius: 100px; }
.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }

/* HERO */
#blog-hero { padding: 6rem 4rem 3rem; max-width: 900px; margin: 0 auto; text-align: center; }
.hero-tag {
  display: inline-block; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--accent); border: 1px solid rgba(79,142,255,0.3);
  padding: 0.35rem 1rem; border-radius: 100px; margin-bottom: 1.5rem;
}
h1 { font-family: 'Syne', sans-serif; font-size: clamp(2.2rem, 6vw, 3.6rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 1rem; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-size: 1.05rem; color: var(--muted); font-weight: 300; max-width: 560px; margin: 0 auto; }

/* GRID ARTICOLI */
#articoli-grid { padding: 2rem 4rem 6rem; max-width: 1200px; margin: 0 auto; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.6rem; }
.post-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.post-card:hover { transform: translateY(-4px); border-color: rgba(79,142,255,0.3); box-shadow: 0 12px 40px rgba(79,142,255,0.08); }
.post-thumb { aspect-ratio: 16/9; background: var(--surface) center/cover no-repeat; display: flex; align-items: center; justify-content: center; }
.post-thumb-fallback { font-size: 2.4rem; opacity: 0.35; }
.post-card-body { padding: 1.3rem 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.post-date { font-size: 0.72rem; color: var(--accent); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.post-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.post-excerpt { font-size: 0.85rem; color: var(--muted); line-height: 1.6; flex: 1; }
.empty-state { color: var(--muted); text-align: center; padding: 4rem 0; }

/* BARRA RICERCA + TOGGLE VISTA */
.blog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.search-form {
  display: flex; align-items: center; gap: 0.6rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 100px; padding: 0.6rem 1.1rem; flex: 1; min-width: 220px; max-width: 380px;
}
.search-form svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.search-form input {
  border: none; background: none; outline: none; color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; width: 100%;
}
.search-form input::placeholder { color: var(--muted); }
.search-clear { color: var(--muted); text-decoration: none; font-size: 0.85rem; padding: 0 0.2rem; }
.search-clear:hover { color: var(--text); }
.view-toggle { display: flex; gap: 0.3rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 0.3rem; }
.view-btn { background: none; border: none; color: var(--muted); padding: 0.4rem 0.6rem; border-radius: 7px; cursor: pointer; display: flex; }
.view-btn svg { width: 16px; height: 16px; }
.view-btn.active { background: var(--surface); color: var(--accent); }
.view-btn:not(.active):hover { color: var(--text); }

/* VISTA A ELENCO */
.posts-grid.list-view { grid-template-columns: 1fr; gap: 0.8rem; }
.posts-grid.list-view .post-card { flex-direction: row; align-items: stretch; }
.posts-grid.list-view .post-thumb { width: 130px; aspect-ratio: auto; flex-shrink: 0; }
.posts-grid.list-view .post-card-body { padding: 1rem 1.3rem; gap: 0.35rem; justify-content: center; }
.posts-grid.list-view .post-excerpt { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 560px) {
  .posts-grid.list-view .post-thumb { width: 90px; }
  .posts-grid.list-view .post-excerpt { display: none; }
}

.pagination { display: flex; gap: 0.5rem; justify-content: center; margin-top: 3rem; }
.page-link { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.page-link.active, .page-link:hover { border-color: var(--accent); color: var(--accent); }

/* ARTICOLO */
#articolo { max-width: 760px; margin: 0 auto; padding: 3rem 2rem 6rem; }
.articolo-head { text-align: center; margin-bottom: 2rem; }
.articolo-cover { border-radius: 16px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 2rem; }
.articolo-cover img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.articolo-content { font-size: 1.05rem; line-height: 1.85; color: #d5d8e0; }
.articolo-content p { margin-bottom: 1.3rem; }
.articolo-content h2 { font-family: 'Syne', sans-serif; font-size: 1.6rem; margin: 2rem 0 1rem; color: var(--text); }
.articolo-content h3 { font-family: 'Syne', sans-serif; font-size: 1.25rem; margin: 1.6rem 0 0.8rem; color: var(--text); }
.articolo-content img { max-width: 100%; border-radius: 12px; margin: 1.2rem 0; }
.articolo-content a { color: var(--accent); }
.articolo-content ul, .articolo-content ol { margin: 0 0 1.3rem 1.4rem; }
.articolo-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--muted); margin: 1.3rem 0; }

.articolo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.7rem; margin: 2rem 0; }
.gallery-item { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.gallery-item:hover img { transform: scale(1.06); }

.articolo-links { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 2rem 0; }
.articolo-link { display: inline-flex; align-items: center; gap: 0.5rem; }
.articolo-link svg { width: 14px; height: 14px; }
.articolo-back { margin-top: 3rem; text-align: center; }

/* NAVIGAZIONE ARTICOLO PRECEDENTE/SUCCESSIVO */
.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 3rem 0 0; }
.article-nav-card {
  display: flex; align-items: center; gap: 0.9rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1rem; text-decoration: none; color: inherit;
  transition: transform 0.2s, border-color 0.2s;
}
.article-nav-card:hover { transform: translateY(-2px); border-color: rgba(79,142,255,0.3); }
.article-nav-card.next { justify-content: flex-end; text-align: right; }
.article-nav-thumb {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 10px; background: var(--surface) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; opacity: 0.6;
}
.article-nav-text { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.article-nav-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.article-nav-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.92rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.article-nav-spacer { display: none; }

/* BOTTONI */
.btn-primary { background: var(--gradient); color: #fff; padding: 0.85rem 2rem; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: 0.95rem; border: none; cursor: pointer; transition: opacity 0.2s, transform 0.2s; display: inline-block; }
.btn-primary:hover { opacity: 0.85; transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text); padding: 0.85rem 2rem; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: 0.95rem; border: 1px solid var(--border); transition: border-color 0.2s, transform 0.2s; display: inline-block; cursor: pointer; }
.btn-ghost:hover { border-color: rgba(255,255,255,0.25); transform: translateY(-2px); }

/* ADS */
.ad-slot { margin: 2.2rem 0; }
.ad-label { font-size: 0.68rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: center; margin-bottom: 0.6rem; opacity: 0.7; }
.ad-frame { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; display: flex; justify-content: center; overflow: hidden; min-height: 60px; }
.ad-inline-wrap { margin: 1.5rem 0; }

/* FOOTER */
footer { border-top: 1px solid var(--border); padding: 3rem 4rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.footer-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem; color: var(--muted); text-decoration: none; }
.footer-logo span { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.footer-copy { font-size: 0.8rem; color: var(--muted); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { font-size: 0.82rem; color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* COOKIE BANNER */
.cookie-banner[hidden] { display: none !important; }
.cookie-banner {
  position: fixed; left: 1.5rem; right: 1.5rem; bottom: 1.5rem; z-index: 500;
  max-width: 720px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.4rem 1.6rem; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; justify-content: space-between;
}
.cookie-text { font-size: 0.85rem; color: var(--muted); flex: 1; min-width: 240px; }
.cookie-actions { display: flex; gap: 0.6rem; }
.cookie-actions .btn-primary, .cookie-actions .btn-ghost { padding: 0.6rem 1.3rem; font-size: 0.85rem; }

/* LIGHTBOX */
.vb-lightbox[hidden] { display: none !important; }
.vb-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 600; display: flex; align-items: center; justify-content: center; }
.vb-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }
.vb-lightbox-close { position: absolute; top: 1.5rem; right: 2rem; background: none; border: none; color: #fff; font-size: 2.2rem; cursor: pointer; }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 768px) {
  nav { padding: 1rem 1.4rem; }
  .nav-links { display: none; }
  #blog-hero { padding: 4rem 1.4rem 2rem; }
  #articoli-grid { padding: 1.5rem 1.4rem 4rem; }
  .blog-toolbar { flex-direction: column; align-items: stretch; }
  .search-form { max-width: none; }
  #articolo { padding: 2rem 1.2rem 4rem; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav-card.next { justify-content: flex-start; text-align: left; }
  footer { flex-direction: column; text-align: center; padding: 2rem 1.4rem; }
  .cookie-banner { left: 0.8rem; right: 0.8rem; bottom: 0.8rem; flex-direction: column; align-items: stretch; }
}
