/* ── LIGHT THEME (default) ── */
:root,
[data-theme="light"] {
  --bg:      #f5f4f0;
  --surface: #ffffff;
  --border:  #e0ddd6;
  --text:    #1a1814;
  --muted:   #8a8070;
  --accent:       #1a6b45;
  --accent-bright:#22a060;
  --accent2: #c0392b;
  --accent3: #b07d10;
  --tag-green-bg:  rgba(26,107,69,0.08);
  --tag-green-brd: rgba(26,107,69,0.2);
  --tag-green-txt: #1a6b45;
  --tag-red-bg:    rgba(192,57,43,0.08);
  --tag-red-brd:   rgba(192,57,43,0.2);
  --tag-red-txt:   #c0392b;
  --tag-yel-bg:    rgba(176,125,16,0.08);
  --tag-yel-brd:   rgba(176,125,16,0.2);
  --tag-yel-txt:   #b07d10;
  --header-bg:     rgba(245,244,240,0.88);
  --card-visual:   linear-gradient(135deg,#eef3f0 0%,#ddeee6 50%,#f0ede8 100%);
  --code-base:  #1d5fa8;
  --code-kw:    #9b1fa5;
  --code-fn:    #1a6b45;
  --code-str:   #b07d10;
  --code-cm:    #8a8070;
  --ticker-txt: #f5f4f0;
  --shadow:     0 2px 12px rgba(0,0,0,0.07);
}

/* ── DARK THEME ── */
[data-theme="dark"] {
  --bg:      #0a0a0f;
  --surface: #111118;
  --border:  #1e1e2e;
  --text:    #e8e8f0;
  --muted:   #6b6b88;
  --accent:       #7cffc4;
  --accent-bright:#a0ffe0;
  --accent2: #ff6b6b;
  --accent3: #ffd166;
  --tag-green-bg:  rgba(124,255,196,0.1);
  --tag-green-brd: rgba(124,255,196,0.2);
  --tag-green-txt: #7cffc4;
  --tag-red-bg:    rgba(255,107,107,0.1);
  --tag-red-brd:   rgba(255,107,107,0.2);
  --tag-red-txt:   #ff6b6b;
  --tag-yel-bg:    rgba(255,209,102,0.1);
  --tag-yel-brd:   rgba(255,209,102,0.2);
  --tag-yel-txt:   #ffd166;
  --header-bg:     rgba(10,10,15,0.88);
  --card-visual:   linear-gradient(135deg,#0d1117 0%,#161b22 50%,#0d2818 100%);
  --code-base:  #58a6ff;
  --code-kw:    #ff79c6;
  --code-fn:    #7cffc4;
  --code-str:   #ffd166;
  --code-cm:    #6b6b88;
  --ticker-txt: #0a0a0f;
  --shadow:     0 2px 12px rgba(0,0,0,0.4);
}

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 1000; opacity: 0.4;
}

/* ── THEME TOGGLE ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.28rem 0.75rem;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.toggle-track {
  width: 28px; height: 16px;
  background: var(--border);
  border-radius: 8px;
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}
[data-theme="dark"] .toggle-track { background: var(--accent); }

.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
[data-theme="dark"] .toggle-thumb { transform: translateX(12px); background: var(--bg); }

.toggle-label { letter-spacing: 0.06em; text-transform: uppercase; }

/* ── HEADER ── */
header {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
  transition: background 0.3s, border-color 0.3s;
}
.logo {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent); letter-spacing: -0.02em; text-decoration: none;
}
.logo span { color: var(--muted); }

nav { display: flex; gap: 1.5rem; align-items: center; }
nav a {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem; color: var(--muted);
  text-decoration: none; letter-spacing: 0.08em;
  text-transform: uppercase; transition: color 0.2s;
}
nav a:hover { color: var(--accent); }

.nav-cta {
  background: var(--accent); color: var(--bg) !important;
  padding: 0.4rem 1rem; border-radius: 2px; font-weight: 700;
}
.nav-cta:hover { background: var(--accent-bright) !important; }

/* ── HERO ── */
.hero {
  padding: 5rem 2rem 3rem; max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4rem;
  align-items: end; animation: fadeUp 0.8s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem; color: var(--accent);
  letter-spacing: 0.15em; text-transform: uppercase;
  margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.6rem;
}
.hero-label::before {
  content: ''; display: inline-block;
  width: 24px; height: 1px; background: var(--accent);
}
.hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 800; line-height: 1.05;
  letter-spacing: -0.03em; color: var(--text); margin-bottom: 1.5rem;
}
.hero h1 em {
  font-style: italic; color: var(--accent);
  font-family: 'Fraunces', serif; font-weight: 300;
}
.hero-desc {
  color: var(--muted); font-size: 1rem;
  font-style: italic; font-weight: 300;
  max-width: 440px; line-height: 1.8;
}
.hero-stats {
  display: flex; gap: 2.5rem;
  padding-top: 2.5rem; border-top: 1px solid var(--border);
}
.stat-num {
  font-family: 'Space Mono', monospace;
  font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1;
}
.stat-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.3rem;
}

/* ── FEATURED CARD ── */
.featured-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; overflow: hidden; position: relative;
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
  cursor: pointer; box-shadow: var(--shadow);
}
.featured-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.featured-card::before {
  content: 'IN EVIDENZA';
  position: absolute; top: 1rem; right: 1rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem; letter-spacing: 0.15em;
  color: var(--bg); background: var(--accent);
  padding: 0.25rem 0.6rem; border-radius: 2px; z-index: 2;
}
.card-visual {
  height: 200px; background: var(--card-visual);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.card-visual::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 70%, rgba(26,107,69,0.06) 0%, transparent 60%);
}
[data-theme="dark"] .card-visual::after {
  background: radial-gradient(circle at 30% 70%, rgba(124,255,196,0.08) 0%, transparent 60%);
}
.code-preview {
  font-family: 'Space Mono', monospace; font-size: 0.72rem;
  color: var(--code-base); padding: 1.5rem; line-height: 1.8;
  text-align: left; width: 100%;
}
.code-preview .kw  { color: var(--code-kw); }
.code-preview .fn  { color: var(--code-fn); }
.code-preview .str { color: var(--code-str); }
.code-preview .cm  { color: var(--code-cm); }

