/* ==========================================================================
   SalvaCode · estilos
   Los colores se definen como variables: cambiá el tema desde :root.
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;

  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: rgb(99 102 241 / 0.1);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  --gradient-btn: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); /* fijo: texto blanco legible en ambos temas */

  --ok: #16a34a;
  --warn: #d97706;
  --info: #2563eb;
  --bad: #dc2626;
  --idle: #94a3b8;

  --radius: 14px;
  --shadow: 0 10px 20px -8px rgb(15 23 42 / 0.12), 0 4px 8px -4px rgb(15 23 42 / 0.06);
  --shadow-hover: 0 18px 30px -10px rgb(15 23 42 / 0.2);
  --header-h: 72px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-alt: #0f172a;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1e293b;
    --primary: #818cf8;
    --primary-2: #a78bfa;
    --primary-soft: rgb(129 140 248 / 0.14);
    --ok: #22c55e;
    --warn: #f59e0b;
    --info: #60a5fa;
    --bad: #f87171;
    --idle: #64748b;
    --shadow: 0 10px 20px -8px rgb(0 0 0 / 0.5);
    --shadow-hover: 0 18px 30px -10px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

/* --- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
  margin: 0;
  font-family: "Poppins", system-ui, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.75rem; }
p { margin: 0 0 1rem; }
ul { margin: 0; padding: 0; list-style: none; }

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}
@media (min-width: 640px) { .container { padding-inline: 24px; } }
@media (min-width: 1024px) { .container { padding-inline: 32px; } }

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  padding: 8px 16px; border-radius: 8px;
  background: var(--primary); color: #fff; text-decoration: none;
}
.skip-link:focus { top: 16px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 6px; }

.icon {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--lg { width: 24px; height: 24px; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Botones ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 500; font-size: 0.95rem;
  text-decoration: none; cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--gradient-btn); color: #fff; }
.btn--primary:hover { opacity: 0.9; }
.btn--outline { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn--outline:hover { border-color: var(--primary); color: var(--primary); }
.btn--lg { padding: 12px 28px; font-size: 1rem; }
.btn--sm { padding: 7px 14px; font-size: 0.875rem; }
.btn--full { width: 100%; }
.btn .icon { width: 16px; height: 16px; }

/* --- Header -------------------------------------------------------------- */

.header {
  position: fixed; inset: 0 0 auto; z-index: 50;
  height: var(--header-h);
  transition: background-color 0.3s, box-shadow 0.3s;
}
.header--scrolled {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--border);
}
.header__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.5rem; font-weight: 700; text-decoration: none; margin: 0; }

.nav { display: flex; align-items: center; gap: 28px; }
.nav__link {
  position: relative; text-decoration: none;
  font-size: 0.9rem; font-weight: 500; color: var(--muted);
  transition: color 0.2s;
}
.nav__link::after {
  content: ""; position: absolute; left: 0; bottom: -4px;
  width: 100%; height: 2px; border-radius: 2px;
  background: var(--gradient);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.25s ease-out;
}
.nav__link:hover, .nav__link--activo { color: var(--primary); }
.nav__link:hover::after, .nav__link--activo::after { transform: scaleX(1); }

.menu-btn {
  display: none; padding: 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); cursor: pointer;
}

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 8px 16px 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  }
  .nav--abierto { visibility: visible; opacity: 1; transform: none; }
  .nav__link { padding: 10px 12px; border-radius: 8px; font-size: 1rem; }
  .nav__link::after { display: none; }
  .nav__link--activo { background: var(--primary-soft); }
  .nav__cta { margin-top: 8px; }
}

/* --- Secciones ----------------------------------------------------------- */

.section { padding: 88px 0; }
.section--alt { background: var(--bg-alt); }

.section__head { text-align: center; max-width: 680px; margin: 0 auto 48px; }
.section__head p { color: var(--muted); }

