/* Fuentes cargadas vía <link> en el HTML (display=swap) */

/*=============== VARIABLES CSS ===============*/
:root {
  /*========== Colors ==========*/
  /*Color mode HSL(hue, saturation, lightness)*/
  /*
      Blue: hsl(207, 90%, 61%)
      Purple: hsl(250, 66%, 75%)
      Pink: hsl(356, 66%, 75%)
      Teal: hsl(174, 63%, 62%)
  */

  --hue: 207;
  --sat: 90%;
  --lig: 61%;
  --first-color: hsl(var(--hue), var(--sat), var(--lig));
  --first-color-alt: hsl(var(--hue), var(--sat), 57%); /* -4% */
  --title-color: hsl(var(--hue), 12%, 15%);
  --text-color: hsl(var(--hue), 12%, 45%);
  --text-color-light: hsl(var(--hue), 8%, 75%);
  --text-color-lighten: hsl(var(--hue), 8%, 92%);
  --body-color: hsl(var(--hue), 100%, 99%);
  --container-color: #fff;

  /*========== Font and typography ==========*/
  --body-font: 'Poppins', sans-serif;
  --h2-font-size: clamp(1.25rem, 1.1vw + 1rem, 1.75rem);
  --h3-font-size: clamp(1rem, .6vw + .8rem, 1.25rem);
  --normal-font-size: clamp(.938rem, .3vw + .8rem, 1.05rem);
  --small-font-size: .813rem;
  --smaller-font-size: .75rem;
  /*========== Radius ==========*/
  --radius: 1rem; /* 16px */
  --ring-color: hsla(var(--hue), var(--sat), var(--lig), .35);
}

@media screen and (min-width: 968px) {
  :root {
    --h2-font-size: clamp(1.5rem, .8vw + 1.25rem, 2rem);
    --h3-font-size: clamp(1.15rem, .6vw + .9rem, 1.35rem);
    --normal-font-size: clamp(1rem, .25vw + .9rem, 1.1rem);
    --small-font-size: .875rem;
    --smaller-font-size: .813rem;
  }
}

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

body {
  font-family: var(--body-font);
  font-size: var(--normal-font-size);
  background:
    radial-gradient(1200px 600px at 110% -10%, hsla(var(--hue), 100%, 70%, .07), transparent 60%),
    radial-gradient(800px 400px at -10% 0%, hsla(250, 66%, 75%, .06), transparent 60%),
    var(--body-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: .3s; /* For animation dark mode */
}

/* Canvas de partículas (parallax sutil) */
#bg-particles { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
/* Asegurar contenido por encima del canvas */
.profile, .main, .footer, .back-to-top { position: relative; z-index: 1; }

h1, h2, h3 {
  color: var(--title-color);
  font-weight: 600;
}

ul { list-style: none; }

a { text-decoration: none; }

img { max-width: 100%; height: auto; }

/* Accesibilidad: estados de foco visibles */
:focus-visible { outline: 3px solid var(--first-color); outline-offset: 2px; box-shadow: 0 0 0 4px var(--ring-color); }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  background: var(--first-color);
  color: #fff;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  z-index: 1000;
}

/*=============== THEME ===============*/
.change-theme {
  position: absolute;
  top: 1.5rem;
  right: 0;
  font-size: 1.25rem;
  color: var(--title-color);
  cursor: pointer;
  transition: .3s;
}
.change-theme:hover { color: var(--first-color); }

/*========== Variables Dark theme ==========*/
body.dark-theme {
  --title-color: hsl(var(--hue), 12%, 95%);
  --text-color: hsl(var(--hue), 12%, 75%);
  --body-color: hsl(var(--hue), 40%, 8%);
  --container-color: hsl(var(--hue), 24%, 12%);
}

.dark-theme .button__gray { background-color: var(--container-color); }
.dark-theme .button__gray:hover { background-color: hsl(var(--hue), 24%, 16%); }
.dark-theme .filters__content { background-color: var(--container-color); }
.dark-theme::-webkit-scrollbar { background-color: hsl(var(--hue), 8%, 16%); }
.dark-theme::-webkit-scrollbar-thumb { background-color: hsl(var(--hue), 8%, 24%); }
.dark-theme::-webkit-scrollbar-thumb:hover { background-color: hsl(var(--hue), 8%, 32%); }

