/* --- 1. ROOT --- */
/* Declaración de la fuente */
@font-face {
  font-family: "Roboto Flex";
  src: url("./assets/fonts/roboto-flex.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Colores de Alta Saliencia y Bajo Consumo (OLED) */
  --bg-primary: #050505;
  --bg-surface: #121212;
  --accent-red: #ff003c;
  --accent-violet: #8b00ff;
  --text-main: #f5f5f7;
  --text-dim: #a1a1a6;

  /* Tipografía Fluida y Variable */
  --font-main: "Roboto Flex", system-ui, sans-serif;
  --fs-base: clamp(1rem, 0.95rem + 0.25vw, 1.25rem);
  --fs-h1: clamp(2.5rem, 6vw + 1rem, 5rem);
  --fs-h2: clamp(1.8rem, 4vw + 1rem, 3rem);
  --fs-h3: clamp(1.2rem, 2vw + 1rem, 1.8rem);
  --fw-main: clamp(400, 350 + 0.5vw, 450);
  --fw-headings: 700;

  /* Espaciados y Efectos */
  --gap-bento: 1.5rem;
  --section-padding: clamp(2rem, 9vh, 7rem) 5%;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Ruta de la imagen del logo */
  --logo-url: url("assets/logo-bm.png");
}

/* --- 2. RESET Y BASE (A11y y Rendimiento) --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth; /* Accesibilidad: Navegación suave nativa */
}

body {
  font-family: var(--font-main);
  font-size: var(--fs-base);
  font-weight: var(--fw-main);
  font-optical-sizing: auto;
  line-height: 1.6;
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  font-weight: var(--fw-headings);
  line-height: 1.1;
  margin-block-end: 0.5em;
  color: var(--text-main);
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* --- 3. COMPONENTES (BEM Methodology) --- */

/* Header & Navegación */
.header {
  position: sticky;
  top: 0;
  width: 100%;
  padding: 0.5rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  background: linear-gradient(
    to bottom,
    rgba(5, 5, 5, 0.9) 0%,
    rgba(5, 5, 5, 0) 100%
  );
  backdrop-filter: blur(5px);
  height: 70px;
}

/* Glitch Logo Effect */
.logo {
  position: relative;
  /* display: inline-block; */
  height: 50%;
  aspect-ratio: 130 / 40;
  background-image: var(--logo-url);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  align-self: center;
}

.logo::before,
.logo::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: var(--logo-url);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
}

.logo:hover::before {
  opacity: 1;
  left: 2px;
  filter: drop-shadow(-2px 0 var(--accent-red));
  clip-path: inset(24% 0 58% 0);
  animation: glitch-anim-1 2.5s infinite linear alternate-reverse;
}

.logo:hover::after {
  opacity: 1;
  left: -2px;
  filter: drop-shadow(2px 0 var(--accent-violet));
  clip-path: inset(54% 0 7% 0);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0% {
    clip-path: inset(20% 0 80% 0);
  }
  20% {
    clip-path: inset(60% 0 10% 0);
  }
  40% {
    clip-path: inset(40% 0 50% 0);
  }
  60% {
    clip-path: inset(80% 0 5% 0);
  }
  80% {
    clip-path: inset(10% 0 70% 0);
  }
  100% {
    clip-path: inset(30% 0 20% 0);
  }
}

@keyframes glitch-anim-2 {
  0% {
    clip-path: inset(10% 0 60% 0);
  }
  20% {
    clip-path: inset(30% 0 20% 0);
  }
  40% {
    clip-path: inset(70% 0 10% 0);
  }
  60% {
    clip-path: inset(20% 0 50% 0);
  }
  80% {
    clip-path: inset(50% 0 30% 0);
  }
  100% {
    clip-path: inset(5% 0 80% 0);
  }
}

/* Botón Menú */
.menu-toggle {
  color: var(--text-main);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-variation-settings: "wght" 700;
  transition: var(--transition-fast);
}

.menu-toggle:hover {
  color: var(--accent-red);
  filter: drop-shadow(0 0 5px var(--accent-red));
}

/* Dialog Sidebar (HTML5 Nativo) */
.sidebar {
  margin-left: auto; /* Alineado a la derecha */
  height: 100vh;
  width: min(400px, 100%);
  background-color: var(--bg-surface);
  border: none;
  border-left: 1px solid rgba(255, 0, 60, 0.3);
  color: var(--text-main);
  padding: 0 3rem;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
}

