/* ============================================================
   SERGIO CARPIO — PORTFOLIO CSS
   Fuente display: Syne (geométrica, técnica, moderna)
   Fuente body: DM Sans (legible, limpia)
   Dirección estética: dark tech refinado — no genérico
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ── VARIABLES ───────────────────────────────────────────── */
:root {
  --bg:        #060d19;
  --surface:   #0b1425;
  --card:      #0d1b2e;
  --card-alt:  #0a1628;
  --border:    rgba(56, 189, 248, 0.10);
  --border-h:  rgba(56, 189, 248, 0.45);
  --primary:   #38bdf8;
  --primary-d: #0ea5e9;
  --glow:      rgba(56, 189, 248, 0.18);
  --text:      #e2eaf4;
  --muted:     #64748b;
  --label:     #94a3b8;
  --radius:    12px;
  --radius-lg: 20px;
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── BASE ────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.75;
  background-color: var(--bg);
  color: var(--text);
  min-width: 320px;
  overflow-x: hidden;

  /* Textura de ruido sutil para dar profundidad */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56,189,248,0.07) 0%, transparent 70%);
}

/* Grano de ruido encima de todo usando pseudoelemento en body */
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='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ── HERO ────────────────────────────────────────────────── */
header {
  position: relative;
  padding: 14vh 5% 12vh;
  text-align: center;
  overflow: hidden;
}

/* Líneas de cuadrícula decorativas */
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(56,189,248,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56,189,248,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 80% at 50% 50%, black 30%, transparent 100%);
}

/* Orbe de luz central */
header::after {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(56,189,248,0.12) 0%, transparent 65%);
  pointer-events: none;
}

header h1 {
  position: relative;
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;

  /* Gradiente sutil en el texto */
  background: linear-gradient(135deg, #ffffff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;

  animation: fadeUp 0.7s ease both;
}

header p {
  position: relative;
  margin-top: 1rem;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  font-weight: 300;
  color: var(--label);
  letter-spacing: 0.02em;
  animation: fadeUp 0.7s 0.15s ease both;
}

/* Separador decorativo bajo el hero */
.hero-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 2.5rem;
  animation: fadeUp 0.7s 0.25s ease both;
}

.hero-divider span {
  display: block;
  height: 1px;
  width: 60px;
  background: linear-gradient(90deg, transparent, var(--primary));
}

.hero-divider span:last-child {
  background: linear-gradient(90deg, var(--primary), transparent);
}

.hero-divider i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

/* ── ANIMACIONES ─────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow); }
  50%       { box-shadow: 0 0 20px 4px var(--glow); }
}

/* ── SECTIONS ────────────────────────────────────────────── */
section {
  width: 90%;
  max-width: 1000px;
  margin: 6rem auto;
}

/* Animación de entrada al hacer scroll */
section {
  opacity: 0;
  transform: translateY(24px);
  animation: fadeUp 0.6s ease forwards;
}

section:nth-child(1) { animation-delay: 0.1s; }
section:nth-child(2) { animation-delay: 0.2s; }
section:nth-child(3) { animation-delay: 0.3s; }
section:nth-child(4) { animation-delay: 0.4s; }
section:nth-child(5) { animation-delay: 0.5s; }

section h2 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.4rem, 3.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
  position: relative;
  display: inline-block;
  color: #fff;
}

section h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
  border-radius: 2px;
}

/* ── SOBRE MÍ ────────────────────────────────────────────── */
section:first-of-type p {
  font-size: 1.05rem;
  color: var(--label);
  max-width: 720px;
  line-height: 1.85;
}

/* ── CV LINK ─────────────────────────────────────────────── */
.cv-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.8rem;
  padding: 0.75rem 2rem;
  background: transparent;
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1.5px solid var(--border-h);
  border-radius: var(--radius);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.cv-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glow);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cv-link:hover {
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(56,189,248,0.2);
  text-decoration: none;
}

.cv-link:hover::before {
  opacity: 1;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  position: relative;
  background: var(--card);
  padding: 2rem 2.2rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
}

/* Línea de acento izquierda */
.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Brillo de esquina superior derecha */
.card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(56,189,248,0.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-h);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), 0 0 0 1px rgba(56,189,248,0.08);
}

.card:hover::before,
.card:hover::after {
  opacity: 1;
}

.card h3 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.card span {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.card p {
  color: var(--label);
  font-size: 0.95rem;
  line-height: 1.8;
}

.card strong {
  color: var(--text);
  font-weight: 500;
}

/* ── ICONOS TECNOLOGÍAS ──────────────────────────────────── */
.icono {
  width: 36px;
  height: 36px;
  vertical-align: middle;
  object-fit: contain;
  margin-right: 6px;
  margin-top: 0.8rem;
  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.2s ease;
  filter: drop-shadow(0 0 0 transparent);
}

.icono:hover {
  opacity: 1;
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 8px rgba(56,189,248,0.3));
}

/* ── LOGO GITHUB en cards ────────────────────────────────── */
.logo {
  width: 28px;
  height: 28px;
  display: block;
  float: right;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
  margin-top: -28px;
}

.logo:hover {
  opacity: 1;
  transform: scale(1.1);
}

.img {
  max-width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  margin: 0.3rem auto 0;
  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ── SKILLS ──────────────────────────────────────────────── */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  gap: 0.9rem;
}

.skill {
  background: var(--card);
  padding: 1rem 0.5rem 0.8rem;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}

.skill:hover {
  border-color: var(--border-h);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.skill:hover .img {
  opacity: 1;
  transform: scale(1.08);
}

/* ── LINKS ───────────────────────────────────────────────── */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #fff;
  text-decoration: none;
}

/* ── CONTACTO ────────────────────────────────────────────── */
.contact {
  position: relative;
  padding: 3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.contact::before {
  content: '';
  position: absolute;
  bottom: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(56,189,248,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.contact h2 {
  margin-bottom: 1.2rem;
}

.contact > p:first-of-type {
  color: var(--label);
  font-size: 0.98rem;
  margin-bottom: 1.8rem;
  max-width: 580px;
}

.contact p {
  margin-bottom: 0.6rem;
  font-size: 0.97rem;
}

.contact p strong {
  color: #fff;
}

/* Separador de contacto */
.contact-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: #1e3a5f;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── SELECCIÓN ───────────────────────────────────────────── */
::selection {
  background: rgba(56,189,248,0.25);
  color: #fff;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  header {
    padding: 10vh 5% 8vh;
  }

  section {
    margin: 4rem auto;
  }

  .card {
    padding: 1.6rem 1.5rem;
  }

  .contact {
    padding: 2rem 1.5rem;
  }

  .skills {
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  }

  .logo {
    margin-top: 0;
    float: none;
    display: inline-block;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 2rem;
  }

  .card {
    padding: 1.3rem 1.2rem;
  }
}