/* ========== RESET ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button, input {
  font: inherit;
  color: inherit;
}

/* ========== VARIABILI ========== */
:root {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #d4d4d4;
  --text-muted: #6a6a6a;
  --accent: #00ff88;
  --accent-dim: #00ff8833;
  --border: #1f1f1f;

  --space-sm: 1rem;
  --space-md: 2rem;
  --space-xl: 4rem;

  --max-width: 1200px;
  --side-padding: 3rem;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', 'Courier New', monospace;
}

/* ========== BASE ========== */
::selection { background: var(--accent); color: var(--bg); }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Etichette verdi monospace - usate in 3 punti */
.label, .stack-label, .contact-btn-label {
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-shadow: 0 0 8px var(--accent-dim);
}

.label { margin-bottom: var(--space-sm); }
.stack-label { margin-bottom: 0.8rem; }

/* ========== HEADER & NAV ========== */
header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-padding);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.logo::before {
  content: '>';
  color: var(--accent);
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 0.25s ease;
}

.logo.open::before {
  transform: rotate(90deg);
}

nav ul {
  display: flex;
  gap: 2rem;
  list-style: none;
}

nav ul li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

nav ul li a::before {
  content: '#';
  color: var(--accent);
  opacity: 0.5;
  margin-right: 0.2rem;
}

nav ul li a:hover { color: var(--accent); }
nav ul li a:hover::before { opacity: 1; }

.nav-right { display: flex; align-items: center; gap: 2rem; }

.lang-toggle {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-dim);
}

/* ========== MAIN ========== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-padding);
}

section {
  padding: var(--space-xl) 0;
  border-bottom: 1px dashed var(--border);
}

section:last-child { border-bottom: none; }

section h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

section h2::before { content: '// '; color: var(--accent); font-weight: 400; }

/* ========== ABOUT ========== */
#about {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#about h1 {
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  line-height: 1.1;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

#about h1::after {
  content: '_';
  color: var(--accent);
  animation: blink 1s step-end infinite;
  margin-left: 0.2rem;
  text-shadow: 0 0 12px var(--accent);
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.accent {
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-dim);
}

.about-description {
  color: var(--text-muted);
  max-width: 650px;
  margin-bottom: var(--space-md);
  line-height: 1.8;
}

/* ========== BUTTONS ========== */
.about-cta {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.85rem 1.6rem;
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary::before { content: '$ '; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary::before { content: '> '; color: var(--text-muted); }

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:hover::before { color: var(--accent); }

/* ========== STACK ========== */
.stack-category { margin-bottom: var(--space-md); }
.stack-category:last-child { margin-bottom: 0; }

.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.stack-list li {
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  cursor: default;
}

/* ========== PROJECTS ========== */
#projects { counter-reset: project-counter; }

#projects article {
  border: 1px solid var(--border);
  padding: 1.75rem;
  padding-top: 3.5rem;
  margin-bottom: var(--space-sm);
  background: var(--bg-elevated);
  position: relative;
  counter-increment: project-counter;
  overflow: hidden;
}

#projects article::before {
  content: '[0' counter(project-counter) ']';
  position: absolute;
  top: 1.25rem;
  right: 1.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  z-index: 2;
}

#projects h3 {
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

#projects h3::before { content: '> '; color: var(--text-muted); }

#projects article p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ========== PROJECT GALLERY BASE ========== */
.project-gallery {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 1.75rem 1rem 0;
  margin: 0 -1.75rem 1.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

.project-gallery img {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: block;
  border-radius: 8px;
}

.gallery-mobile img {
  height: 480px;
  width: auto;
}

.gallery-desktop img {
  height: 460px;
  width: auto;
}

.project-gallery::-webkit-scrollbar { height: 6px; }
.project-gallery::-webkit-scrollbar-track { background: var(--bg); border: 1px solid var(--border); }
.project-gallery::-webkit-scrollbar-thumb { background: var(--border); transition: background 0.2s; }
.project-gallery:hover::-webkit-scrollbar-thumb { background: var(--accent); }

/* ========== CONTACT ========== */
.contact-intro {
  color: var(--text-muted);
  max-width: 650px;
  margin-bottom: var(--space-md);
  line-height: 1.8;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  max-width: 800px;
}

.contact-btn {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  text-decoration: none;
  transition: all 0.2s;
}

.contact-btn-value {
  font-size: 0.9rem;
  color: var(--text-muted);
  word-break: break-all;
  transition: color 0.2s;
}

.contact-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
  transform: translateY(-2px);
}

.contact-btn:hover .contact-btn-value { color: var(--text); }

/* ========== PROJECT LINKS ========== */
.project-links {
  margin-top: 1.25rem;
}

/* ========== FOOTER ========== */
footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem var(--side-padding);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer::before { content: '// '; color: var(--accent); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  :root {
    --side-padding: 1rem;
    --space-xl: 3rem;
  }

  header { padding: 1rem 0; }

  .logo { user-select: none; }

  nav { position: relative; }
  .nav-right { gap: 1rem; }

  nav ul {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 0.9rem);
    left: 0;
    background: var(--bg);
    border-left: 1px solid var(--accent);
    padding: 0.75rem 0 0.75rem 1.25rem;
    gap: 0.85rem;
    z-index: 200;
    list-style: none;
  }

  nav ul.open { display: flex; }

  nav ul li a {
    font-size: 0.9rem;
    color: var(--text-muted);
  }

  #about {
    min-height: auto;
    padding: 3rem 0;
  }

  .about-cta { flex-direction: column; width: 100%; }
  .btn { text-align: center; }

  #projects article {
    padding: 1.25rem;
    padding-top: 3rem;
  }

  #projects article::before {
    top: 1rem;
    right: 1.25rem;
  }

  .project-gallery {
    margin-right: -1.25rem;
    padding-right: 1.25rem;
  }

  .gallery-mobile img {
    width: 180px;
    height: auto;
  }

  .gallery-desktop img {
    width: 260px;
    height: auto;
  }

  .contact-grid { grid-template-columns: 1fr; }
}

.privacy-link {
  margin-top: var(--space-sm);
}

.privacy-link a {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s;
}

.privacy-link a:hover { color: var(--accent); }