/* Hack para animar dialog nativo */
.sidebar[open] {
  transform: translateX(0);
}

.sidebar::backdrop {
  background: rgba(5, 5, 5, 0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.sidebar[open]::backdrop {
  opacity: 1;
}

.sidebar__close {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  color: var(--text-dim);
  font-size: 2rem;
  transition: var(--transition-fast);
}

.sidebar__close:hover {
  color: var(--accent-red);
  transform: rotate(90deg);
}

.sidebar__nav {
  margin-top: 3rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar__link {
  font-size: var(--fs-h3);
  font-variation-settings: "wght" 300;
  transition: var(--transition-fast);
  display: inline-block;
}

.sidebar__link:hover {
  color: var(--accent-red);
  font-variation-settings: "wght" 600;
  transform: translateX(10px);
}

/* --- 4. HERO --- */

.hero {
  min-height: 100vh;
  padding: var(--section-padding);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  position: relative;
}

.hero__content {
  flex: 1 1 500px;
  z-index: 2;
}

@media (max-width: 968px) {
  .hero {
    flex-direction: column;
    text-align: center;
    gap: 2rem;
  }
  .hero__content {
    width: 100%;
  }
}

.hero__title {
  font-size: var(--fs-h1);
  font-variation-settings: "wght" 900;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.hero__title-accent {
  background: linear-gradient(90deg, var(--accent-red), var(--accent-violet));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
}

.hero__text {
  color: var(--text-dim);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  margin-bottom: 2.5rem;
  max-width: 600px;
}

@media (max-width: 768px) {
  .hero__text {
    margin-left: auto;
    margin-right: auto;
  }
}

.hero__text--highlight {
  color: var(--text-main);
  font-weight: 500;
}

.btn-neon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 2.5rem;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-variation-settings: "wght" 700;
  position: relative;
  transition: var(--transition-smooth);
  background: transparent;
  /* Resplandor (glow) optimizado para GPU */
  filter: drop-shadow(0 0 4px rgba(255, 0, 60, 0.4));
}

.btn-neon:hover,
.btn-neon:focus {
  background-color: var(--accent-red);
  color: var(--bg-primary);
  filter: drop-shadow(0 0 15px var(--accent-red));
}

.hero__actions {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 768px) {
  .hero__actions {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .hero__actions .btn-neon {
    width: 100%;
    text-align: center;
  }
}

.hero__image-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 450px;
  position: relative;
}

/* Efecto halo detrás del retrato */
.hero__image-wrapper::before {
  content: "";
  position: absolute;
  width: 80%;
  height: 80%;
  background: var(--accent-violet);
  filter: blur(100px);
  opacity: 0.3;
  z-index: 0;
  border-radius: 50%;
}

.hero__portrait {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 20px;
  /* object-fit: cover; */
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  background-color: var(--bg-surface);
  display: block;
  z-index: 1;
}

.hero__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Efecto sutil para integrar la foto */
  filter: grayscale(20%) contrast(1.1);
  transition: var(--transition-smooth);
}

.hero__portrait:hover img {
  filter: grayscale(0%) contrast(1.2);
  transform: scale(1.02);
}

/* --- 5. SECCIONES GENERALES --- */

.projects,
.skills,
.faq,
.education {
  padding: var(--section-padding);
}

.section-title {
  font-size: var(--fs-h2);
  font-variation-settings: "wght" 800;
  margin-bottom: 3rem;
  position: relative;
  padding-left: 1.5rem;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  height: 80%;
  width: 4px;
  background-color: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
}

.project-card__text,
.skills-card__text,
.faq-card__text,
.education-card__text {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* --- 6. PROYECTOS --- */

.projects__list {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.project-card {
  background-color: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 3rem;
  border-radius: 12px;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  border-color: rgba(255, 0, 60, 0.3);
  box-shadow: 0 5px 30px -5px rgba(255, 0, 60, 0.8);
}

.project-card__status {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-violet);
  border: 1px solid var(--accent-violet);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
}

@media (max-width: 600px) {
  .project-card {
    padding: 1.5rem;
  }

  .project-card__status {
    position: relative;
    top: 0;
    right: 0;
    align-self: flex-start;
    margin-bottom: 1rem;
  }
}

.project-card__title {
  font-size: var(--fs-h3);
  margin-bottom: 1rem;
  font-variation-settings: "wght" 700;
}

/* --- 7. SKILLS (Habilidades) - :has() CSS --- */
/* --- --- & --- --- */
/* --- 8. FAQ (AEO: Answer Engine Optimization) --- */

.faq {
  background: #0a0a0a;
}

.skills-grid,
.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap-bento);
}

.skills-card,
.faq-card {
  background-color: var(--bg-surface);
  padding: 2.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skills-card__title,
.faq-card__title {
  font-size: 1.5rem;
  color: var(--accent-red);
  font-variation-settings: "wght" 600;
}

/* Efecto Foco: :has() */
/* Si la cuadrícula tiene un elemento con hover, a los que NO tienen hover les bajamos la opacidad */
@supports selector(:has(a)) {
  .skills-grid:has(.skills-card:hover) .skills-card:not(:hover),
  .faq-grid:has(.faq-card:hover) .faq-card:not(:hover) {
    opacity: 0.4;
    filter: grayscale(80%);
  }
}

.skills-card:hover,
.faq-card:hover {
  border-color: var(--accent-red);
  box-shadow: 0 0 20px rgba(255, 0, 60, 0.1);
}

/* --- 9. FORMACIÓN (PESTAÑAS) --- */

.education {
  background: #080808;
}
.tabs {
  display: flex;
  gap: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 3rem;
}
.tab-btn {
  padding: 1rem 0;
  font-variation-settings: "wght" 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
}
.tab-btn.active {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.education__grid {
  display: none;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.education__grid.active {
  display: grid;
}

.education-card {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--bg-surface);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition-smooth);
  position: relative;
}
.education-card:hover {
  border-color: var(--accent-red);
}

.education-card__image-container {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.education-card__image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.education-card__content {
  flex-grow: 1;
}

.education-card__title {
  color: var(--text-main);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  font-variation-settings: "wght" 700;
}

.education-card__status {
  position: absolute;
  top: 15%;
  /* transform: translateY(-50%); */
  right: 2rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-violet);
  border: 1px solid var(--accent-violet);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
}

@media (max-width: 600px) {
  .education-card {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1rem;
  }
  .tabs {
    gap: 1rem;
    justify-content: center;
  }
  .tab-btn {
    font-size: 0.8rem;
  }
  .education-card__status {
    position: static;
    display: inline-block;
    transform: none;
    margin-bottom: 1.2rem; /* Espacio con el título */
    align-self: center;
  }
}

/* --- CONTACTO --- */

.contact {
  padding: var(--section-padding);
  background: #0a0a0a; /* mismo tono que FAQ */
  text-align: center;
}

.contact__container {
  max-width: 700px;
  margin: 0 auto;
}

.contact__text {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.contact__status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 2.5rem;
}

.status-primary {
  color: var(--accent-red);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-secondary {
  color: var(--accent-violet);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.contact__actions {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* Variante botón secundaria */
.btn-neon--secondary {
  border-color: var(--accent-violet);
  color: var(--accent-violet);
  filter: drop-shadow(0 0 4px rgba(139, 0, 255, 0.4));
}

.btn-neon--secondary:hover {
  background-color: var(--accent-violet);
  color: var(--bg-primary);
  filter: drop-shadow(0 0 15px var(--accent-violet));
}

/* Footer */
.footer {
  padding: 4rem 5%;
  background-color: var(--bg-surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer__copy {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer__copy span {
  font-size: 0.8rem;
  color: var(--accent-red);
}

.footer__social-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer__social-link {
  display: flex;
  color: var(--text-dim);
}

.footer__social-link svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  transition: var(--transition-fast);
}

.footer__social-link:hover {
  color: var(--accent-violet);
  filter: drop-shadow(0 0 8px var(--accent-violet));
  transform: translateY(-3px);
}

.footer__social-link--cv {
  flex-direction: column;
  gap: 0;
  align-items: center;
  margin-left: -0.3rem;
}

.footer__cv-label {
  font-size: 0.9rem;
  font-variation-settings: "wght" 800;
  letter-spacing: 1px;
  line-height: 1;
  text-transform: uppercase;
  text-align: center;
}

@media (max-width: 968px) {
  .hero {
    flex-direction: column;
    text-align: center;
  }
  .footer {
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
  }
  .footer__social-list {
    gap: 2rem;
    justify-content: center;
  }
}