/*=============== REUSABLE CSS CLASSES ===============*/
.container { max-width: 1280px; margin-left: 1.5rem; margin-right: 1.5rem; }
.grid { display: grid; gap: 1.5rem; }

/*=============== PROFILE ===============*/
.profile { position: relative; padding-top: 3.5rem; }
.profile__container { row-gap: 2rem; }
.profile__data { display: grid; text-align: center; }
.profile__perfil {
  width: 92%; height: 92%; aspect-ratio: 1 / 1;
  background: linear-gradient(180deg, hsla(var(--hue), var(--sat), var(--lig), 1) 0%, hsla(var(--hue), var(--sat), var(--lig), .2) 100%);
  border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative;
}
.profile__perfil img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; transition: transform .6s cubic-bezier(.2,.6,.2,1); will-change: transform; }
@media (prefers-reduced-motion: no-preference) {
  .profile__border:hover .profile__perfil img,
  .profile__perfil:hover img { transform: scale(1.08); }
}
.profile__border { border: 3.5px solid var(--first-color); justify-self: center; width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; margin-bottom: .75rem; }
.profile__name { font-size: var(--h2-font-size); }
.profile__profession { font-size: var(--smaller-font-size); font-weight: 500; color: var(--text-color); margin-bottom: 1rem; }
.profile__social { display: flex; justify-content: center; column-gap: .75rem; }
.profile__social-link { font-size: 1.25rem; color: var(--title-color); transition: .3s; }
.profile__social-link:hover { color: var(--first-color); }
.profile__info { grid-template-columns: repeat(3, max-content); justify-content: center; column-gap: 2.5rem; }
.profile__info-group { text-align: center; }
.profile__info-number { font-size: var(--normal-font-size); margin-bottom: .25rem; }
.profile__info-description { font-size: var(--smaller-font-size); font-weight: 500; }
.profile__buttons, .profile__buttons-small { display: flex; align-items: center; justify-content: center; }
.profile__buttons { column-gap: 1rem; }
.profile__buttons-small { column-gap: .25rem; }

/*=============== BUTTONS ===============*/
.button { display: inline-flex; align-items: center; column-gap: .5rem; background-color: var(--first-color); color: #fff; padding: 1.05rem 1.35rem; border-radius: var(--radius); transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease; box-shadow: 0 8px 24px hsla(var(--hue), var(--sat), var(--lig), .25); }
.button { position: relative; overflow: hidden; }
.button i { font-size: 1.25rem; }
.button:hover { background-color: var(--first-color-alt); transform: translateY(-1px); box-shadow: 0 10px 26px hsla(var(--hue), var(--sat), var(--lig), .3); }
.button:focus-visible { outline: 3px solid var(--first-color); outline-offset: 2px; box-shadow: 0 0 0 4px hsla(var(--hue), var(--sat), var(--lig), .25); }
.button__small { padding: .75rem; box-shadow: none; }
.button__gray { background-color: var(--text-color-lighten); color: var(--title-color); }
.button__gray:hover { background-color: var(--text-color-light); }
@media (prefers-reduced-motion: no-preference) {
  .button::after { content: ""; position: absolute; top: -50%; bottom: -50%; left: -30%; width: 30%; transform: skewX(-25deg) translateX(-150%); background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.35) 50%, rgba(255,255,255,0) 100%); filter: blur(.5px); }
  .button:hover::after { transition: transform .6s cubic-bezier(.2,.6,.2,1); transform: skewX(-25deg) translateX(350%); }
}

/*=============== FILTERS TABS===============*/
.filters__content { position: relative; --seg-gap: .25rem; margin: 2rem auto 1.5rem; width: min(100%, 360px); background-color: var(--text-color-lighten); padding: var(--seg-gap); border-radius: calc(var(--radius) + 1rem); display: grid; grid-template-columns: 1fr 1fr; gap: var(--seg-gap); border: 1px solid hsl(var(--hue), 8%, 86%); overflow: hidden; }
.filters__button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; border: none; outline: none; padding: .6rem .9rem; color: var(--title-color); font-size: var(--small-font-size); font-family: var(--body-font); font-weight: 600; border-radius: calc(var(--radius) + .25rem); cursor: pointer; background-color: transparent; transition: color .2s ease; }
.filters__button i { font-size: 1rem; }
[role="tab"].filters__button { flex-direction: column; }
[role="tab"][aria-selected="false"] { color: var(--text-color); }
[role="tab"][aria-selected="true"] { z-index: 2; }
.filters__button[aria-selected="false"] i { opacity: .7; }
.filters__button[aria-selected="true"] i { opacity: 1; }
.filters__button:hover { background-color: var(--body-color); box-shadow: inset 0 0 0 1px hsl(var(--hue), 8%, 90%); }
.filters__button:focus-visible { outline: 3px solid var(--first-color); outline-offset: 2px; }

