/* EKON — Mejoras móvil (safe areas, toques) en toda la web. */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@supports (selector(:has(*))) {
    @media (max-width: 767.98px) {
        html:has(body.perfil-pagina) {
            height: 100%;
        }
    }
}

@media (max-width: 767.98px) {
    html.perfil-html {
        height: 100%;
    }
}

/*
 * Perfil móvil: rejilla fija — tarjeta desplazable arriba, botón «Añadir contacto» siempre abajo.
 * Sin transform/scale (evita solapamientos con empresa, enlaces, etc.).
 */
@media (max-width: 767.98px) {
    body.perfil-pagina {
        position: relative;
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: 100dvh;
        min-height: 100svh;
        margin: 0;
        padding: 0;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .perfil-surface {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
        width: 100%;
        overflow: hidden;
        background: #030306;
    }

    body.perfil-pagina a,
    body.perfil-pagina button,
    body.perfil-pagina [role="button"] {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 212, 255, 0.12);
    }

    .perfil-shell {
        flex: 1 1 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
        width: 100%;
        padding-top: env(safe-area-inset-top, 0);
        overflow: hidden;
    }

    #perfilStage.perfil-stage {
        flex: 1 1 0;
        min-height: 0;
        min-width: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        overflow: hidden;
    }

    #mainContent {
        flex: 1 1 0;
        min-height: 0;
        min-width: 0;
        width: 100%;
        max-width: 22rem;
        margin-left: auto;
        margin-right: auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-top: 0.35rem;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    /* Rejilla: fila 1 = scroll tarjeta, fila 2 = CTA fijo */
    .perfil-viewport {
        flex: 1 1 0;
        min-height: 0;
        width: 100%;
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 0.5rem;
        align-content: stretch;
        box-sizing: border-box;
        padding: 0 max(0.5rem, env(safe-area-inset-left, 0px)) 0.25rem max(0.5rem, env(safe-area-inset-right, 0px));
    }

    .perfil-scroll {
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 212, 255, 0.35) transparent;
    }

    .perfil-scroll::-webkit-scrollbar {
        width: 4px;
    }

    .perfil-scroll::-webkit-scrollbar-thumb {
        background: rgba(0, 212, 255, 0.35);
        border-radius: 4px;
    }

    #profileCard.ekon-identity-card {
        width: 100%;
        max-width: 22rem;
        margin-left: auto;
        margin-right: auto;
    }

    .perfil-cta-bar,
    #perfilCtaDock.perfil-cta-bar {
        grid-row: 2;
        flex-shrink: 0;
        width: 100%;
        max-width: 22rem;
        margin-left: auto;
        margin-right: auto;
        position: relative;
        z-index: 2;
        padding-bottom: max(0.15rem, env(safe-area-inset-bottom, 0px));
    }

    #perfilFooter.perfil-foot-glass {
        flex-shrink: 0;
        padding-top: 0.4rem;
        padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
    }

    body.perfil-pagina .ekon-link-pill {
        min-height: 2.65rem;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    body.perfil-pagina.perfil-has-team #profileCard {
        padding-top: 0.75rem;
        padding-bottom: 0.5rem;
    }

    body.perfil-pagina.perfil-has-team #pAvatar {
        width: 4.25rem !important;
        height: 4.25rem !important;
        margin-bottom: 0.4rem !important;
        font-size: 1.35rem !important;
    }

    body.perfil-pagina.perfil-has-team #pName {
        font-size: 1.55rem !important;
        line-height: 1.12 !important;
        margin-bottom: 0.15rem !important;
    }

    body.perfil-pagina.perfil-has-team #pRole {
        margin-bottom: 0.3rem !important;
        font-size: 0.82rem !important;
    }

    #teamBrandWrap.show {
        display: flex;
        justify-content: center;
        width: 100%;
        min-width: 0;
    }

    #teamBrandPill {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 100%;
        max-width: min(100%, 17.5rem);
        margin-left: auto;
        margin-right: auto;
        padding: 0.55rem 0.8rem 0.6rem;
        gap: 0.28rem;
        box-sizing: border-box;
        min-width: 0;
    }

    #teamBrandPill .team-brand-icon {
        width: 2.25rem;
        height: 2.25rem;
        margin: 0 auto;
        flex-shrink: 0;
    }

    #teamBrandPill .team-brand-eyebrow {
        display: block;
        width: 100%;
        text-align: center;
        margin: 0;
        font-size: 0.56rem;
        letter-spacing: 0.2em;
        line-height: 1.2;
    }

    #teamBrandPill #teamBrandName {
        width: 100%;
        max-width: 100%;
        text-align: center;
        font-size: 0.86rem;
        line-height: 1.35;
        margin: 0;
        padding: 0 0.15rem;
        box-sizing: border-box;
        word-break: normal;
        overflow-wrap: break-word;
        hyphens: none;
    }

    body.perfil-pagina.perfil-has-team #teamBrandPill {
        padding: 0.5rem 0.7rem 0.55rem;
        gap: 0.22rem;
    }

    body.perfil-pagina.perfil-has-team .team-brand-icon {
        width: 2rem;
        height: 2rem;
    }

    body.perfil-pagina.perfil-has-team #teamBrandName {
        font-size: 0.8rem;
        line-height: 1.32;
    }

    body.perfil-pagina.perfil-has-team #pBio {
        margin-bottom: 0.45rem !important;
    }

    body.perfil-pagina.perfil-has-team .perfil-contact-rows {
        margin-bottom: 0.45rem !important;
    }

    body.perfil-pagina.perfil-has-team .ekon-link-pill {
        min-height: 2.4rem;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }
}

@media (min-width: 768px) {
    body.perfil-pagina {
        min-height: 100vh;
    }

    .perfil-shell {
        min-height: 100vh;
    }

    #perfilStage.perfil-stage {
        align-items: center;
    }

    #mainContent {
        width: 100%;
        max-width: 22rem;
        margin-left: auto;
        margin-right: auto;
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .perfil-viewport {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 1rem;
        width: 100%;
    }

    .perfil-scroll {
        overflow: visible;
        flex: 0 1 auto;
    }

    .perfil-cta-bar,
    #perfilCtaDock.perfil-cta-bar {
        flex-shrink: 0;
        width: 100%;
        max-width: 22rem;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 640px) {
    body.legal-page .legal-wrap {
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
        padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
    }

    body.legal-page .legal-topbar {
        flex-wrap: wrap;
    }
}

button,
a[href] {
    -webkit-tap-highlight-color: rgba(0, 212, 255, 0.12);
}
