/* =====================================================
   Menú móvil (hamburguesa) - reutilizable
   Solo visible en pantallas <= 767px
   ===================================================== */

/* Por defecto ocultos en escritorio */
.mobile-menu-toggle,
.mobile-menu {
  display: none;
}

:root {
  --mobile-menu-cover-h: 100vh;
  --mobile-menu-cover-offset-top: 0px;
}

@supports (height: 100dvh) {
  :root {
    --mobile-menu-cover-h: 100dvh;
  }
}

@media screen and (max-width: 767px) {

  /* ---------- Botón hamburguesa ---------- */
  .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: absolute;
    top: 18px;
    right: 18px;
    width: 44px;
    height: 38px;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    z-index: 1100;
  }

  .mobile-menu-toggle .bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #000;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }

  /* Oculta el botón hamburguesa mientras el menú está abierto */
  body.mobile-menu-open .mobile-menu-toggle {
    display: none;
  }

  /* ---------- Overlay del menú ---------- */
  /*
    iPhone Safari: 100vh suele ignorar barras dinámicas del navegador; el tamaño efectivo viene
    de --mobile-menu-cover-h y --mobile-menu-cover-offset-top (menu.js + visualViewport).
  */
  .mobile-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    left: 0;
    right: 0;
    bottom: auto;
    top: var(--mobile-menu-cover-offset-top, 0px);
    width: 100%;
    height: var(--mobile-menu-cover-h, 100vh);
    min-height: var(--mobile-menu-cover-h, 100vh);
    padding: calc(80px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    background: linear-gradient(to bottom, #D92827 0%, #731515 100%);
    z-index: 1090;
    box-sizing: border-box;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  }

  .mobile-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .mobile-menu-logo {
    width: 40%;
    max-width: 320px;
    margin: 0 auto;
    text-align: center;
    margin-bottom: 40px;
  }

  .mobile-menu-logo img {
    width: 100%;
    max-width: 100%;
  }

  .mobile-menu-profile {
    width: 35%;
    max-width: 320px;
    margin: 0 auto;
    text-align: center;
    margin-bottom: 20px;
  }
  
  .mobile-menu-profile img {
    width: 100%;
    max-width: 100%;
  }
  
  .mobile-menu-profile p {
    color: #ffffff;
    font-size: 16px;
  }

  /* ---------- Botón cerrar (X) ---------- */
  .mobile-menu-close {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: calc(18px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
    z-index: 1101;
  }

  /* ---------- Lista de links ---------- */
  .mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 320px;
    text-align: left;
  }

  .mobile-menu-list li {
    margin: 14px 0;
  }

  .mobile-menu-list a {
    display: block;
    padding: 12px 18px 12px 50px;
    color: #ffffff;
    font-family: 'DIN', sans-serif;
    font-size: 22px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transition: color 0.2s ease;
  }

  .mobile-menu-list li:first-child a {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  .mobile-menu-list a:hover,
  .mobile-menu-list a:focus {
    color: #ffd54a;
  }

  /* Bloquea scroll del body cuando el menú está abierto */
  body.mobile-menu-open {
    overflow: hidden;
  }
}
