/* Mattia Ballabio - Professional Portfolio Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #080c14;
  --bg-secondary: #0e1626;
  --bg-card: rgba(16, 24, 40, 0.75);
  --bg-card-hover: rgba(22, 34, 58, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(56, 189, 248, 0.35);
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
  selection-background-color: #06b6d4;
  selection-color: #000;
}

::selection {
  background: rgba(6, 182, 212, 0.35);
  color: #fff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #080c14;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #06b6d4;
}

/* Custom Cursor */
.custom-cursor-dot,
.custom-cursor-outline {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, transform 0.15s ease-out;
}

.custom-cursor-dot {
  width: 8px;
  height: 8px;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8, 0 0 20px #06b6d4;
}

.custom-cursor-outline {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease, transform 0.08s ease-out;
}

body.cursor-hover .custom-cursor-outline {
  width: 55px;
  height: 55px;
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.08);
}

body.cursor-hover .custom-cursor-dot {
  background: #c084fc;
  box-shadow: 0 0 12px #c084fc;
}

@media (pointer: coarse) or (hover: none) {
  .custom-cursor-dot,
  .custom-cursor-outline {
    display: none !important;
  }
}

/* Dynamic Scroll Progress Bar */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4, #3b82f6, #8b5cf6, #ec4899);
  z-index: 10000;
  width: 0%;
  transition: width 0.05s ease-out;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.75);
}

/* Background Canvas */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Background Grids & Ambient Glows */
.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 1;
  mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
  animation: floatAmbient 18s ease-in-out infinite alternate;
}

@keyframes floatAmbient {
  0% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-40px) scale(1.1) translateX(20px); }
  100% { transform: translateY(30px) scale(0.95) translateX(-20px); }
}

/* Glassmorphism Card with Spotlight */
.glass-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.35s ease, 
              box-shadow 0.35s ease;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    600px circle at var(--mouse-x, -500px) var(--mouse-y, -500px),
    rgba(56, 189, 248, 0.12),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 2;
}

.glass-card:hover::before {
  opacity: 1;
}

.glass-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px -5px rgba(56, 189, 248, 0.2);
}

/* 3D Tilt Card Base */
.tilt-card {
  transform-style: preserve-3d;
  perspective: 1000px;
}

/* Text Gradients */
.text-gradient-cyan {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-gold {
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-emerald {
  background: linear-gradient(135deg, #34d399 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Terminal Styling */
.terminal-window {
  background: #090e17;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 12px;
  font-family: var(--font-mono);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(6, 182, 212, 0.15);
  overflow: hidden;
}

.terminal-header {
  background: #0d1522;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #eab308; }
.dot-green { background: #22c55e; }

.terminal-body {
  padding: 16px;
  min-height: 280px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.6;
}

.terminal-prompt {
  color: #38bdf8;
  font-weight: 600;
}

.terminal-command {
  color: #f1f5f9;
}

.terminal-output {
  color: #94a3b8;
  margin-bottom: 12px;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  flex: 1;
  caret-color: #38bdf8;
}

/* Animations */
.animate-pulse-slow {
  animation: pulseSlow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseSlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.badge-glow {
  position: relative;
}
.badge-glow::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: inherit;
  border-radius: inherit;
  filter: blur(6px);
  opacity: 0.5;
  z-index: -1;
}

/* Scroll reveal initial states */
.reveal {
  opacity: 0;
  transform: translateY(35px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.15s; }
.reveal-delay-2 { transition-delay: 0.3s; }
.reveal-delay-3 { transition-delay: 0.45s; }

/* Timeline styling */
.timeline-stem {
  position: absolute;
  left: 20px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: linear-gradient(180deg, #06b6d4, #3b82f6, #8b5cf6, transparent);
}

@media (min-width: 768px) {
  .timeline-stem {
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Floating Badges */
.tech-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  transition: all 0.25s ease;
}

.tech-tag:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  transform: translateY(-2px);
}

/* Button Glows */
.btn-glow-primary {
  position: relative;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #7c3aed 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-glow-primary:hover {
  box-shadow: 0 0 35px rgba(14, 165, 233, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  transform: translateY(-2px) scale(1.02);
}

.btn-glow-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.btn-glow-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
  transform: translateY(-2px);
}

/* Toast Notification */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  border: 1px solid #38bdf8;
  color: #f8fafc;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10001;
  font-size: 0.9rem;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Modal Backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(12px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0c1322;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 20px;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}