h2 { font-size: clamp(1.9rem, 4vw, 2.4rem); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.texto { color: var(--muted); }

.pill {
  display: inline-block; padding: 4px 14px; margin-bottom: 16px;
  border-radius: 999px; font-size: 0.85rem; font-weight: 500;
  background: var(--primary-soft); color: var(--primary);
}

.redes { display: flex; gap: 16px; }
.redes a { color: var(--muted); transition: color 0.2s; display: inline-flex; }
.redes a:hover { color: var(--primary); }

/* --- Hero ---------------------------------------------------------------- */

.hero {
  position: relative; overflow: hidden;
  min-height: 100svh;
  display: flex; align-items: center;
  padding: calc(var(--header-h) + 40px) 0 80px;
}
.hero__blob {
  position: absolute; width: 18rem; height: 18rem; border-radius: 50%;
  filter: blur(64px); pointer-events: none;
}
.hero__blob--a { top: 80px; right: 10%; background: rgb(139 92 246 / 0.22); }
.hero__blob--b { bottom: 80px; left: 10%; background: rgb(99 102 241 / 0.2); }

.hero__grid {
  position: relative;
  display: grid; gap: 48px; align-items: center;
  grid-template-columns: 1fr;
  text-align: center;
}
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.8rem); font-weight: 700; margin-bottom: 20px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 34rem; margin: 0 auto 32px; }
.acciones { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.hero .redes { margin-top: 32px; justify-content: center; }

@media (min-width: 1024px) {
  .hero__grid { grid-template-columns: 1.1fr 1fr; text-align: left; }
  .lead { margin-inline: 0; }
  .acciones, .hero .redes { justify-content: flex-start; }
}

.code-card {
  max-width: 460px; margin-inline: auto;
  border-radius: 16px; overflow: hidden;
  background: #0f172a; color: #e2e8f0;
  box-shadow: 0 30px 60px -20px rgb(79 70 229 / 0.45);
  border: 1px solid rgb(148 163 184 / 0.15);
  text-align: left;
}
.code-card__bar {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px; background: #1e293b;
}
.code-card__bar span { width: 11px; height: 11px; border-radius: 50%; background: #475569; }
.code-card__bar span:nth-child(1) { background: #f87171; }
.code-card__bar span:nth-child(2) { background: #fbbf24; }
.code-card__bar span:nth-child(3) { background: #4ade80; }
.code-card__bar em { margin-left: 8px; font-style: normal; font-size: 0.8rem; color: #94a3b8; }
.code-card__body {
  margin: 0; padding: 20px;
  font: 0.85rem/1.8 "JetBrains Mono", ui-monospace, monospace;
  overflow-x: auto;
}
.c-k { color: #c4b5fd; }
.c-s { color: #86efac; }

.hero__scroll {
  position: absolute; bottom: 24px; left: 50%; translate: -50% 0;
  color: var(--muted); display: none;
  animation: rebote 1.6s ease-in-out infinite;
}
@media (min-width: 768px) { .hero__scroll { display: block; } }
@keyframes rebote { 50% { transform: translateY(8px); } }

/* --- Sobre mí ------------------------------------------------------------ */

.about { display: grid; gap: 48px; align-items: center; }
@media (min-width: 1024px) { .about { grid-template-columns: 1fr 1fr; } }
/* Se descuenta el marco (14px) a cada lado para que no toque el borde en celulares */
.about__img { position: relative; isolation: isolate; width: min(100% - 28px, 380px); margin-inline: auto; }
.about__img img { border-radius: var(--radius); width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
/* Marco con el degradé de la marca, corrido detrás de la foto */
.about__img::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: var(--radius); background: var(--gradient-btn);
  transform: translate(14px, 14px); opacity: 0.5;
}

.areas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 24px 0 32px; }
.area { padding: 16px; transition: transform 0.3s, box-shadow 0.3s; }
.area:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.area h3 { font-size: 1rem; color: var(--primary); margin-bottom: 4px; }
.area p { font-size: 0.875rem; color: var(--muted); margin: 0; }

/* --- Proyectos ----------------------------------------------------------- */

.monitor {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 0.85rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
}
.monitor__punto { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: latido 2s ease-out infinite; }

.proyectos { display: grid; gap: 28px; }
@media (min-width: 720px) { .proyectos { grid-template-columns: repeat(2, 1fr); } }

.proyecto { display: flex; flex-direction: column; overflow: hidden; transition: transform 0.3s, box-shadow 0.3s; }
.proyecto:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.proyecto__media { position: relative; display: block; aspect-ratio: 16 / 10; background: var(--surface-2); }
.proyecto__media img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: filter 0.3s; }

.proyecto__cuerpo { display: flex; flex-direction: column; flex: 1; padding: 20px 22px 22px; }
.proyecto__nombre { font-size: 1.2rem; margin-bottom: 6px; }
.proyecto__desc { color: var(--muted); font-size: 0.95rem; }
.proyecto__detalle { font-size: 0.85rem; color: var(--muted); margin: 14px 0 0; min-height: 1.4em; }
.proyecto__detalle:empty { display: none; }
.proyecto__link { margin-top: auto; align-self: flex-start; }
.proyecto__cuerpo .tags { margin-bottom: 18px; }

/* Con un solo proyecto, la tarjeta ocupa todo el ancho y en pantallas grandes va horizontal */
.proyecto:only-child { grid-column: 1 / -1; }
@media (min-width: 860px) {
  .proyecto:only-child {
    display: grid; grid-template-columns: 3fr 2fr;
    width: min(100%, 1040px); justify-self: center;
  }
  .proyecto:only-child .proyecto__cuerpo { justify-content: center; padding: 32px; }
  .proyecto:only-child .proyecto__nombre { font-size: 1.5rem; }
  .proyecto:only-child .proyecto__link { margin-top: 20px; }
}

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li { padding: 3px 12px; border-radius: 999px; font-size: 0.8rem; background: var(--primary-soft); color: var(--primary); }

/* Insignia de estado sobre la captura */
.estado {
  position: absolute; bottom: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
  background: rgb(255 255 255 / 0.92); color: #0f172a;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  --dot: var(--idle);
}
.estado__punto { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }

.proyecto[data-estado="online"] .estado { --dot: #16a34a; }
.proyecto[data-estado="online"] .estado__punto { animation: latido 2s ease-out infinite; }
.proyecto[data-estado="privado"] .estado { --dot: #d97706; }
.proyecto[data-estado="construccion"] .estado { --dot: #2563eb; }
.proyecto[data-estado="error"] .estado { --dot: #ea580c; }
.proyecto[data-estado="caido"] .estado { --dot: #dc2626; }
.proyecto[data-estado="verificando"] .estado__punto { animation: parpadeo 1s ease-in-out infinite; }

/* Sitios caídos: se muestran apagados y al final de la lista */
.proyecto[data-estado="caido"] { order: 1; }
.proyecto[data-estado="caido"] .proyecto__media img { filter: grayscale(1) opacity(0.55); }
.proyecto[data-estado="caido"] .proyecto__detalle { color: var(--bad); }
.proyecto__link[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }

@keyframes latido {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dot, var(--ok)) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}
.monitor__punto { --dot: var(--ok); }
@keyframes parpadeo { 50% { opacity: 0.3; } }

/* --- Habilidades --------------------------------------------------------- */

.skills { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.skills__grupo { padding: 24px; }
.skills__grupo h3 { font-size: 1.2rem; margin-bottom: 16px; }

.chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.chips li {
  display: flex; align-items: center; justify-content: center;
  padding: 10px; border-radius: 10px; text-align: center;
  font-size: 0.875rem; font-weight: 500;
  background: var(--surface-2); color: var(--muted);
  transition: transform 0.2s;
}
.chips li:hover { transform: scale(1.04); }
/* Si la cantidad es impar, el último ocupa la fila entera */
.chips:not(.chips--centro) li:last-child:nth-child(odd) { grid-column: 1 / -1; }

.metodologias { max-width: 760px; margin: 56px auto 0; padding: 32px; text-align: center; }
.metodologias h3 { font-size: 1.5rem; margin-bottom: 20px; }
@media (min-width: 640px) { .chips--centro { grid-template-columns: repeat(4, 1fr); } }

/* --- Contacto ------------------------------------------------------------ */

.contacto { display: grid; gap: 32px; }
@media (min-width: 1024px) { .contacto { grid-template-columns: 1fr 1fr; } }

.contacto__info { padding: 32px; }
.contacto__info h3 { font-size: 1.4rem; margin-bottom: 24px; }
.contacto__info h4 { margin: 32px 0 14px; }
.datos { display: grid; gap: 20px; }
.datos li { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.datos .icon { color: var(--primary); }
.datos a { text-decoration: none; overflow-wrap: anywhere; }
.datos a:hover { color: var(--primary); }

.form { padding: 32px; display: grid; gap: 20px; }
.campo label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.campo input, .campo textarea {
  width: 100%; padding: 10px 14px;
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.campo textarea { resize: vertical; }
.campo input:focus, .campo textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form__nota { font-size: 0.85rem; color: var(--muted); margin: 0; }
.form__nota a { color: var(--primary); }

/* --- Footer -------------------------------------------------------------- */

.footer { padding: 56px 0 28px; }
.footer__grid { display: grid; gap: 32px; }
@media (min-width: 768px) { .footer__grid { grid-template-columns: repeat(3, 1fr); } }
.footer p { color: var(--muted); }
.footer .logo { font-size: 1.3rem; margin-bottom: 12px; }
.footer h4 { font-size: 1.05rem; margin-bottom: 14px; }
.footer__links { display: grid; gap: 8px; }
.footer__links a { color: var(--muted); text-decoration: none; }
.footer__links a:hover { color: var(--primary); }
.footer__copy { text-align: center; margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); font-size: 0.9rem; }

/* --- Animaciones de entrada ---------------------------------------------- */

.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease-out, transform 0.6s ease-out; }
.js .reveal--visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