.card-body { padding: 1.5rem; }
.card-meta { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }

/* ── TAGS ── */
.tag {
  font-family: 'Space Mono', monospace; font-size: 0.65rem;
  color: var(--tag-green-txt);
  background: var(--tag-green-bg); border: 1px solid var(--tag-green-brd);
  padding: 0.2rem 0.6rem; border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.tag.red    { color: var(--tag-red-txt); background: var(--tag-red-bg); border-color: var(--tag-red-brd); }
.tag.yellow { color: var(--tag-yel-txt); background: var(--tag-yel-bg); border-color: var(--tag-yel-brd); }

.stars { font-family: 'Space Mono', monospace; font-size: 0.7rem; color: var(--accent3); margin-left: auto; }

.card-title {
  font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 700;
  color: var(--text); margin-bottom: 0.5rem; letter-spacing: -0.02em;
}
.card-desc { font-size: 0.9rem; color: var(--muted); font-style: italic; font-weight: 300; line-height: 1.7; }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}
.repo-link {
  font-family: 'Space Mono', monospace; font-size: 0.7rem;
  color: var(--muted); text-decoration: none; transition: color 0.2s;
}
.repo-link:hover { color: var(--accent); }
.read-more {
  font-family: 'Space Mono', monospace; font-size: 0.7rem; color: var(--accent);
  text-decoration: none; display: flex; align-items: center; gap: 0.4rem; transition: gap 0.2s;
}
.read-more:hover { gap: 0.8rem; }

/* ── SECTIONS ── */
.section { max-width: 1200px; margin: 0 auto; padding: 4rem 2rem; animation: fadeUp 0.8s ease 0.2s both; }

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 2.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.section-title { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.section-title span {
  font-family: 'Fraunces', serif; font-style: italic; font-weight: 300;
  color: var(--muted); font-size: 1.1rem; margin-left: 0.6rem;
}
.view-all {
  font-family: 'Space Mono', monospace; font-size: 0.7rem; color: var(--muted);
  text-decoration: none; text-transform: uppercase; letter-spacing: 0.08em; transition: color 0.2s;
}
.view-all:hover { color: var(--accent); }

/* ── PROJECTS GRID ── */
.projects-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }

.project-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1.5rem;
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s;
}
.project-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.project-card:hover::before { transform: scaleX(1); }
.project-card.red::before    { background: var(--accent2); }
.project-card.yellow::before { background: var(--accent3); }

.project-lang {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: 'Space Mono', monospace; font-size: 0.65rem;
  color: var(--muted); margin-bottom: 1rem;
}
.lang-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.lang-dot.py { background: #3572A5; }
.lang-dot.ts { background: #2b7489; }
.lang-dot.rs { background: #dea584; }
.lang-dot.go { background: #00ADD8; }
.lang-dot.sh { background: #89e051; }

.project-name { font-family: 'Syne', sans-serif; font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.01em; }
.project-desc { font-size: 0.88rem; color: var(--muted); font-style: italic; font-weight: 300; line-height: 1.65; margin-bottom: 1.2rem; }
.project-meta { display: flex; align-items: center; gap: 1rem; }
.meta-item { font-family: 'Space Mono', monospace; font-size: 0.65rem; color: var(--muted); display: flex; align-items: center; gap: 0.3rem; }
.meta-item.star { color: var(--accent3); }

/* ── NEWS STRIP ── */
.news-strip {
  background: var(--surface);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}
.news-inner { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.news-list { display: flex; flex-direction: column; }

.news-item {
  display: grid; grid-template-columns: 80px 1fr auto;
  gap: 1.5rem; align-items: center;
  padding: 1.4rem 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover .news-title { color: var(--accent); }

.news-date { font-family: 'Space Mono', monospace; font-size: 0.65rem; color: var(--muted); line-height: 1.5; text-align: center; }
.news-date strong { display: block; font-size: 1.3rem; color: var(--text); font-weight: 700; line-height: 1; margin-bottom: 0.2rem; }
.news-title { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; transition: color 0.2s; margin-bottom: 0.25rem; }
.news-excerpt { font-size: 0.85rem; color: var(--muted); font-style: italic; font-weight: 300; }
.news-tags { display: flex; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── FOOTER ── */
footer {
  max-width: 1200px; margin: 0 auto; padding: 3rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
}
.footer-logo { font-family: 'Space Mono', monospace; font-size: 0.9rem; color: var(--accent); }
.footer-copy { font-family: 'Space Mono', monospace; font-size: 0.65rem; color: var(--muted); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a {
  font-family: 'Space Mono', monospace; font-size: 0.65rem; color: var(--muted);
  text-decoration: none; text-transform: uppercase; letter-spacing: 0.08em; transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

/* ── TICKER ── */
.ticker { background: var(--accent); color: var(--ticker-txt); overflow: hidden; height: 32px; display: flex; align-items: center; }
.ticker-inner {
  display: flex; gap: 3rem;
  animation: ticker 30s linear infinite;
  white-space: nowrap;
  font-family: 'Space Mono', monospace; font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
}
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ticker-sep { opacity: 0.35; }