/* Estado activo/seleccionado para tabs */
[role="tab"][aria-selected="true"], .filter-tab-active { color: var(--title-color); text-shadow: 0 0 1px rgba(0,0,0,.08); }
.dark-theme [role="tab"][aria-selected="true"], .dark-theme .filter-tab-active { color: #fff; }

/* Indicador deslizante */
.filters__content::before { content: ""; position: absolute; top: var(--seg-gap); bottom: var(--seg-gap); left: var(--seg-gap); width: calc(50% - var(--seg-gap)); background: var(--body-color); border-radius: calc(var(--radius) + .75rem); box-shadow: 0 1px 0 0 hsl(var(--hue), 8%, 92%) inset, 0 0 0 1px hsl(var(--hue), 8%, 86%) inset; transform: translateX(var(--seg-x, 0%)); transition: transform .25s cubic-bezier(.2,.6,.2,1), width .25s ease; z-index: 0; pointer-events: none; }
.dark-theme .filters__content::before { box-shadow: 0 1px 0 0 hsl(var(--hue), 8%, 18%) inset, 0 0 0 1px hsl(var(--hue), 8%, 26%) inset; }

/*=============== PROJECTS ===============*/
.projects__card { position: relative; border-radius: var(--radius); overflow: hidden; content-visibility: auto; contain-intrinsic-size: 200px 220px; }
.projects__card[role="link"] { cursor: pointer; }
.projects__card img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.projects__modal { position: absolute; width: 100%; height: 100%; bottom: -100%; left: 0; background: linear-gradient(180deg, hsla(var(--hue), 24%, 40%, .3) 0%, hsla(var(--hue), 24%, 4%, 1) 95%); display: grid; align-items: flex-end; padding: 1.5rem 1.25rem; transition: .3s; }
.projects__modal > div { transform: translateY(8px); transition: transform .3s ease, opacity .3s ease; opacity: .98; }
.projects__subtitle, .projects__title { color: #fff; }
.projects__subtitle { font-size: var(--smaller-font-size); }
.projects__title { font-size: var(--h3-font-size); margin-bottom: .75rem; }
.projects__chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.chip { display: inline-block; font-size: .75rem; padding: .25rem .5rem; border-radius: .5rem; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2); }
.chip--neutral { background: var(--text-color-lighten); color: var(--title-color); border: 1px solid hsl(var(--hue), 8%, 88%); }
.projects__button { padding: .5rem; }
.projects__button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.projects__card:hover .projects__modal { bottom: 0; }
/* Mostrar overlay también con teclado */
.projects__card:focus-within .projects__modal { bottom: 0; }
.projects__card:hover .projects__modal > div,
.projects__card:focus-within .projects__modal > div { transform: translateY(0); }
/* Pequeña elevación al hover/focus de la tarjeta */
.projects__card { transition: transform .2s ease, box-shadow .2s ease; }
.projects__card:hover, .projects__card:focus-within { transform: translateY(-2px) scale(1.01); box-shadow: 0 10px 28px hsla(var(--hue), var(--sat), var(--lig), .22); }
/* Asegurar que los headers de sección dentro del grid ocupen toda la fila */
.projects__content > .section__header,
.skills__content > .section__header { grid-column: 1 / -1; }

/*=============== SKILLS ===============*/
.skills__content { row-gap: 3.5rem; }
.skills__title { font-size: var(--h3-font-size); text-align: center; margin-bottom: 1.5rem; }
.skills__box { display: flex; justify-content: center; column-gap: 3rem; }
/* Centrado de todo el contenido de Habilidades */
.skills__group { display: grid; align-content: flex-start; row-gap: 1rem; }
.skills__data { display: flex; column-gap: .5rem; align-items: center; }
.skills__data > div { text-align: left; }
.skills__data i { font-size: 1rem; color: var(--first-color); }
.skills__name { font-size: var(--normal-font-size); font-weight: 500; line-height: 18px; }
.skills__level { font-size: var(--smaller-font-size); }
.skill-meter { position: relative; height: .4rem; border-radius: 999px; background: var(--text-color-lighten); overflow: hidden; margin-top: .35rem; width: 100%; margin-left: 0; margin-right: 0; }
.skill-meter__fill { height: 100%; background: linear-gradient(90deg, var(--first-color) 0%, var(--first-color-alt) 100%); width: 0; transition: width .7s cubic-bezier(.2,.6,.2,1); }
.skill-meter--active .skill-meter__fill { width: var(--level, 70%); }
@media (prefers-reduced-motion: no-preference) {
  .skill-meter__fill { position: relative; overflow: hidden; }
  .skill-meter--active .skill-meter__fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.35) 18%, rgba(255,255,255,0) 36%); background-size: 200% 100%; animation: sheen-slide 1.2s linear infinite; opacity: .3; }
  @keyframes sheen-slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }
}

