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

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

/* =============================================
   CANVAS DE PARTÍCULES (fons fix)
   ============================================= */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

/* =============================================
   FONS ANIMAT — CICLE COMPLET RGB (via HSL)
   ============================================= */
body {
  font-family: 'Poppins', sans-serif;
  animation: fadeInBody 1.5s ease-in-out,
             rgbCycle 40s linear infinite;
  color: #2c3e50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

/* =============================================
   CONTINGUT PER DAVANT DEL CANVAS
   ============================================= */
header,
#projectes {
  position: relative;
  z-index: 1;
}

/* =============================================
   HEADER
   ============================================= */
header {
  text-align: center;
  margin-bottom: 3rem;
}

.foto-rodona {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.foto-rodona:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* =============================================
   TÍTOL AMB GRADIENT (un sol bloc, sense conflicte)
   ============================================= */
h1 {
  font-size: 2.5rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  background: linear-gradient(90deg, #00897b, #0288d1, #00acc1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: slideDown 1s ease-out;
}

/* Cursor parpellejant del typewriter */
.cursor {
  display: inline-block;
  width: 3px;
  height: 0.85em;
  background: #0288d1;
  margin-left: 2px;
  vertical-align: middle;
  -webkit-text-fill-color: initial; /* override gradient per al cursor */
  animation: blink 1s infinite;
}

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

/* Subtítol */
.subtitle {
  color: #546e7a;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  opacity: 0;
  animation: fadeInUp 1s ease-out 0.5s forwards;
}

/* =============================================
   SECCIÓ PROJECTES
   ============================================= */
#projectes {
  width: 100%;
  max-width: 800px;
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  text-align: center;
  opacity: 0;
  animation: fadeInUp 1s ease-out 0.8s forwards;
}

/* =============================================
   CARDS DE PROJECTES
   ============================================= */
.projecte-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px);
  /* Les cards s'animen amb JS (classe .visible) */
  transition: transform 0.3s ease, box-shadow 0.3s ease,
              background 0.3s ease, border-color 0.3s ease;
}

/* Animació d'entrada de les cards */
.projecte-card.visible {
  animation: slideUpCard 0.6s ease-out forwards;
}

.projecte-card:nth-child(1) { animation-delay: 0.2s; }
.projecte-card:nth-child(2) { animation-delay: 0.4s; }
.projecte-card:nth-child(3) { animation-delay: 0.6s; }
.projecte-card:nth-child(4) { animation-delay: 0.8s; }

/* Efecte shimmer en hover */
.projecte-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: left 0.45s ease;
}

.projecte-card:hover::before {
  left: 100%;
}

.projecte-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
  background: rgba(241, 248, 233, 0.9);
  border-color: rgba(2, 136, 193, 0.3);
}

.projecte-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
  color: #00695c;
}

.projecte-card p {
  font-size: 0.95rem;
  color: #546e7a;
}

/* Fletxa animada al costat dret */
.projecte-card::after {
  content: '→';
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  font-size: 1.2rem;
  color: #0288d1;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.projecte-card:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* =============================================
   ANIMACIONS @keyframes
   ============================================= */

@keyframes fadeInBody {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes slideDown {
  from { transform: translateY(-40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

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

/* Cicle complet per tots els tons RGB (pastel, lluminositat alta) */
@keyframes rgbCycle {
  0%   { background-color: hsl(0,   60%, 88%); }   /* rosa */
  12%  { background-color: hsl(45,  60%, 88%); }   /* taronja */
  25%  { background-color: hsl(90,  60%, 88%); }   /* verd clar */
  37%  { background-color: hsl(150, 60%, 88%); }   /* menta */
  50%  { background-color: hsl(200, 60%, 88%); }   /* blau cel */
  62%  { background-color: hsl(240, 60%, 88%); }   /* blau */
  75%  { background-color: hsl(280, 60%, 88%); }   /* violeta */
  87%  { background-color: hsl(320, 60%, 88%); }   /* magenta */
  100% { background-color: hsl(360, 60%, 88%); }   /* torna al rosa */
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  h1 { font-size: 2rem; }
  .foto-rodona { width: 120px; height: 120px; }
  .projecte-card { padding: 1.25rem; }
}
