/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100vw;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   COLOR THEMES
   ============================================ */
/* TEMA SCURO (default) */
body {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60c4fa;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --bg-dark: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222222;
  --text-primary: #ffffff;
  --text-secondary: #b4b4b4;
  --border-subtle: rgba(255, 255, 255, 0.08);
}

/* TEMA GIORNO */
body.light-theme {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --accent-purple: #7c3aed;
  --accent-pink: #db2777;
  --bg-dark: #ffffff;
  --bg-card: #f8f9fa;
  --bg-card-hover: #f1f3f5;
  --text-primary: #0f0f0f;
  --text-secondary: #6b7280;
  --border-subtle: rgba(0, 0, 0, 0.08);
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
header {
  position: fixed;
  top: 0;
  width: 100%;
  max-width: 100vw;
  z-index: 1000;
  background: rgba(15, 15, 15, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
  overflow: visible;
}

body.light-theme header {
  background: rgba(255, 255, 255, 0.8);
}

header.scrolled {
  background: rgba(15, 15, 15, 0.95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

body.light-theme header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 60px;
  height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.logo {
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

nav {
  display: flex;
  align-items: center;
  gap: 30px;
}

nav ul {
  display: flex;
  gap: 50px;
  list-style: none;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
  letter-spacing: 0.3px;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent-purple));
  transition: width 0.3s ease;
}

nav a:hover {
  color: var(--text-primary);
}

nav a:hover::after {
  width: 100%;
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  width: 50px;
  height: 50px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.05);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--text-primary);
  transition: all 0.3s ease;
}

.theme-toggle .sun-icon {
  display: none;
}

body.light-theme .theme-toggle .moon-icon {
  display: none;
}

body.light-theme .theme-toggle .sun-icon {
  display: block;
}

/* ============================================
   MOBILE MENU (HAMBURGER)
   ============================================ */
.mobile-menu-toggle {
  display: none;
  width: 45px;
  height: 45px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.mobile-menu-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.mobile-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.3s ease;
  border-radius: 2px;
}

.mobile-menu-toggle span:nth-child(1) { top: 14px; }
.mobile-menu-toggle span:nth-child(2) { top: 21.5px; }
.mobile-menu-toggle span:nth-child(3) { top: 29px; }

.mobile-menu-toggle.active span:nth-child(1) {
  top: 21.5px;
  transform: translateX(-50%) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-50%) scale(0);
}

.mobile-menu-toggle.active span:nth-child(3) {
  top: 21.5px;
  transform: translateX(-50%) rotate(-45deg);
}

/* Menu Overlay */
.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  animation: fadeIn 0.3s ease;
}

.menu-overlay.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   CONTACT SECTION
   ============================================ */
#contact {
  padding: 120px 60px;
  max-width: 1000px;
  margin: 0 auto;
  text-align: center;
}

.contact-content {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
  padding: 80px 60px;
  border-radius: 30px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  position: relative;
  overflow: hidden;
}

.contact-content::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent, rgba(59, 130, 246, 0.3), transparent);
  animation: rotate 4s linear infinite;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

.contact-content::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--bg-dark);
  border-radius: 30px;
  z-index: 0;
}

.contact-inner {
  position: relative;
  z-index: 1;
}

.contact-title {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 900;
  margin-bottom: 20px;
  letter-spacing: -1px;
}

.contact-description {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 50px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.contact-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 25px;
  margin-bottom: 50px;
}

.contact-method {
  padding: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  text-decoration: none;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.contact-method:hover {
  transform: translateY(-5px);
  border-color: rgba(59, 130, 246, 0.4);
  background: var(--bg-card-hover);
}

.method-icon {
  width: 60px;
  height: 60px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.method-icon img,
.skill-icon {
  width: 28px;
  height: 28px;
}

.skill-icon {
  width: 20px;
  height: 20px;
}

body.light-theme .method-icon img,
body.light-theme .skill-icon {
  filter: brightness(0) saturate(100%);
}

body:not(.light-theme) .method-icon img,
body:not(.light-theme) .skill-icon {
  filter: brightness(0) invert(1);
}

.contact-method h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.contact-method p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.cta-large {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 20px 45px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3);
}

.cta-large:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 15px 50px rgba(59, 130, 246, 0.4);
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  padding: 60px 60px 40px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 60px;
  margin-bottom: 40px;
}

.footer-brand h3 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 15px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-brand p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.footer-social {
  display: flex;
  gap: 15px;
}

.footer-social a {
  width: 40px;
  height: 40px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.footer-social a:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  transform: translateY(-3px);
}

.footer-social img {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

body.light-theme .footer-social img {
  filter: brightness(0) saturate(100%);
}

body:not(.light-theme) .footer-social img {
  filter: brightness(0) invert(1);
}

.footer-links h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.footer-links ul {
  list-style: none;
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  padding-top: 30px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   RESPONSIVE - MOBILE MENU
   ============================================ */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  nav ul {
    display: none;
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 20px;
    gap: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    max-width: 280px;
    flex-direction: column;
    z-index: 10000;
    animation: slideIn 0.3s ease;
  }
  
  body.light-theme nav ul {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  }
  
  @keyframes slideIn {
    from {
      opacity: 0;
      transform: translateY(-20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  nav ul.mobile-menu-open {
    display: flex;
  }
  
  nav ul li {
    width: 100%;
    border-bottom: 1px solid var(--border-subtle);
  }
  
  nav ul li:last-child {
    border-bottom: none;
  }
  
  nav a {
    display: block;
    padding: 15px 10px;
    font-size: 16px;
    text-align: left;
  }
  
  nav a::after {
    display: none;
  }
  
  nav a:hover {
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
  }
  
  nav {
    gap: 15px;
  }
  
  .header-container {
    padding: 0 20px;
  }
}

@media (max-width: 640px) {
  .header-container {
    padding: 0 15px;
    height: 70px;
  }
  
  .logo {
    font-size: 20px;
  }
  
  .mobile-menu-toggle {
    width: 42px;
    height: 42px;
  }
  
  .mobile-menu-toggle span {
    width: 20px;
  }
  
  .theme-toggle {
    width: 42px;
    height: 42px;
  }
  
  .theme-toggle svg {
    width: 20px;
    height: 20px;
  }
  
  nav ul {
    top: 70px;
    right: 15px;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0 12px;
  }
  
  .logo {
    font-size: 18px;
  }
  
  .mobile-menu-toggle {
    width: 40px;
    height: 40px;
  }
  
  .mobile-menu-toggle span {
    width: 18px;
  }
  
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
  
  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }
}

/* ============================================
   RESPONSIVE - GENERAL
   ============================================ */
@media (max-width: 1200px) {
  .footer-content {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 968px) {
  .header-container,
  #contact,
  footer {
    padding-left: 30px;
    padding-right: 30px;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 640px) {
  #contact,
  footer {
    padding: 80px 20px;
  }
  
  .contact-content {
    padding: 50px 30px;
  }
  
  .contact-methods {
    grid-template-columns: 1fr;
  }
}