/* ============ RESPONSIVE DESIGN ============ */

/* Tablets */
@media (max-width: 1024px) {
  header {
    padding: 10px 24px;
  }

  .header-projects {
    padding: 10px 24px;
  }

  .presentacion-contenido {
    gap: 40px;
    padding: 2.5rem 2rem;
  }

  .mi-foto {
    width: 280px;
    height: 280px;
  }

  .proyectos,
  .skills,
  .certificaciones {
    padding: 40px 24px;
  }
}

/* Smartphones grandes */
@media (max-width: 768px) {
  /*
   * CRÍTICO: header_cont tiene position:sticky + z-index:500 en base CSS.
   * Eso crea un "stacking context" que atrapa al nav position:fixed dentro de él,
   * impidiendo que los clicks lleguen al nav. Solución: z-index:auto elimina
   * el stacking context y el nav pasa a operar en el contexto raíz.
   */
  .header_cont,
  .header-projects_cont {
    position: relative;        /* sticky → relative: no overlay al scroll, pero nav queda libre */
    z-index: auto;             /* elimina el stacking context */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(13, 13, 13, 0.97);
  }

  header {
    padding: 10px 20px;
  }

  .header-projects {
    padding: 10px 20px;
  }

  /* Menú hamburguesa */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Nav slide desde la derecha */
  header nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: -100%;
    width: 270px;
    height: 100%;
    background: rgba(13, 13, 13, 0.98);
    padding: 80px 24px 40px;
    gap: 8px;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.6);
    z-index: 1100;
    border-left: 1px solid rgba(139, 0, 0, 0.3);
    overflow-y: auto;
  }

  header nav.active {
    right: 0;
  }

  /* Ajustar botones en menú mobile */
  .btn-header {
    font-size: 17px;
    padding: 14px 18px;
    border-radius: 10px;
    color: var(--text-secondary);
    background: transparent;
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
  }

  .btn-header:hover {
    background: rgba(139, 0, 0, 0.12);
    border-color: rgba(139, 0, 0, 0.3);
    color: var(--text-primary);
  }

  /* El botón "Contáctame" en mobile */
  .btn-header:nth-child(2) {
    background: linear-gradient(135deg, #8b0000, #b50000);
    color: #fff;
    border-color: transparent;
    margin-bottom: 8px;
  }

  /* Botones header2 en proyectos */
  .btn-header2 {
    font-size: 17px;
    padding: 14px 18px;
    border-radius: 10px;
    width: 100%;
    text-align: left;
  }

  /* Overlay */
  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1050;
  }

  .overlay.active {
    display: block;
  }

  /* Intro logo */
  .intro-logo {
    width: 55%;
    max-width: 200px;
  }

  /* Hero section */
  .presentacion {
    min-height: auto;
    padding: 20px 0;
  }

  .presentacion-contenido {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 32px;
    padding: 2.5rem 1.5rem;
  }

  .mi-foto {
    width: 220px;
    height: 220px;
    animation: none; /* sin float en mobile */
  }

  .presentacion-text {
    align-items: center;
    text-align: center;
  }

  .hero-eyebrow {
    justify-content: center;
  }

  .hero-name {
    font-size: clamp(2.2rem, 10vw, 3rem);
    text-align: center;
  }

  .hero-role {
    text-align: center;
  }

  .saludo {
    text-align: center;
    font-size: 16px;
  }

  .cv-btn {
    align-self: center;
  }

  .habilidades-card {
    justify-content: center;
  }

  .card-skill {
    min-width: 130px;
  }

  /* Main proyectos */
  .special-projects {
    max-width: 60%;
  }

  .proyectos,
  .skills,
  .certificaciones {
    padding: 32px 20px;
  }

  h2 {
    font-size: 1.8rem;
  }

  /* Cards */
  .cards {
    gap: 16px;
  }

  .card {
    width: calc(50% - 8px);
    min-width: 160px;
  }

  /* Carrusel de diseño */
  .carrusel .slide {
    min-width: 200px;
  }

  .carrusel .slide img {
    height: 150px;
  }

  .carrusel .slide p {
    font-size: 14px;
    margin-top: 8px;
  }

  /* Skills logos */
  .logo-skill {
    max-width: 52px;
    padding: 12px;
  }

  /* Footer */
  footer {
    padding: 48px 20px 36px;
  }

  .footer-h1 {
    font-size: 1.4rem;
  }

  .redes-btn {
    font-size: 14px;
    padding: 10px 16px;
  }

  .redes-btn:hover {
    transform: none;
    margin: 0;
  }

  /* Scroll top button */
  #scrollTopBtn {
    bottom: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}

/* Smartphones pequeños */
@media (max-width: 480px) {
  /* Hero */
  .mi-foto {
    width: 180px;
    height: 180px;
  }

  .hero-name {
    font-size: 2rem;
  }

  .saludo {
    font-size: 15px;
  }

  /* Cards a 1 columna */
  .card {
    width: 100%;
    max-width: 340px;
  }

  /* Logo skills pequeños */
  .logo-skill {
    max-width: 44px;
    padding: 10px;
  }

  /* Certificaciones */
  .cert-card {
    min-width: 100%;
  }

  /* Footer redes */
  .redes-container {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .redes-btn {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
}