/* ==========================================================================
   MYCLOUD.UNO — DYNAMIC ADAPTIVE HEADER (CSS/HEADER.CSS)
   Al inicio: barra completa de ancho completo (100% edge-to-edge)
   Al scrollear: cápsula flotante estilo nube ("pill / cloud navbar")
   ========================================================================== */

.mch, .mch * { box-sizing: border-box; }

/* Espaciador de flujo para evitar saltos o solapamiento en carga inicial */
.mch-space-holder {
  height: calc(72px + env(safe-area-inset-top, 0px));
  width: 100%;
  pointer-events: none;
  visibility: hidden;
}

@media (max-width: 720px) {
  .mch-space-holder {
    height: calc(64px + env(safe-area-inset-top, 0px));
  }
}

/* ==========================================================================
   Contenedor Principal del Header
   - Estado Inicial (Top): ancho 100%, pegado arriba
   - Estado Scrolled: centrado, flotante, ancho máx 760px ("Nube")
   ========================================================================== */
.mch {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  z-index: 1000;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Estado al scrollear: se transforma en la cápsula / nube flotante */
.mch.is-scrolled {
  top: calc(16px + env(safe-area-inset-top, 0px));
  width: min(760px, calc(100% - 28px));
}

/* ==========================================================================
   Barra Interna
   ========================================================================== */
.mch-bar {
  position: relative;
  width: 100%;
  height: calc(72px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: clamp(20px, 4vw, 56px);
  padding-right: clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  background: rgba(26, 29, 73, 0.94);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
          backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(10, 10, 30, 0.25);
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-radius 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Barra interna en modo nube / cápsula */
.mch.is-scrolled .mch-bar {
  height: 68px;
  padding-top: 0;
  padding-left: 24px;
  padding-right: 8px;
  border-radius: 34px;
  background: rgba(30, 33, 70, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 44px rgba(20, 18, 60, 0.45);
}

/* Borde con destello que recorre la cápsula (solo activo en modo nube) */
.mch-bar::before {
  content: "";
  position: absolute;
  left: -1px; top: -1px; right: -1px; bottom: -1px;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(139,147,255,0) 30%, rgba(165,171,255,.95) 50%, rgba(134,239,208,.7) 56%, rgba(139,147,255,0) 70%) 0 0 / 250% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  animation: mch-edge 5s linear infinite;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.mch.is-scrolled .mch-bar::before {
  opacity: 1;
}

/* ==========================================================================
   Logo de Marca
   ========================================================================== */
.mch-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  flex-shrink: 0;
}

.mch-lg {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: #4f46e5;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .55);
  transition: transform .3s cubic-bezier(.3, 1.5, .5, 1);
  animation: mch-bob 3.5s ease-in-out infinite;
}

.mch-logo:hover .mch-lg {
  transform: rotate(-8deg) scale(1.1);
}

.mch-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.mch-name span {
  font-weight: 500;
  color: #8b8ffa;
}

/* ==========================================================================
   Navegación con Indicador Líquido Deslizante
   ========================================================================== */
.mch-nav {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05);
}

.mch-link {
  position: relative;
  z-index: 2;
  height: 38px;
  line-height: 38px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: #c9cdf0;
  text-decoration: none;
  transition: color .2s ease, transform .2s ease;
}

.mch-link:hover, .mch-link:focus-visible, .mch-link.is-active {
  color: #fff;
}

.mch-link:hover {
  transform: translateY(-1px);
}

.mch-link:focus-visible {
  outline: 2px solid #86efd0;
  outline-offset: 2px;
}

/* Indicador deslizante (Liquid Pill) */
.mch-ind {
  position: absolute;
  left: 4px; top: 4px;
  height: 38px;
  width: 0;
  z-index: 1;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(124,128,255,.7), rgba(79,70,229,.55));
  border: 1px solid #8a8ef8;
  box-shadow: 0 0 24px rgba(99,102,241,.6), inset 0 1px 0 rgba(255,255,255,.28);
  pointer-events: none;
  opacity: 0;
}

.mch-ind.is-ready {
  opacity: 1;
  transition: left .4s cubic-bezier(.3, 1.35, .5, 1), width .4s cubic-bezier(.3, 1.35, .5, 1);
}

/* Barra de progreso de lectura */
.mch-prog {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #86efd0, #fbbf24);
  transform-origin: left center;
  transform: scaleX(0);
  pointer-events: none;
  transition: left 0.4s ease, right 0.4s ease;
}

.mch.is-scrolled .mch-prog {
  left: 32px; right: 32px;
  border-radius: 2px;
}

/* ==========================================================================
   Botón Hamburguesa (Móvil)
   ========================================================================== */
.mch-burger {
  display: none;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
}

.mch-burger:focus-visible {
  outline: 2px solid #86efd0;
  outline-offset: 2px;
}

.mch-burger span {
  display: block;
  width: 18px; height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform .3s ease;
}

.mch.is-open .mch-burger span:nth-child(1) {
  transform: translateY(3.5px) rotate(45deg);
}

.mch.is-open .mch-burger span:nth-child(2) {
  transform: translateY(-3.5px) rotate(-45deg);
}

/* ==========================================================================
   Responsive / Móvil (<= 720px)
   ========================================================================== */
@media (max-width: 720px) {
  .mch {
    top: 0;
    width: 100%;
  }

  .mch-bar {
    height: calc(64px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: 18px;
    padding-right: 14px;
  }

  .mch.is-scrolled {
    top: calc(12px + env(safe-area-inset-top, 0px));
    width: calc(100% - 24px);
  }

  .mch.is-scrolled .mch-bar {
    height: 60px;
    padding-top: 0;
    padding-left: 18px;
    padding-right: 8px;
    border-radius: 30px;
  }

  .mch-burger {
    display: flex;
  }

  .mch-nav {
    position: absolute;
    left: 12px; right: 12px;
    top: calc(100% + 10px);
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border-radius: 24px;
    background: rgba(30, 33, 70, .96);
    -webkit-backdrop-filter: blur(16px);
            backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 16px 44px rgba(20, 18, 60, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(.98);
    transform-origin: top center;
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
  }

  .mch.is-open .mch-nav {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }

  .mch-ind {
    display: none;
  }

  .mch-link {
    height: 48px;
    line-height: 48px;
    padding: 0 18px;
    border-radius: 16px;
    font-size: 16px;
  }

  .mch-link.is-active {
    background: rgba(99, 102, 241, .38);
  }
}

/* ==========================================================================
   Animaciones & Preferencias de Movimiento
   ========================================================================== */
@keyframes mch-edge {
  to { background-position: -250% 0; }
}

@keyframes mch-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -2px; }
}

@media (prefers-reduced-motion: reduce) {
  .mch-bar::before, .mch-lg { animation: none; }
  .mch, .mch-bar, .mch-ind.is-ready { transition: none; }
}