/* Hide and show projects & skills */
.filters [data-content] { display: none; }
.filters__active[data-content] { display: grid; }

/*=============== FOOTER ===============*/
.footer__copy { display: block; margin: 2.5rem 0 2rem; text-align: center; font-size: var(--smaller-font-size); color: var(--text-color-light); }
.footer__copy a { color: inherit; position: relative; text-decoration: none; }
@media (prefers-reduced-motion: no-preference) {
  .footer__copy a::after { content: ""; position: absolute; left: 0; bottom: -.15rem; height: 2px; width: 0; background: currentColor; transition: width .25s ease; opacity: .85; }
  .footer__copy a:hover::after, .footer__copy a:focus-visible::after { width: 100%; }
}
/* CTA de contacto */
.contact-cta { margin-top: 3rem; }
.contact-cta__box { background: transparent; border: none; border-radius: calc(var(--radius) + .25rem); padding: 2rem; box-shadow: none; text-align: center; }
.contact-cta__actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

/* Cabeceras de sección */
.section__header { margin: 1rem 0 1.5rem; text-align: center; }
.section__title { font-size: var(--h2-font-size); }
.section__subtitle { color: var(--text-color); font-size: var(--small-font-size); }

/* Animación de despliegue para paneles activos */
@media (prefers-reduced-motion: no-preference) {
  .filters__sections [data-content].filters__active {
    animation: panelIn .28s cubic-bezier(.2,.6,.2,1);
  }
  @keyframes panelIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* Asegurar que las habilidades sean visibles al activar la pestaña (si ScrollReveal aplicó estilos inline) */
.filters__sections #skills.filters__active .skills__group {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}
/* Eliminar encabezado redundante dentro del tab de Habilidades para quitar hueco */
.filters__sections #skills .section__header { display: none; }

/* Micro-interacciones y animaciones sutiles */
@media (prefers-reduced-motion: no-preference) {
  /* Zoom suave en imágenes de proyectos */
  .projects__card img { transition: transform .45s cubic-bezier(.2,.6,.2,1); }
  .projects__card:hover img,
  .projects__card:focus-within img { transform: scale(1.05); }

  /* Chips elevan sutilmente */
  .chip { transition: transform .2s ease, box-shadow .2s ease; }
  .chip:hover { transform: translateY(-2px); box-shadow: 0 6px 14px hsla(var(--hue), var(--sat), var(--lig), .15); }

  /* Avatar y borde con ligera elevación */
  .profile__border { transition: transform .25s cubic-bezier(.2,.6,.2,1), box-shadow .25s; }
  .profile__border:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 12px 30px hsla(var(--hue), var(--sat), var(--lig), .18); }

  /* Íconos sociales con pequeño desplazamiento */
  .profile__social-link { transition: transform .2s ease, color .2s ease; }
  .profile__social-link:hover { transform: translateY(-2px); }

  /* Botones con rebote leve al click */
  .button { transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease; }
  .button:active { transform: translateY(0) scale(.98); }

  /* Tabs: icono flota ligeramente al hover */
  .filters__button { transition: color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s ease; }
  .filters__button:hover i { transform: translateY(-1px); transition: transform .2s ease; }

  /* Toggle de tema con pequeña rotación al presionarlo */
  .change-theme { transition: transform .2s ease, color .2s ease; }
  .change-theme:active { transform: rotate(-15deg) scale(.95); }

  /* Aparición escalonada de los items de skills al activar la pestaña */
  #skills.filters__active .skills__group .skills__data { animation: itemIn .35s ease both; }
  #skills.filters__active .skills__group .skills__data:nth-child(1) { animation-delay: .05s; }
  #skills.filters__active .skills__group .skills__data:nth-child(2) { animation-delay: .1s; }
  #skills.filters__active .skills__group .skills__data:nth-child(3) { animation-delay: .15s; }
  #skills.filters__active .skills__group .skills__data:nth-child(4) { animation-delay: .2s; }
  #skills.filters__active .skills__group .skills__data:nth-child(5) { animation-delay: .25s; }

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

/* Volver arriba */
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  background: var(--first-color);
  color: #fff;
  box-shadow: 0 8px 24px hsla(var(--hue), var(--sat), var(--lig), .25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(.98);
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,.6,.2,1), visibility .25s ease;
  z-index: 999;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.back-to-top:hover { transform: translateY(0) scale(1.03); }
.back-to-top:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/*=============== SCROLL BAR ===============*/
::-webkit-scrollbar { width: .6rem; border-radius: .5rem; background-color: hsl(var(--hue), 8%, 66%); }
::-webkit-scrollbar-thumb { background-color: hsl(var(--hue), 8%, 54%); border-radius: .5rem; }
::-webkit-scrollbar-thumb:hover { background-color: hsl(var(--hue), 8%, 44%); }

/*=============== BREAKPOINTS ===============*/
@media screen and (max-width: 320px) {
  .container { margin-left: 1rem; margin-right: 1rem; }
  .profile__info { column-gap: 1.5rem; }
  .profile__buttons { flex-direction: column; row-gap: 1rem; }
  .skills__box { column-gap: 1rem; }
}

/* Grid fluido para proyectos */
.projects__content { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

@media screen and (min-width: 576px) {
  .filters__content { width: min(100%, 360px); margin: 3rem auto; }
  .skills__content { grid-template-columns: repeat(2, 332px); }
  .skills__content { justify-content: center; column-gap: 3rem; }
}

/* Mejor centrado en móviles: apilar columnas de habilidades */
@media screen and (max-width: 575.98px) {
  .skills__area { text-align: center; }
  .skills__box { flex-direction: column; align-items: center; row-gap: 1.1rem; }
  .skills__group { width: 100%; justify-items: center; }
  .skills__data { justify-content: center; }
  .skills__data > div { text-align: center; }
  .skill-meter { width: min(240px, 80vw); }
}


/* Escala aún mayor en desktop amplio */
@media screen and (min-width: 1200px) {
  :root {
    --h2-font-size: clamp(1.75rem, .9vw + 1.4rem, 2.35rem);
    --h3-font-size: clamp(1.25rem, .7vw + 1rem, 1.5rem);
    --normal-font-size: clamp(1.06rem, .35vw + 1rem, 1.22rem);
    --small-font-size: .925rem;
  }
  .skills__content { grid-template-columns: repeat(2, 360px); column-gap: 3.25rem; }
}
@media screen and (min-width: 992px) {
  .container { margin-left: auto; margin-right: auto; }
  .change-theme { top: 2.5rem; right: 2.5rem; }
  .profile { padding-top: 4rem; }
  .profile__border { width: 150px; height: 150px; margin-bottom: 1rem; border-radius: 50%; }
  .profile__perfil { width: 92%; height: 92%; aspect-ratio: 1 / 1; border-radius: 50%; }
  .profile__profession { margin-bottom: 1.5rem; }
  .profile__info { column-gap: 3rem; }
  .profile__info-description { font-size: var(--small-font-size); }
  .profile__buttons { column-gap: 2rem; }
  .projects__content { gap: 2rem 3rem; }
  .projects__modal { padding: 1.5rem; }
  .skills__title { font-size: var(--normal-font-size); margin-bottom: 2.5rem; }
  .footer__copy { margin: 4.5rem 0 2.5rem; }
}
